如何使用fopen_s打开文件以保存图像? [英] How to open the file using fopen_s to save the image?

查看:366
本文介绍了如何使用fopen_s打开文件以保存图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用fopen_s打开文件以保存图像???请帮帮我...

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);
		}
		
	}

推荐答案

好友,据我所知,您正在尝试将图像文件的内容复制到普通文件中,可以这样做...: )

但是,如果您尝试将一种文件转换为另一种类型,那么这样做是不正确的..

相反,您可以对程序员使用GDIPLUS: GDI + [ ^ ]

希望这会有所帮助!!! :)
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!!! :)


您显然正在使用MFC.为什么不继续使用框架的类?

You''re obviously using MFC. Why don''t you go ahead and use the framework''s classes?

CBitmap myBmp;
CImage myImg;
myImg.Attach(myBmp);
myImg.Save(_T("my.bmp"));
myImg.Detach();


这篇关于如何使用fopen_s打开文件以保存图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆