Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 29, 2001
1 parent 5602937 commit 275f6e2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES
@@ -1,4 +1,8 @@

1.2.2:
Mattias Engdeg�rd - Fri Dec 28 17:54:31 PST 2001
* Worked around exit() in the jpeg image library

1.2.1:
Mattias Engdeg�rd - Tue Nov 20 08:08:53 PST 2001
* Fixed transparency in the GIF loading code
Expand Down
33 changes: 30 additions & 3 deletions IMG_jpg.c
Expand Up @@ -26,6 +26,7 @@

#include <stdio.h>
#include <string.h>
#include <setjmp.h>

#include "SDL_image.h"

Expand Down Expand Up @@ -171,16 +172,42 @@ static void jpeg_SDL_RW_src (j_decompress_ptr cinfo, SDL_RWops *ctx)
src->pub.next_input_byte = NULL; /* until buffer loaded */
}

struct my_error_mgr {
struct jpeg_error_mgr errmgr;
jmp_buf escape;
};

static void my_error_exit(j_common_ptr cinfo)
{
struct my_error_mgr *err = (struct my_error_mgr *)cinfo->err;
longjmp(err->escape, 1);
}

static void output_no_message(j_common_ptr cinfo)
{
/* do nothing */
}

/* Load a JPEG type image from an SDL datasource */
SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
{
struct jpeg_error_mgr errmgr;
struct jpeg_decompress_struct cinfo;
JSAMPROW rowptr[1];
SDL_Surface *surface;
SDL_Surface *volatile surface = NULL;
struct my_error_mgr jerr;

/* Create a decompression structure and load the JPEG header */
cinfo.err = jpeg_std_error(&errmgr);
cinfo.err = jpeg_std_error(&jerr.errmgr);
jerr.errmgr.error_exit = my_error_exit;
jerr.errmgr.output_message = output_no_message;
if(setjmp(jerr.escape)) {
/* If we get here, libjpeg found an error */
jpeg_destroy_decompress(&cinfo);
IMG_SetError("JPEG loading error");
SDL_FreeSurface(surface);
return NULL;
}

jpeg_create_decompress(&cinfo);
jpeg_SDL_RW_src(&cinfo, src);
jpeg_read_header(&cinfo, TRUE);
Expand Down
6 changes: 3 additions & 3 deletions configure.in
Expand Up @@ -13,9 +13,9 @@ dnl Set various version strings - taken gratefully from the GTk sources

MAJOR_VERSION=1
MINOR_VERSION=2
MICRO_VERSION=1
INTERFACE_AGE=0
BINARY_AGE=1
MICRO_VERSION=2
INTERFACE_AGE=1
BINARY_AGE=2
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION

AC_SUBST(MAJOR_VERSION)
Expand Down

0 comments on commit 275f6e2

Please sign in to comment.