2014-11-14 77 views
1

我使用Visual Studio 2012 我試圖用一個的CImage保存爲JPG如下:保存的CImage給出了錯誤:標識符「ImageFormatJPEG」未定義

theImage.Save(filePathAndName, Gdiplus::ImageFormatJPEG); 
截至 link to Microsoft example using CImage::Save所示

但是,Visual Studio中給出了錯誤:

Error: identifier "ImageFormatJPEG" is undefined 

爲什麼會出現這個錯誤?

注意,我已經包括以下內容:

#include <gdiplus.h> 

而且,我看着gdiplus.h,看到下面一行:

#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 

封閉,除其他外,#include "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); 

我認爲這可能是造成問題的原因,但我還沒有想通出來呢。

回答

1

我不能直接指定使用

Gdiplus::ImageFormatJPEG 

爲保存功能的第二個參數的圖像格式。

然而,截至Microsoft's CImage::Save

If the guidFileType parameter is not included, the file name's file extension will be used to determine the image format.

指定於是,我做了以下內容:

char *filePathAndName = "C:\\Projects\\AcesHyAcceptanceTestScreenShot2.jpg"; 
theImage.Save(filePathAndName); 

到的CImage保存爲JPEG格式。

如果有人知道的修復程序能夠使用Gdiplus::ImageFormatJPEG請張貼的解決方案。