|
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
|
|
|
|
|
I have 3 files in my folder test1 , test2 , test3
i use FindFirstFile command
and when i type m_List.AddString(pTempFind.cFilename);
Listbox appear me 'Eu|
|
|
|
|
|
But what is the value of pTempFind.cFilename at the time AddString() is called? Set a breakpoint and check the debug window.
"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
|
|
|
|
|
value is MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM i see :/ it has wrong value
my code is
m_FolderName = "C:\dsadasdxzc\";
WIN32_FIND_DATA pTempFind;
HANDLE hFile = FindFirstFile(m_FolderName, &pTempFind);
m_List.AddString(pTempFind.cFilename);
while (FindNextFile(hFile, &pTempFind))
{
m_List.AddString(pTempFind.cFilename);
}
|
|
|
|
|
Immunity18 wrote: m_FolderName = "C:\dsadasdxzc\";
Shouldn't the string literal have double backslashes?
Why are you not checking the return value of FindFirstFile() ?
Going back to what I asked earlier, why not use the CFileFind class?
"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
|
|
|
|
|
Right now I'm creating a program that declares a structure, which also has enum inside it. Now I believe I declare the structure right, but the next step is to create a loop that has the user enter 5 different items of data for library information. But I have to use pointers, so when the loop runs and I enter the information, the data has to be sent to a structure variable only once all six attributes are entered, and the pointer values should be used to create the structure.
I was given an example:
cin >> a;<br />
cin >> b;<br />
library.dewey = &aptr;
This is my code so far:
struct card_catalogue
{
float dewey;<br />
string title;<br />
string author;<br />
int released;<br />
int num_pages;<br />
enum type {fiction, nonfiction, reference, pond};<br />
};<br />
<br />
int main()<br />
{ <br />
card_catalogue books;<br />
<br />
<br />
cout<< "Enter the Dewey Decimal Number please: ";<br />
cin>> books.dewey;<br />
cout<< "Enter the Title of the book please: ";<br />
getline(cin, books.title);<br />
cout<< "Enter the Author of the book please: ";<br />
getline(cin, books.author);<br />
cout<< "Enter the Year of Release please: ";<br />
cin>> books.released;<br />
cout<< "Enter the Number of Pages please: ";<br />
cin>> books.num_pages;<br />
cout<< "Enter the type: ";<br />
getline(cin, books.type);<br />
<br />
<br />
return 0;<br />
}
|
|
|
|
|
klutez123 wrote: But I have to use pointers...
Why? They are not necessary for what you are doing.
klutez123 wrote: card_catalogue books;
Should be:
card_catalogue books[5]; You then need to wrap your cout /cin statements in a for loop.
"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
|
|
|
|