本文整理汇总了C++中gdiplus::Bitmap::GetThumbnailImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::GetThumbnailImage方法的具体用法?C++ Bitmap::GetThumbnailImage怎么用?C++ Bitmap::GetThumbnailImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Bitmap
的用法示例。
在下文中一共展示了Bitmap::GetThumbnailImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateThumbnail
BOOL GdiplusUtilities::CreateThumbnail(LPCTSTR srcFile, LPCTSTR thumbnailFile, ImageFormatEnum imageFormat, INT cx, INT cy)
{
Gdiplus::Bitmap* pSrcImage = Gdiplus::Bitmap::FromFile(srcFile, FALSE);
if (pSrcImage == NULL)
return FALSE;
//=== Default function...stretches the image
Gdiplus::Image* pDestImage = pSrcImage->GetThumbnailImage(cx, cy);
delete pSrcImage;
CLSID pngClsid;
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytes
Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL;
Gdiplus::GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // Failure
pImageCodecInfo = (Gdiplus::ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure
GetImageEncoders(num, size, pImageCodecInfo);
for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, _T("image/png")) == 0 )
{
pngClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
Gdiplus::Status st = pDestImage->Save(thumbnailFile, &pngClsid, NULL);
return st == Gdiplus::Ok;
}
}
free(pImageCodecInfo);
return FALSE;
}