Example #1
0
// Internal function used to load the jpeg.
ILboolean iLoadJpegInternal()
{
	struct jpeg_error_mgr			Error;
	struct jpeg_decompress_struct	JpegInfo;
	ILboolean						result;

	if ( iCurImage == NULL )
	{
		ilSetError( IL_ILLEGAL_OPERATION );
		return IL_FALSE;
	}

	JpegInfo.err = jpeg_std_error( &Error );		// init standard error handlers
	Error.error_exit = iJpegErrorExit;				// add our exit handler
	Error.output_message = OutputMsg;

	if ( (result = setjmp( JpegJumpBuffer ) == 0) != IL_FALSE )
	{
		jpeg_create_decompress( &JpegInfo );
		JpegInfo.do_block_smoothing = IL_TRUE;
		JpegInfo.do_fancy_upsampling = IL_TRUE;

		//jpeg_stdio_src(&JpegInfo, iGetFile());
		devil_jpeg_read_init( &JpegInfo );
		jpeg_read_header( &JpegInfo, IL_TRUE );

		result = ilLoadFromJpegStruct( &JpegInfo );

		jpeg_finish_decompress( &JpegInfo );
		jpeg_destroy_decompress( &JpegInfo );
	}
	return result;
}
Example #2
0
// Internal function used to load the jpeg.
ILboolean __cdecl iLoadJpegInternal(ILimage* image)
{
	struct jpeg_error_mgr			Error;
	struct jpeg_decompress_struct	JpegInfo;
	ILboolean						result;

	if (image == NULL) {
		il2SetError(IL_ILLEGAL_OPERATION);
		return IL_FALSE;
	}

	JpegInfo.err = jpeg_std_error(&Error);		// init standard error iors
	Error.error_exit = iJpegErrorExit;				// add our exit ior
	Error.output_message = OutputMsg;

	if ((result = setjmp(JpegJumpBuffer) == 0) != IL_FALSE) {
		jpeg_create_decompress(&JpegInfo);
		JpegInfo.do_block_smoothing = IL_TRUE;
		JpegInfo.do_fancy_upsampling = IL_TRUE;

		//jpeg_stdio_src(&JpegInfo, iGetFile());

		devil_jpeg_read_init(image, &JpegInfo);
		jpeg_read_header(&JpegInfo, IL_TRUE);

		result = ilLoadFromJpegStruct(image, &JpegInfo);

		jpeg_finish_decompress(&JpegInfo);
		jpeg_destroy_decompress(&JpegInfo);

	}
	else
	{
		jpeg_destroy_decompress(&JpegInfo);
	}

	//return ilFixImage();  // No need to call it again (called first in ilLoadFromJpegStruct).
	return result;
}