本文整理汇总了C++中Canvas::GetPixelByteSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Canvas::GetPixelByteSize方法的具体用法?C++ Canvas::GetPixelByteSize怎么用?C++ Canvas::GetPixelByteSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas::GetPixelByteSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadJpeg
TEXLoader::IoStatus TEXLoader::ReadJpeg(Canvas& canvas) {
unsigned size;
load_file_->Read(size);
jpeg_decompress_struct _c_info;
jpeg_error_mgr j_err;
_c_info.err = jpeg_std_error(&j_err);
jpeg_create_decompress(&_c_info);
InitSourceManager(&_c_info);
if (jpeg_read_header(&_c_info, TRUE) != JPEG_HEADER_OK) {
jpeg_destroy_decompress(&_c_info);
return kStatusReadHeaderError;
}
if (jpeg_start_decompress(&_c_info) != TRUE) {
jpeg_destroy_decompress(&_c_info);
return kStatusReadPictureError;
}
if (_c_info.output_components == 1) {
// Create grayscale palette.
Color palette[256];
for (int i = 0; i < 256; i++) {
palette[i].Set(i, i, i, i);
}
canvas.SetPalette(palette);
}
uint8* buffer = (uint8*)canvas.GetBuffer();
int row_stride = canvas.GetPitch() * canvas.GetPixelByteSize();
int scan_lines = canvas.GetHeight();
JSAMPROW offset[1];
offset[0] = buffer;
for (int i = 0; i < scan_lines; i++) {
jpeg_read_scanlines(&_c_info, offset, 1);
offset[0] += row_stride;
}
jpeg_finish_decompress(&_c_info);
jpeg_destroy_decompress(&_c_info);
load_file_->SeekCur(size);
return kStatusSuccess;
}