Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
保存CImage时出现错误:identifier";ImageFormatJPEG";是未定义的_Image_Visual Studio 2012_Save_Jpeg_Gdi+ - Fatal编程技术网

保存CImage时出现错误:identifier";ImageFormatJPEG";是未定义的

保存CImage时出现错误:identifier";ImageFormatJPEG";是未定义的,image,visual-studio-2012,save,jpeg,gdi+,Image,Visual Studio 2012,Save,Jpeg,Gdi+,我正在使用Visual Studio 2012。 我尝试使用以下命令将CImage保存为jpg: theImage.Save(filePathAndName, Gdiplus::ImageFormatJPEG); #include <gdiplus.h> char *filePathAndName = "C:\\Projects\\AcesHyAcceptanceTestScreenShot2.jpg"; theImage.Save(filePathAndName); 如所示

我正在使用Visual Studio 2012。 我尝试使用以下命令将CImage保存为jpg:

theImage.Save(filePathAndName, Gdiplus::ImageFormatJPEG);
#include <gdiplus.h>
char *filePathAndName = "C:\\Projects\\AcesHyAcceptanceTestScreenShot2.jpg";
theImage.Save(filePathAndName);
如所示

但是,Visual Studio给出了以下错误:

Error: identifier "ImageFormatJPEG" is undefined
为什么我会犯这个错误

注意,我已包括以下内容:

theImage.Save(filePathAndName, Gdiplus::ImageFormatJPEG);
#include <gdiplus.h>
char *filePathAndName = "C:\\Projects\\AcesHyAcceptanceTestScreenShot2.jpg";
theImage.Save(filePathAndName);
除其他外,包括“GdiplusImaging.h”。GdiplusImaging.h还使用

#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
除其他外,包括

DEFINE_GUID(ImageFormatJPEG, 0xb96b3cae,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e);

我想这可能是造成问题的原因,但我还没有弄清楚。

我无法使用

Gdiplus::ImageFormatJPEG
作为save函数的第二个参数

但是,按照

如果未包含guidFileType参数,则将使用文件名的文件扩展名来确定图像格式

因此,我做了以下工作:

theImage.Save(filePathAndName, Gdiplus::ImageFormatJPEG);
#include <gdiplus.h>
char *filePathAndName = "C:\\Projects\\AcesHyAcceptanceTestScreenShot2.jpg";
theImage.Save(filePathAndName);
将CImage另存为jpeg

如果有人知道修复程序能够使用
Gdiplus::ImageFormatJPEG
请发布解决方案。

包括“”应该适合您