|
Cool does it work like you need it to? I was never sure what you were up to
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
|
how do I input info entered for a enumerated object?
enum typeofbook {fiction, nonfiction, reference, pond};
I'm trying to prompt the user which type of book they are entering information for.
Any ideas would be appreciated.
thanks
|
|
|
|
|
Your question is not very clear.
cout << "Which type of book... (1=fiction, 2=nonfiction, 3=reference, 4=pond)";
int nType;
cin >> nType;
switch (nType)
{
case 1:
break;
...
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I put enum typeofbook {fiction, nonfiction, reference, pond}; in a structure which is then declared the structure as books. I am asking the user which type of book he is entering information for, 1 fiction, 2 nonfiction, 3 reference, 4 pond. Once they enter either the number or name for type of book, I need to cin>> the information or something so I can store into a text file.
|
|
|
|
|
enum are only an internal semantic representation of an integer value.
you will store the integer value; not it's "representation"
if a user enters 1 ( in the enum is fiction ) it will be stored as 1.
pseudo code :
you can either directly do something like :
typedef enum {fiction, nonfiction, reference, pond} typeofbook;
typeofbook myBookType;
int i;
cin>>i;
myBookType = (typeofbook) i;
|
|
|
|
|
Dear all
this is very urgent issue for my project, my image processing interface is 2-dimenssion image procesing. but how to build a 3-dimenssion image processing inside my interface?
thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
Your question is very generic. If you want to render a 3D scene in your application, I suggest you take a look at DirectX or OpenGL.
|
|
|
|
|
|
Dear All;
I am trying to save an image to my harddrive, the image should be of depth 24 or less ie.16, 8, 4. regardless of of the monitor's resolution
I have the tried the following code and its works fine but the saved images are of 32 bit depth. I have tried to fiddle with the code but i cant get an image of 24 bit depth or less , can anyone please advise and i will be grateful.
<br />
void Example:: SaveBitmap(char *name,HBITMAP hBitMap)<br />
{<br />
CBitmap bmp;<br />
bmp.Attach(hBitMap);<br />
<br />
BITMAP bitmap;<br />
bmp.GetBitmap(&bitmap);<br />
int size = bitmap.bmWidth*bitmap.bmHeight*bitmap.bmBitsPixel/8;<br />
BYTE *lpBits = new BYTE[size];<br />
<br />
::GetBitmapBits(hBitMap,size,lpBits);<br />
WriteBmp(name,&bitmap,(int*)lpBits);<br />
delete []lpBits;<br />
}<br />
void Example::WriteBmp(char* name,BITMAP *bmp,int* data)<br />
{<br />
BITMAPINFO Bmi;<br />
memset(&Bmi,0,sizeof(BITMAPINFO));<br />
Bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);<br />
Bmi.bmiHeader.biWidth = bmp->bmWidth;<br />
Bmi.bmiHeader.biHeight = bmp->bmHeight;<br />
Bmi.bmiHeader.biPlanes = 1;<br />
Bmi.bmiHeader.biBitCount = bmp->bmBitsPixel;<br />
Bmi.bmiHeader.biCompression = BI_RGB;<br />
Bmi.bmiHeader.biSizeImage = bmp->bmHeight*bmp->bmWidth*bmp->bmBitsPixel/8;<br />
<br />
FILE* image = fopen (name,"wb");<br />
if(image==0)<br />
return;<br />
int h = abs(Bmi.bmiHeader.biHeight);<br />
int w = abs(Bmi.bmiHeader.biWidth);<br />
Bmi.bmiHeader.biHeight=-h;<br />
Bmi.bmiHeader.biWidth=w;<br />
int sz = Bmi.bmiHeader.biSizeImage;<br />
<br />
BITMAPFILEHEADER bfh;<br />
bfh.bfType=('M'<<8)+'B'; <br />
bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); <br />
bfh.bfSize=sz+bfh.bfOffBits; <br />
bfh.bfReserved1=0; <br />
bfh.bfReserved2=0; <br />
fwrite(&bfh,sizeof(bfh),1,image);<br />
fwrite(&Bmi.bmiHeader,sizeof(BITMAPINFOHEADER),1,image);<br />
fwrite(data,sz,1,image);<br />
fclose(image);<br />
}<br />
<\code><br />
<br />
Thank you <br />
<br />
<div class="ForumSig">llp00na</div>
|
|
|
|
|
You are converting a device-dependent bitmap (DDB) to a device independent bitmap (DIB) to save.
Since you don't do any conversion of the bitmap format, if the source DDB is 32-bit, then the
saved DIB is 32-bit.
If you want to convert the format, you can use GetDIBits() to get the DIB bits in the format you
want.
See How To Convert Between Device-Dependent Bitmaps and DIBs[^]
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: Since you don't do any conversion of the bitmap format, if the source DDB is 32-bit, then the
saved DIB is 32-bit.
Its because i don't know how to convert from a 32 bit bitmap to a less depth bitmap.
Mark Salsbery wrote: See How To Convert Between Device-Dependent Bitmaps and DIBs[^]
Thank you for the article, i will go through it and give it a go.
I am gratefull for your valuable assistance .
llp00na
|
|
|
|
|
Here's another link: Converting DDB to DIB[^]
In that code, the BITMAPINFOHEADER biPlanes, biBitCount, and biCompression members are initialized
to match the source DDB.
To change the type, set those members to the actual format you want before making the first
call to GetDIBits.
Remember, for 1, 4, and 8 bit formats you'll need to deal with a color table in the DIB.
For 24-bit, there's no color table. See the documentation for BITMAPINFOHEADER for details.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: Remember, for 1, 4, and 8 bit formats you'll need to deal with a color table in the DIB.
For 24-bit, there's no color table. See the documentation for BITMAPINFOHEADER for details.
Alright then, i will convert it to a 16 or 24 bit bitmap then. I dont want to run into complications.
Mark Salsbery wrote: Here's another link: Converting DDB to DIB[^]
Many thanx, I am once again very grateful
llp00na
|
|
|
|
|
He will need to deal with CPalette too
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
what are the basic functionality difference between this two header files???
can any one explain me in detail ???
Thanks in advance.
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
I don't know about detail, but ...
wininet.h is the header file for the WinINet APIs:
"The Windows Internet (WinINet) application programming interface (API) enables applications to
interact with Gopher, FTP, and HTTP protocols to access Internet resources. "
winsock.h is the header file for the Windows Sockets 2 APIs:
"Windows Sockets 2 (Winsock) enables programmers to create advanced Internet, intranet, and other
network-capable applications to transmit application data across the wire, independent of the
network protocol being used."
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
can winsock do the functionality of WinINet?
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
You could write your own FTP/HTTP/etc. code using Windows Sockets but you'd need to thoroughly
understand those protocols. The idea of WinInet is to make that easier. WinInet is probably
using sockets for its communication.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Dear Mark,
I really appreciate your response, can you provide me any example or link of winsock
Which is used FTP/HTTP/GOPHER?. One thing more,
Winsock used any default protocol ?
Questions:
1) how the checksum play role in this socket programming.?
2) what is the difference between synchronous and asynchronous socket?
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
Hi in my code i search a folder for all files it contains
WIN32_FIND_DATA pTempFind;
HANDLE hFile = FindFirstFile(m_FolderName, &pTempFind);
with the code pTempFind.cFilename you get the name of the file ? (as CString ?)
I want to get the file name in String format so i can add in my List box
|
|
|
|
|
from a reseach on google i find that i need
to convert string array to string
how i can do it in C++ ? (i only found for java :/)
|
|
|
|
|
Immunity18 wrote:
with the code pTempFind.cFilename you get the name of the file ? (as CString ?)
No, it's a TCHAR array. Why would you think it's a CString ?
Immunity18 wrote: I want to get the file name in String format so i can add in my List box
Are you sending the listbox a LB_ADDSTRING message? For example:
SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM) pTempFind.cFilename);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i have my list box variable m_List
and i add strings by m_List.AddString(str) (CString);
i had on my code m_List.AddString(pTempFind.cFilename);
and list box appear some strange letters
|
|
|
|
|
Immunity18 wrote: i have my list box variable m_List
Assuming that m_List is a CListBox object, why are you not also using CFileFind() ?
Immunity18 wrote: i had on my code m_List.AddString(pTempFind.cFilename);
What is the value of pTempFind.cFilename at this point?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|