Game Development Reference
In-Depth Information
// Step 1: allocate and initialize JPEG decompression object
//We set up the normal JPEG error routines, then override
//error_exit.
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;
// Establish the setjmp return context for my_error_exit to use.
if (setjmp(jerr.setjmp_buffer)) {
// If we get here, the JPEG code has signaled an error.
// We need to clean up the JPEG object, close the input file,
//and return.
TRACE(”CJpeg::Load>> Problem with Jpeg file”);
jpeg_destroy_decompress(&cinfo);
if (infile!=NULL) fclose(infile);
return NULL;
}
// Now we can initialize the JPEG decompression object.
jpeg_create_decompress(&cinfo);
// Step 2: specify data source (eg, a file)
jpeg_stdio_src(&cinfo, infile);
// Step 3: read file parameters with jpeg_read_header()
(void) jpeg_read_header(&cinfo, TRUE);
// We can ignore the return value from jpeg_read_header since
//(a) suspension is not possible with the stdio data source, and
//(b) we passed TRUE to reject a tables-only JPEG file as an error.
// Step 4: set parameters for decompression
// In this example, we don't need to change any of the defaults set by
//jpeg_read_header(), so we do nothing here.
// Step 5: Start decompressor
(void) jpeg_start_decompress(&cinfo);
// We can ignore the return value since suspension is not possible
//with the stdio data source.
Search Nedrilad ::




Custom Search