Click here to Skip to main content
16,006,535 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Answeruse <pre></pre> tags Pin
toxcct14-Nov-06 4:51
toxcct14-Nov-06 4:51 
GeneralRe: use <pre></pre> tags Pin
Max++14-Nov-06 5:36
Max++14-Nov-06 5:36 
GeneralRe: use <pre></pre> tags Pin
toxcct14-Nov-06 5:41
toxcct14-Nov-06 5:41 
GeneralRe: use <pre></pre> tags Pin
Mark Salsbery14-Nov-06 5:52
Mark Salsbery14-Nov-06 5:52 
GeneralRe: use <pre></pre> tags Pin
toxcct14-Nov-06 5:58
toxcct14-Nov-06 5:58 
GeneralRe: use <pre></pre> tags Pin
Hamid_RT14-Nov-06 8:12
Hamid_RT14-Nov-06 8:12 
GeneralRe: use <pre></pre> tags Pin
Hamid_RT14-Nov-06 8:09
Hamid_RT14-Nov-06 8:09 
Questioncopy image file to memory [modified] Pin
_tasleem14-Nov-06 4:47
_tasleem14-Nov-06 4:47 
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

QuestionRe: copy image file to memory Pin
David Crow14-Nov-06 4:54
David Crow14-Nov-06 4:54 
AnswerRe: copy image file to memory Pin
_tasleem14-Nov-06 5:27
_tasleem14-Nov-06 5:27 
AnswerRe: copy image file to memory Pin
David Crow14-Nov-06 5:35
David Crow14-Nov-06 5:35 
GeneralRe: copy image file to memory Pin
_tasleem14-Nov-06 6:37
_tasleem14-Nov-06 6:37 
QuestionRe: copy image file to memory Pin
David Crow14-Nov-06 6:45
David Crow14-Nov-06 6:45 
AnswerRe: copy image file to memory Pin
_tasleem15-Nov-06 2:54
_tasleem15-Nov-06 2:54 
QuestionRe: copy image file to memory Pin
David Crow15-Nov-06 3:18
David Crow15-Nov-06 3:18 
AnswerRe: copy image file to memory Pin
_tasleem15-Nov-06 20:49
_tasleem15-Nov-06 20:49 
QuestionHow to save and resotre the Child Frame? Pin
abuseyoudna198114-Nov-06 4:26
abuseyoudna198114-Nov-06 4:26 
AnswerRe: How to save and resotre the Child Frame? Pin
Hamid_RT15-Nov-06 7:20
Hamid_RT15-Nov-06 7:20 
QuestionMaximaze dialog? Pin
Larsson14-Nov-06 4:21
Larsson14-Nov-06 4:21 
AnswerRe: Maximaze dialog? Pin
toxcct14-Nov-06 4:36
toxcct14-Nov-06 4:36 
AnswerRe: Maximaze dialog? Pin
Hamid_RT14-Nov-06 8:09
Hamid_RT14-Nov-06 8:09 
Questionmaximaze dialog? Pin
Larsson14-Nov-06 4:09
Larsson14-Nov-06 4:09 
AnswerRe: maximaze dialog? [modified] Pin
toxcct14-Nov-06 4:14
toxcct14-Nov-06 4:14 
GeneralRe: maximaze dialog? Pin
Larsson14-Nov-06 4:33
Larsson14-Nov-06 4:33 
GeneralRe: maximaze dialog? Pin
toxcct14-Nov-06 4:36
toxcct14-Nov-06 4:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.