本文整理汇总了C++中imf::Header::setPreviewImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Header::setPreviewImage方法的具体用法?C++ Header::setPreviewImage怎么用?C++ Header::setPreviewImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imf::Header
的用法示例。
在下文中一共展示了Header::setPreviewImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preview
/**
Set the preview image using the dib embedded thumbnail
*/
static BOOL
SetPreviewImage(FIBITMAP *dib, Imf::Header& header) {
if(!FreeImage_GetThumbnail(dib)) {
return FALSE;
}
FIBITMAP* thumbnail = FreeImage_GetThumbnail(dib);
if((FreeImage_GetImageType(thumbnail) != FIT_BITMAP) || (FreeImage_GetBPP(thumbnail) != 32)) {
// invalid thumbnail - ignore it
FreeImage_OutputMessageProc(s_format_id, FI_MSG_WARNING_INVALID_THUMBNAIL);
} else {
const unsigned thWidth = FreeImage_GetWidth(thumbnail);
const unsigned thHeight = FreeImage_GetHeight(thumbnail);
Imf::PreviewImage preview(thWidth, thHeight);
// copy thumbnail to 32-bit RGBA preview image
const BYTE* src_line = FreeImage_GetScanLine(thumbnail, thHeight - 1);
Imf::PreviewRgba* dst_line = preview.pixels();
const unsigned srcPitch = FreeImage_GetPitch(thumbnail);
for (unsigned y = 0; y < thHeight; y++) {
const RGBQUAD* src_pixel = (RGBQUAD*)src_line;
Imf::PreviewRgba* dst_pixel = dst_line;
for(unsigned x = 0; x < thWidth; x++) {
dst_pixel->r = src_pixel->rgbRed;
dst_pixel->g = src_pixel->rgbGreen;
dst_pixel->b = src_pixel->rgbBlue;
dst_pixel->a = src_pixel->rgbReserved;
src_pixel++;
dst_pixel++;
}
src_line -= srcPitch;
dst_line += thWidth;
}
header.setPreviewImage(preview);
}
return TRUE;
}