本文整理汇总了C++中Image::CreatePart方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::CreatePart方法的具体用法?C++ Image::CreatePart怎么用?C++ Image::CreatePart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::CreatePart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadParams
bool ImageLoaderJPG::LoadParams(Image &cImage, File &cFile, bool bBlockSmoothing, bool bFancyUpsampling)
{
jpeg_decompress_struct sInfo;
jpeg_error_mgr sError;
sInfo.err = jpeg_std_error(&sError);
sInfo.err->error_exit = ExitErrorHandle;
jpeg_create_decompress(&sInfo);
// Set the user given parameters
sInfo.do_block_smoothing = bBlockSmoothing;
sInfo.do_fancy_upsampling = bFancyUpsampling;
jpeg_read_init(&sInfo, &cFile);
jpeg_read_header(&sInfo, TRUE);
jpeg_start_decompress(&sInfo);
// Get the color format
EColorFormat nColorFormat;
switch (sInfo.num_components) {
case 1:
nColorFormat = ColorGrayscale;
break;
case 3:
nColorFormat = ColorRGB;
break;
case 4:
nColorFormat = ColorRGBA;
break;
default:
// Error: Unsupported color format
return false;
}
// Create image buffer
ImageBuffer *pImageBuffer = cImage.CreatePart()->CreateMipmap();
pImageBuffer->CreateImage(DataByte, nColorFormat, Vector3i(sInfo.output_width, sInfo.output_height, 1));
// Read in the data
uint8 *pCurrentData = pImageBuffer->GetData();
while (sInfo.output_scanline < sInfo.output_height) {
jpeg_read_scanlines(&sInfo, &pCurrentData, 1);
pCurrentData += pImageBuffer->GetBytesPerRow();
}
// Cleanup
jpeg_finish_decompress(&sInfo);
jpeg_destroy_decompress(&sInfo);
// Done
return true;
}