Game Development Reference
In-Depth Information
// We may need to do some setup of our own at this point before
//reading the data. After jpeg_start_decompress() we have the
//correct scaled output image dimensions available, as well as
//the output colormap if we asked for color quantization.
//In this example, we need to make an output work buffer of the right
// get our buffer set to hold data
BYTE *dataBuf;
//DWORD align the storage width
int swidth = (cinfo.output_width * cinfo.output_components + 3) &
// alloc and open our new buffer
dataBuf = new BYTE[swidth * cinfo.output_height];
if (dataBuf==NULL) {
TRACE(”Cjpeg::Load>> Out of memory”);
return NULL;
// how big is this thing gonna be?
width = cinfo.output_width;
height = cinfo.output_height;
//JSAMPLEs per row in output buffer
row_stride = cinfo.output_width * cinfo.output_components;
// Make a one-row-high sample array that will go away when done with
buffer = (*cinfo.mem->alloc_sarray)
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
// Step 6: while (scan lines remain to be read)
// jpeg_read_scanlines(. . .);
// Here we use the library's state variable cinfo.output_scanline
//as the loop counter, so that we don't have to keep
//track ourselves.
Search Nedrilad ::

Custom Search