Game Development Reference
In-Depth Information
BYTE *bits;
while (cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, buffer, 1);
//Copy scan line to dataBuf
memcpy(&dataBuf[swidth * cinfo.output_scanline,
buffer, row_stride);
// Step 7: Finish decompression
(void) jpeg_finish_decompress(&cinfo);
// We can ignore the return value since suspension is not possible
//with the stdio data source.
//Step 8: Release JPEG decompression object
//This is an important step since it will release a good deal of
// After finish_decompress, we can close the input file.
//Here we postpone it until after no more JPEG errors are possible,
//so as to simplify the setjmp error logic above.
// At this point you may want to check to see whether any corrupt-data
//warnings occurred (test whether is
return dataBuf;
A Jpeg RGB buffer is not guaranteed to be DWORD aligned, so you
may want to copy each scan line into a DWORD aligned buffer if you are
using the buffer as a Windows bitmap type. Also, the pixel data will not be
provided last scan line first, so another useful utility will be code to flip the
buffer vertically. The final utility that you may use is to flip the red and blue
components, because again Windows stores the data the opposite way
round. All these utility functions are available in the Toon3D source code
and are very easy to write for yourself.
Search Nedrilad ::

Custom Search