|
But some titles are depend for example read and write to sql maybe its for sql forum
|
|
|
|
|
hi i want to copy bitmap file from disk to memory and then read it bits and after changing some bits then i want to save agian to the file.
i could do that reading bit by bit but that is slow method which i dont want so i want to copy whole image to memory at once.
i m using this code to read/copy image into memory,
HANDLE handle=CreateFile("D:\\tasleem.bmp",GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);<br />
if (handle == INVALID_HANDLE_VALUE)<br />
{<br />
return 0;<br />
}<br />
DWORD fileSize=GetFileSize(handle,NULL);<br />
DWORD bytesReaded,bytesWritten;<br />
<br />
unsigned char *Rbuff=new char[fileSize];<br />
ReadFile(handle,(LPVOID)Rbuff,fileSize,&bytesReaded,NULL);<br />
if (bytesReaded==0)<br />
return 0;<br />
CloseHandle(handle);
i looked at bytesreaded variable by debugging its equal to the fileSize variable but when i try to display from memory into console it does not show,any it show garbage.
when i write on another file data from Rbuffer then that is copied and iamge is copy of that hence it all works i think problem is with accessing/display values.
i m trying to show bitmapfile header and info header structure of bitmap only for verification that it works or not.here is the code
cout<<"\n Bitmap File header";<br />
cout<<"\n"<<Rbuff[i];<br />
i+=2;<br />
cout<<"\n"<<Rbuff[i];<br />
i+=4;<br />
cout<<"\n"<<Rbuff[i];<br />
i+=2;<br />
cout<<"\n"<<Rbuff[i];<br />
i+=2;<br />
cout<<"\n"<<Rbuff[i];<br />
i+=4;<br />
cout<<"\n"<<Rbuff[i];
-- modified at 11:21 Tuesday 14th November, 2006
Tasleem Arif
|
|
|
|
|
tasleem143 wrote: DWORD file=GetFileSize(handle,NULL);
Just curious, but do you supopose that someone three weeks from now will be able to discern that file represents the size of a file?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i had changed that it was just the test code a part of program it was not final version code with variable.i just changed that on ur demand
top fileSize ,which was not my question its still on.
Tasleem Arif
|
|
|
|
|
tasleem143 wrote: unsigned char *Rbuff=new char[fileSize];
Why are you allocating char s for an unsigned char variable?
tasleem143 wrote: cout<<"\n Bitmap File header";
cout<<"\n"<<rbuff[i];< blockquote="">
Use endl instead of \n . Otherwise, cout 's caching will mess you up.
Is cout producing anything? If it looks like a memory address, you might need to cast it to a char ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
tasleem143 wrote:
unsigned char *Rbuff=new char[fileSize];
sorry for this mistake,it was char* then i forget to replaced other side.
yes cout displays but these are fake char like BM p ? ( etc.
Tasleem Arif
|
|
|
|
|
tasleem143 wrote: fake char like BM p ?
Last time I checked, B, M, p, and ? were all real characters. What exactly are you referring to?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i want to see the exact fields values present in the bitmapfileheader and bitmapfileinfo,when i read bit by bit from hard disk using fread etc then those values are not matched with the current i mean read through memory values i want that both should match so that i m confirmed that these r valid values from memory.
Tasleem Arif
|
|
|
|
|
tasleem143 wrote: i want to see the exact fields values present in the bitmapfileheader and bitmapfileinfo,when i read bit by bit from hard disk using fread...
So why aren't you doing something like:
CFile fileBitmap;
BITMAPFILEHEADER rBitmapFileHeader;
BITMAPINFOHEADER rBitmapInfoHeader;
fileBitmap.Open(strFilename, CFile::modeRead);
fileBitmap.Read(&rBitmapFileHeader, sizeof(BITMAPFILEHEADER));
fileBitmap.Read(&rBitmapInfoHeader, sizeof(BITMAPINFOHEADER));
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks for replay!
i had done that b4 and it works,The purpose of reading from memory n displaying was that i want to confirm that bitmaps is correctaly copied in memory, and purpose of displaying through cout<< was that i m varified that both outputs are same, and if i perform the operations like changing its bits from memory then get the correct bits to change.
what i m doing i had read the file from disk through 2 methods
1.as u mentioned above and it works fine reading byte by byte or structure but this method is slow as i had to read the whole image byte by byte and it will take lot of time.
2.Through second method i m reading the whole image once not like byte by byte as method 1. i.e
file.read(buffer,filesize);
what i m doing is displaying the data using cout and confirming that both workd fine or not.
hope now u understood the situation.
Tasleem Arif
|
|
|
|
|
Is anyone kindly to tell me how can i save and resotre the child frames that last opened in a MDI program?
In the Main Frame,left side is a Tree Pane,when we selected a tree item and double click,it will create a corresponding child frame,The Child Frames are created dynamicly. When i close the program ,i need to save the status of the opened frame and open them the next time i start the program.
Is anybody can give me an example?
|
|
|
|
|
If I understood you want to save current status of your program you can save parameters to a file or on the registry and when you want to run your program first you read parameters and set your program to it.
|
|
|
|
|
How can A maximaze a dialog at runtime?
|
|
|
|
|
no need to reask
|
|
|
|
|
Is ShowWindow(SW_*) helpfuls ?
|
|
|
|
|
How can I at runtime maximaze a window?
|
|
|
|
|
use CWnd::ShowWindow(SW_SHOWMAXIMIZED);
|
|
|
|
|
Error on SW_MAXIMIZED way?
|
|
|
|
|
Larsson wrote: Error on SW_MAXIMIZED way?
what error ? i don't even understand your post...
|
|
|
|
|
If I use CWnd::ShowWindow(SW_MAXIMIZED);
I get;
error C2065: 'SW_MAXIMIZED' : undeclared identifier
Do I need to use something else?
|
|
|
|
|
fixed. use SW_SHOWMAXIMIZED instead...
|
|
|
|
|
|
toxcct wrote: use CWnd::ShowWindow(SW_MAXIMIZED);
Perhaps you meant SW_MAXIMIZE or SW_SHOWMAXIMIZED .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
you're right, i typed from my head...
fixed now.
|
|
|
|
|