Click here to Skip to main content
15,886,061 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
How to open the file using fopen_s to save the image??? Please help me...

for(int c=0;c<10;c++)
	{
		 sprintf_s(buffer,"D:\image%u.jpg",c);
		 CString sName(buffer);  
         LPCTSTR lpszName = sName; 
		 bool ok=CreateFile(lpszName,GENERIC_ALL,FILE_SHARE_WRITE | FILE_SHARE_READ,NULL,CREATE_NEW | OPEN_EXISTING,
			                FILE_ATTRIBUTE_NORMAL,NULL);

         if( (err = fopen_s( &stream2, "data2", "w+" )) != 0 )

		file.Write(&bh, sizeof(BITMAPFILEHEADER));
			file.Write(&(bi.bmiHeader), sizeof(BITMAPINFOHEADER));
			file.Write(lpBitmapBits, 3 * nWidth * nHeight);
			file.Close();
			Sleep(10000);
		}
		
	}
Posted
Comments
walterhevedeich 19-Apr-11 5:49am    
What's the error message you are receiving?
Sergey Alexandrovich Kryukov 19-Apr-11 13:14pm    
Did you remove your Question:
http://www.codeproject.com/Answers/183776/How-to-write-and-call-a-function-in-windows-servic.aspx

...after I answered and added the update. Why?!
--SA
Gokulnath007 20-Apr-11 0:23am    
No. i didnt remove it..

Buddy as per i understand your problem you are trying to copy content of image file to a normal file it is ok to do it...:)

But if you are trying to convert one kind of file to another type then it is not the right way to do so..

Instead you can use GDIPLUS for programmers: GDI+[^]

Hope this may help!!! :)
 
Share this answer
 
You're obviously using MFC. Why don't you go ahead and use the framework's classes?

C++
CBitmap myBmp;
CImage myImg;
myImg.Attach(myBmp);
myImg.Save(_T("my.bmp"));
myImg.Detach();
 
Share this answer
 
Comments
Niklas L 19-Apr-11 7:39am    
I think he's trying to rid himself of MFC as per his other questions.
Gokulnath007 20-Apr-11 0:25am    
I need these codes which is taking the screenshots of the screen to be run as a service so that it can start taking the screen shots once the service is started.. please help me..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900