Added RGB565 JPEG image patch by Kurosu

This commit is contained in:
pelya
2011-02-07 11:18:33 +00:00
parent 72d436d8eb
commit 125d3a1df6
3 changed files with 14 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ LOCAL_SRC_FILES += jidctint.c jidctfst.S
endif
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_CFLAGS += -DAVOID_TABLES
LOCAL_CFLAGS += -DAVOID_TABLES -DANDROID_RGB
LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays
LOCAL_MODULE:= jpeg

View File

@@ -6,6 +6,7 @@ LOCAL_MODULE := sdl_image
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/../jpeg/include $(LOCAL_PATH)/../png/include $(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include $(LOCAL_PATH)/include
LOCAL_CFLAGS := -O3 -DLOAD_PNG -DLOAD_JPG -DLOAD_GIF -DLOAD_BMP
# Add -DANDROID_RGB to LOCAL_CFLAGS to make SDL_image output JPEG in native RGB565 format
LOCAL_CPP_EXTENSION := .cpp

View File

@@ -420,7 +420,13 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
#endif
} else {
/* Set 24-bit RGB output */
#ifdef ANDROID_RGB
const SDL_PixelFormat *fmt = SDL_GetVideoInfo()->vfmt;
cinfo.out_color_space = (fmt->BitsPerPixel==16) ? JCS_RGB_565 : JCS_RGB;
#else
cinfo.out_color_space = JCS_RGB;
#endif
cinfo.quantize_colors = FALSE;
#ifdef FAST_JPEG
cinfo.scale_num = 1;
@@ -431,6 +437,11 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
lib.jpeg_calc_output_dimensions(&cinfo);
/* Allocate an output surface to hold the image */
#ifdef ANDROID_RGB
surface = SDL_AllocSurface(SDL_SWSURFACE, cinfo.output_width, cinfo.output_height,
(fmt->BitsPerPixel==16) ? 16 : 24,
fmt->Rmask, fmt->Gmask, fmt->Bmask, 0);
#else
surface = SDL_AllocSurface(SDL_SWSURFACE,
cinfo.output_width, cinfo.output_height, 24,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
@@ -439,6 +450,7 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
0xFF0000, 0x00FF00, 0x0000FF,
#endif
0);
#endif
}
if ( surface == NULL ) {