我在MSDN上将代码编写为指导,但没有用。它无法加载图像并将图像另存为bmp。
#include "stdafx.h"
#include "atlimage.h"
#include "cstdio"
#include "fstream"
int _tmain(int argc, _TCHAR* argv[])
{
CImage m_image1;
CImage m_image2;
char *srcFile = "C:\\Users\\TYZRPVX\\Desktop\\test.jpg";
const char *tarFile = "C:\\Users\\TYZRPVX\\Desktop\\testBmp.bmp";
FILE *tar;
fopen_s(&tar, tarFile, "w");
m_image1.Load((LPCTSTR)(srcFile));
//m_image1.Save(_T("C:\\Users\\TYZRPVX\\Desktop\\testBmp.bmp"));
m_image1.Save(_T("C:\\Users\\TYZRPVX\\Desktop"),Gdiplus::ImageFormatBMP);
return 0;
}
您可能在启用Unicode的情况下进行编译,而Unicode是在Visual Studio中创建新项目时的默认设置。这使您的投射LPCTSTR
不正确。使用宽字符串作为文件名并删除演员表。
const wchar_t *srcFile = L"C:\\Users\\TYZRPVX\\Desktop\\test.jpg";
const wchar_t *bmpFile = L"C:\\Users\\TYZRPVX\\Desktop\\testBmp.bmp";
m_image1.Load(srcFile);
m_image1.Save(bmpFile, Gdiplus::ImageFormatBMP);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句