diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 1d7499d158..95cc9791eb 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -26,9 +26,6 @@ #include #include #include -#ifdef HAVE_RTGA -#include -#endif #include "../general.h" @@ -178,10 +175,16 @@ static bool video_texture_image_load_internal( #endif case IMAGE_TYPE_BMP: break; + case IMAGE_TYPE_TGA: +#ifdef HAVE_RTGA + break; +#else + return false; +#endif default: break; } - + img = image_transfer_new(type); if (!img) @@ -261,8 +264,10 @@ static enum image_type_enum video_texture_image_convert_fmt_to_type(enum video_i return IMAGE_TYPE_JPEG; case IMAGE_FORMAT_BMP: return IMAGE_TYPE_BMP; - default: + case IMAGE_FORMAT_TGA: + return IMAGE_TYPE_TGA; case IMAGE_FORMAT_NONE: + default: break; } @@ -281,46 +286,25 @@ bool video_texture_image_load(struct texture_image *out_img, video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift, &a_shift); - switch (fmt) + if (fmt != IMAGE_FORMAT_NONE) { - case IMAGE_FORMAT_NONE: - break; - default: - handle = (struct nbio_t*)nbio_open(path, NBIO_READ); - if (!handle) - goto error; - nbio_begin_read(handle); + handle = (struct nbio_t*)nbio_open(path, NBIO_READ); + if (!handle) + goto error; + nbio_begin_read(handle); - while (!nbio_iterate(handle)); + while (!nbio_iterate(handle)); - ptr = nbio_get_ptr(handle, &file_len); + ptr = nbio_get_ptr(handle, &file_len); - if (!ptr) - goto error; - break; - } + if (!ptr) + goto error; - switch (fmt) - { - case IMAGE_FORMAT_TGA: -#ifdef HAVE_RTGA - if (rtga_image_load_shift((uint8_t*)ptr, out_img, - a_shift, r_shift, g_shift, b_shift)) - goto success; -#endif - break; - case IMAGE_FORMAT_BMP: - case IMAGE_FORMAT_PNG: - case IMAGE_FORMAT_JPEG: - if (video_texture_image_load_internal( - video_texture_image_convert_fmt_to_type(fmt), - ptr,out_img, - a_shift, r_shift, g_shift, b_shift)) - goto success; - break; - default: - case IMAGE_FORMAT_NONE: - break; + if (video_texture_image_load_internal( + video_texture_image_convert_fmt_to_type(fmt), + ptr,out_img, + a_shift, r_shift, g_shift, b_shift)) + goto success; } error: diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c index 35acca23fa..360bb469df 100644 --- a/libretro-common/formats/image_transfer.c +++ b/libretro-common/formats/image_transfer.c @@ -8,6 +8,9 @@ #ifdef HAVE_RJPEG #include #endif +#ifdef HAVE_RTGA +#include +#endif #include #include @@ -16,6 +19,11 @@ void image_transfer_free(void *data, enum image_type_enum type) { switch (type) { + case IMAGE_TYPE_TGA: +#ifdef HAVE_RTGA + rtga_free((rtga_t*)data); +#endif + break; case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG rpng_free((rpng_t*)data); @@ -75,6 +83,11 @@ bool image_transfer_start(void *data, enum image_type_enum type) case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG return true; +#endif + break; + case IMAGE_TYPE_TGA: +#ifdef HAVE_RTGA + return true; #endif break; case IMAGE_TYPE_BMP: @@ -103,6 +116,12 @@ bool image_transfer_is_valid( return true; #else break; +#endif + case IMAGE_TYPE_TGA: +#ifdef HAVE_RTGA + return true; +#else + break; #endif case IMAGE_TYPE_BMP: return true; @@ -128,6 +147,11 @@ void image_transfer_set_buffer_ptr( case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG rjpeg_set_buf_ptr((rjpeg_t*)data, (uint8_t*)ptr); +#endif + break; + case IMAGE_TYPE_TGA: +#ifdef HAVE_RTGA + rtga_set_buf_ptr((rtga_t*)data, (uint8_t*)ptr); #endif break; case IMAGE_TYPE_BMP: @@ -163,6 +187,13 @@ int image_transfer_process( (void**)buf, len, width, height); #else break; +#endif + case IMAGE_TYPE_TGA: +#ifdef HAVE_RTGA + return rtga_process_image((rtga_t*)data, + (void**)buf, len, width, height); +#else + break; #endif case IMAGE_TYPE_BMP: return rbmp_process_image((rbmp_t*)data, @@ -190,6 +221,12 @@ bool image_transfer_iterate(void *data, enum image_type_enum type) return false; #else break; +#endif + case IMAGE_TYPE_TGA: +#ifdef HAVE_RTGA + return false; +#else + break; #endif case IMAGE_TYPE_BMP: return false; diff --git a/libretro-common/formats/tga/rtga.c b/libretro-common/formats/tga/rtga.c index e1c1535063..7699065991 100644 --- a/libretro-common/formats/tga/rtga.c +++ b/libretro-common/formats/tga/rtga.c @@ -1,103 +1,480 @@ -/* Copyright (C) 2010-2016 The RetroArch team - * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (rtga.c). - * --------------------------------------------------------------------------------------- - * - * Permission is hereby granted, free of charge, - * to any person obtaining a copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - #include #include +#include +#include /* ptrdiff_t on osx */ #include #include -#include +#include +#include + #include +#include -bool rtga_image_load_shift(uint8_t *buf, - void *data, - unsigned a_shift, unsigned r_shift, - unsigned g_shift, unsigned b_shift) +struct rtga { - unsigned i, bits, size, bits_mul; - uint8_t info[6] = {0}; - unsigned width = 0; - unsigned height = 0; - const uint8_t *tmp = NULL; - struct texture_image *out_img = (struct texture_image*)data; + uint8_t *buff_data; + uint32_t *output_image; + void *empty; +}; - if (!buf || buf[2] != 2) +typedef struct +{ + int (*read) (void *user,char *data,int size); /* fill 'data' with 'size' bytes. return number of bytes actually read */ + void (*skip) (void *user,int n); /* skip the next 'n' bytes, or 'unget' the last -n bytes if negative */ + int (*eof) (void *user); /* returns nonzero if we are at end of file/data */ +} rtga_io_callbacks; + +typedef struct +{ + uint32_t img_x, img_y; + int img_n, img_out_n; + + rtga_io_callbacks io; + void *io_user_data; + + int read_from_callbacks; + int buflen; + uint8_t buffer_start[128]; + + uint8_t *img_buffer, *img_buffer_end; + uint8_t *img_buffer_original; +} rtga__context; + +static void rtga__refill_buffer(rtga__context *s); + +static void rtga__start_mem(rtga__context *s, uint8_t const *buffer, int len) +{ + s->io.read = NULL; + s->read_from_callbacks = 0; + s->img_buffer = s->img_buffer_original = (uint8_t *) buffer; + s->img_buffer_end = (uint8_t *) buffer+len; +} + +static uint8_t *rtga__tga_load(rtga__context *s, unsigned *x, unsigned *y, int *comp, int req_comp); + +#define rtga__err(x,y) 0 +#define rtga__errpf(x,y) ((float *) (rtga__err(x,y)?NULL:NULL)) +#define rtga__errpuc(x,y) ((unsigned char *) (rtga__err(x,y)?NULL:NULL)) + +static uint8_t *rtga_load_from_memory(uint8_t const *buffer, int len, unsigned *x, unsigned *y, int *comp, int req_comp) +{ + rtga__context s; + rtga__start_mem(&s,buffer,len); + return rtga__tga_load(&s,x,y,comp,req_comp); +} + +static void rtga__refill_buffer(rtga__context *s) +{ + int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); + if (n == 0) { - fprintf(stderr, "TGA image is not uncompressed RGB.\n"); - goto error; + /* at end of file, treat same as if from memory, but need to handle case + * where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file */ + s->read_from_callbacks = 0; + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start+1; + *s->img_buffer = 0; + } else { + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + n; + } +} + +static INLINE uint8_t rtga__get8(rtga__context *s) +{ + if (s->img_buffer < s->img_buffer_end) + return *s->img_buffer++; + if (s->read_from_callbacks) { + rtga__refill_buffer(s); + return *s->img_buffer++; + } + return 0; +} + +static void rtga__skip(rtga__context *s, int n) +{ + if (n < 0) { + s->img_buffer = s->img_buffer_end; + return; + } + if (s->io.read) { + int blen = (int) (s->img_buffer_end - s->img_buffer); + if (blen < n) { + s->img_buffer = s->img_buffer_end; + (s->io.skip)(s->io_user_data, n - blen); + return; + } + } + s->img_buffer += n; +} + +static int rtga__getn(rtga__context *s, uint8_t *buffer, int n) +{ + if (s->io.read) { + int blen = (int) (s->img_buffer_end - s->img_buffer); + if (blen < n) { + int res, count; + + memcpy(buffer, s->img_buffer, blen); + + count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); + res = (count == (n-blen)); + s->img_buffer = s->img_buffer_end; + return res; + } } - memcpy(info, buf + 12, 6); + if (s->img_buffer+n <= s->img_buffer_end) { + memcpy(buffer, s->img_buffer, n); + s->img_buffer += n; + return 1; + } else + return 0; +} - width = info[0] + ((unsigned)info[1] * 256); - height = info[2] + ((unsigned)info[3] * 256); - bits = info[4]; +static int rtga__get16le(rtga__context *s) +{ + int z = rtga__get8(s); + return z + (rtga__get8(s) << 8); +} - fprintf(stderr, "Loaded TGA: (%ux%u @ %u bpp)\n", width, height, bits); +static uint8_t rtga__compute_y(int r, int g, int b) +{ + return (uint8_t) (((r*77) + (g*150) + (29*b)) >> 8); +} - size = width * height * sizeof(uint32_t); - out_img->pixels = (uint32_t*)malloc(size); - out_img->width = width; - out_img->height = height; +static unsigned char *rtga__convert_format( + unsigned char *data, + int img_n, + int req_comp, + unsigned int x, + unsigned int y) +{ + int i,j; + unsigned char *good; - if (!out_img->pixels) + if (req_comp == img_n) return data; + retro_assert(req_comp >= 1 && req_comp <= 4); + + good = (unsigned char *) malloc(req_comp * x * y); + if (good == NULL) { - fprintf(stderr, "Failed to allocate TGA pixels.\n"); - goto error; + free(data); + return rtga__errpuc("outofmem", "Out of memory"); } - tmp = buf + 18; - bits_mul = 3; - - if (bits != 32 && bits != 24) + for (j=0; j < (int) y; ++j) { - fprintf(stderr, "Bit depth of TGA image is wrong. Only 32-bit and 24-bit supported.\n"); - goto error; + unsigned char *src = data + j * x * img_n ; + unsigned char *dest = good + j * x * req_comp; + + switch (((img_n)*8+(req_comp))) + { + case ((1)*8+(2)): + for(i=x-1; i >= 0; --i, src += 1, dest += 2) + dest[0]=src[0], dest[1]=255; + break; + case ((1)*8+(3)): + for(i=x-1; i >= 0; --i, src += 1, dest += 3) + dest[0]=dest[1]=dest[2]=src[0]; + break; + case ((1)*8+(4)): + for(i=x-1; i >= 0; --i, src += 1, dest += 4) + dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; + break; + case ((2)*8+(1)): + for(i=x-1; i >= 0; --i, src += 2, dest += 1) + dest[0]=src[0]; + break; + case ((2)*8+(3)): + for(i=x-1; i >= 0; --i, src += 2, dest += 3) + dest[0]=dest[1]=dest[2]=src[0]; + break; + case ((2)*8+(4)): + for(i=x-1; i >= 0; --i, src += 2, dest += 4) + dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; + break; + case ((3)*8+(4)): + for(i=x-1; i >= 0; --i, src += 3, dest += 4) + dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; + break; + case ((3)*8+(1)): + for(i=x-1; i >= 0; --i, src += 3, dest += 1) + dest[0]=rtga__compute_y(src[0],src[1],src[2]); + break; + case ((3)*8+(2)): + for(i=x-1; i >= 0; --i, src += 3, dest += 2) + dest[0]=rtga__compute_y(src[0],src[1],src[2]), dest[1] = 255; + break; + case ((4)*8+(1)): + for(i=x-1; i >= 0; --i, src += 4, dest += 1) + dest[0]=rtga__compute_y(src[0],src[1],src[2]); + break; + case ((4)*8+(2)): + for(i=x-1; i >= 0; --i, src += 4, dest += 2) + dest[0]=rtga__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; + break; + case ((4)*8+(3)): + for(i=x-1; i >= 0; --i, src += 4, dest += 3) + dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; + break; + default: + retro_assert(0); + break; + } + } - if (bits == 32) - bits_mul = 4; + free(data); + return good; +} - for (i = 0; i < width * height; i++) +static uint8_t *rtga__tga_load(rtga__context *s, unsigned *x, unsigned *y, int *comp, int req_comp) +{ + /* Read in the TGA header stuff */ + int tga_offset = rtga__get8(s); + int tga_indexed = rtga__get8(s); + int tga_image_type = rtga__get8(s); + int tga_is_RLE = 0; + int tga_palette_start = rtga__get16le(s); + int tga_palette_len = rtga__get16le(s); + int tga_palette_bits = rtga__get8(s); + int tga_x_origin = rtga__get16le(s); + int tga_y_origin = rtga__get16le(s); + int tga_width = rtga__get16le(s); + int tga_height = rtga__get16le(s); + int tga_bits_per_pixel = rtga__get8(s); + int tga_comp = tga_bits_per_pixel / 8; + int tga_inverted = rtga__get8(s); + + /* image data */ + unsigned char *tga_data; + unsigned char *tga_palette = NULL; + int i, j; + unsigned char raw_data[4] = {0}; + int RLE_count = 0; + int RLE_repeating = 0; + int read_next_pixel = 1; + + /* do a tiny bit of precessing */ + if ( tga_image_type >= 8 ) { - uint32_t b = tmp[i * bits_mul + 0]; - uint32_t g = tmp[i * bits_mul + 1]; - uint32_t r = tmp[i * bits_mul + 2]; - uint32_t a = tmp[i * bits_mul + 3]; - - if (bits == 24) - a = 0xff; - - out_img->pixels[i] = (a << a_shift) | - (r << r_shift) | (g << g_shift) | (b << b_shift); + tga_image_type -= 8; + tga_is_RLE = 1; } + /* int tga_alpha_bits = tga_inverted & 15; */ + tga_inverted = 1 - ((tga_inverted >> 5) & 1); + + /* error check */ + if ( + (tga_width < 1) || (tga_height < 1) || + (tga_image_type < 1) || (tga_image_type > 3) || + ((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16) && + (tga_bits_per_pixel != 24) && (tga_bits_per_pixel != 32)) + ) + return NULL; /* we don't report this as a bad TGA because we don't even know if it's TGA */ + + /* If paletted, then we will use the number of bits from the palette */ + if ( tga_indexed ) + tga_comp = tga_palette_bits / 8; + + /* TGA info */ + *x = tga_width; + *y = tga_height; + if (comp) *comp = tga_comp; + + tga_data = (unsigned char*)malloc( (size_t)tga_width * tga_height * tga_comp ); + if (!tga_data) + return rtga__errpuc("outofmem", "Out of memory"); + + /* skip to the data's starting position (offset usually = 0) */ + rtga__skip(s, tga_offset ); + + if ( !tga_indexed && !tga_is_RLE) + { + for (i=0; i < tga_height; ++i) + { + int y = tga_inverted ? tga_height -i - 1 : i; + uint8_t *tga_row = tga_data + y*tga_width*tga_comp; + rtga__getn(s, tga_row, tga_width * tga_comp); + } + } + else + { + /* Do I need to load a palette? */ + if ( tga_indexed) + { + /* any data to skip? (offset usually = 0) */ + rtga__skip(s, tga_palette_start ); + /* load the palette */ + tga_palette = (unsigned char*)malloc( tga_palette_len * tga_palette_bits / 8 ); + + if (!tga_palette) + { + free(tga_data); + return rtga__errpuc("outofmem", "Out of memory"); + } + if (!rtga__getn(s, tga_palette, tga_palette_len * tga_palette_bits / 8 )) { + free(tga_data); + free(tga_palette); + return rtga__errpuc("bad palette", "Corrupt TGA"); + } + } + + /* load the data */ + for (i=0; i < tga_width * tga_height; ++i) + { + /* if I'm in RLE mode, do I need to get a RLE rtga__pngchunk? */ + if ( tga_is_RLE ) + { + if ( RLE_count == 0 ) + { + /* yep, get the next byte as a RLE command */ + int RLE_cmd = rtga__get8(s); + RLE_count = 1 + (RLE_cmd & 127); + RLE_repeating = RLE_cmd >> 7; + read_next_pixel = 1; + } + else if ( !RLE_repeating ) + read_next_pixel = 1; + } + else + read_next_pixel = 1; + + /* OK, if I need to read a pixel, do it now */ + if ( read_next_pixel ) + { + /* load however much data we did have */ + if ( tga_indexed ) + { + /* read in 1 byte, then perform the lookup */ + int pal_idx = rtga__get8(s); + if ( pal_idx >= tga_palette_len ) /* invalid index */ + pal_idx = 0; + pal_idx *= tga_bits_per_pixel / 8; + for (j = 0; j*8 < tga_bits_per_pixel; ++j) + raw_data[j] = tga_palette[pal_idx+j]; + } + else + { + /* read in the data raw */ + for (j = 0; j*8 < tga_bits_per_pixel; ++j) + raw_data[j] = rtga__get8(s); + } + + /* clear the reading flag for the next pixel */ + read_next_pixel = 0; + } /* end of reading a pixel */ + + /* copy data */ + for (j = 0; j < tga_comp; ++j) + tga_data[i*tga_comp+j] = raw_data[j]; + + /* in case we're in RLE mode, keep counting down */ + --RLE_count; + } + + /* do I need to invert the image? */ + if ( tga_inverted ) + { + for (j = 0; j*2 < tga_height; ++j) + { + int index1 = j * tga_width * tga_comp; + int index2 = (tga_height - 1 - j) * tga_width * tga_comp; + for (i = tga_width * tga_comp; i > 0; --i) + { + unsigned char temp = tga_data[index1]; + tga_data[index1] = tga_data[index2]; + tga_data[index2] = temp; + ++index1; + ++index2; + } + } + } + + /* Clear my palette, if I had one */ + if ( tga_palette != NULL ) + free( tga_palette ); + } + + /* swap RGB */ + if (tga_comp >= 3) + { + unsigned char* tga_pixel = tga_data; + + for (i=0; i < tga_width * tga_height; ++i) + { + unsigned char temp = tga_pixel[0]; + tga_pixel[0] = tga_pixel[2]; + tga_pixel[2] = temp; + tga_pixel += tga_comp; + } + } + + /* convert to target component count */ + if (req_comp && req_comp != tga_comp) + tga_data = rtga__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); + + tga_palette_start = tga_palette_len = tga_palette_bits = + tga_x_origin = tga_y_origin = 0; + + return tga_data; +} + +int rtga_process_image(rtga_t *rtga, void **buf_data, + size_t size, unsigned *width, unsigned *height) +{ + int comp; + unsigned size_tex = 0; + + if (!rtga) + return IMAGE_PROCESS_ERROR; + + rtga->output_image = (uint32_t*)rtga_load_from_memory(rtga->buff_data, size, width, height, &comp, 4); + *buf_data = rtga->output_image; + size_tex = (*width) * (*height); + + printf("GETS HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); +#if 0 + /* Convert RGBA to ARGB */ + do + { + unsigned int texel = rtga->output_image[size_tex]; + unsigned int A = texel & 0xFF000000; + unsigned int B = texel & 0x00FF0000; + unsigned int G = texel & 0x0000FF00; + unsigned int R = texel & 0x000000FF; + ((unsigned int*)rtga->output_image)[size_tex] = A | (R << 16) | G | (B >> 16); + }while(size_tex--); +#endif + + return IMAGE_PROCESS_END; +} + +bool rtga_set_buf_ptr(rtga_t *rtga, void *data) +{ + if (!rtga) + return false; + + rtga->buff_data = (uint8_t*)data; + return true; - -error: - if (out_img->pixels) - free(out_img->pixels); - - out_img->pixels = NULL; - out_img->width = out_img->height = 0; - return false; +} + +void rtga_free(rtga_t *rtga) +{ + if (!rtga) + return; + + free(rtga); +} + +rtga_t *rtga_alloc(void) +{ + rtga_t *rtga = (rtga_t*)calloc(1, sizeof(*rtga)); + if (!rtga) + return NULL; + return rtga; } diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index b54c72a96c..437af0a373 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -45,7 +45,8 @@ enum image_type_enum IMAGE_TYPE_NONE = 0, IMAGE_TYPE_PNG, IMAGE_TYPE_JPEG, - IMAGE_TYPE_BMP + IMAGE_TYPE_BMP, + IMAGE_TYPE_TGA }; bool video_texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift, diff --git a/libretro-common/include/formats/tga.h b/libretro-common/include/formats/rtga.h similarity index 87% rename from libretro-common/include/formats/tga.h rename to libretro-common/include/formats/rtga.h index 09e813424a..74dda5a0ad 100644 --- a/libretro-common/include/formats/tga.h +++ b/libretro-common/include/formats/rtga.h @@ -36,12 +36,17 @@ RETRO_BEGIN_DECLS -bool rtga_image_load_shift(uint8_t *buf, - void *data, - unsigned a_shift, unsigned r_shift, - unsigned g_shift, unsigned b_shift); +typedef struct rtga rtga_t; + +int rtga_process_image(rtga_t *rtga, void **buf, + size_t size, unsigned *width, unsigned *height); + +bool rtga_set_buf_ptr(rtga_t *rtga, void *data); + +void rtga_free(rtga_t *rtga); + +rtga_t *rtga_alloc(void); RETRO_END_DECLS #endif - diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 7712bfce44..08cad10c23 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4011,7 +4011,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) break; case DISPLAYLIST_IMAGES: info->type_default = MENU_FILE_IMAGE; - strlcpy(info->exts, "png|jpg|jpeg|bmp", sizeof(info->exts)); + strlcpy(info->exts, "png|jpg|jpeg|bmp|tga", sizeof(info->exts)); break; case DISPLAYLIST_AUDIO_FILTERS: info->type_default = MENU_FILE_AUDIOFILTER; diff --git a/tasks/task_image.c b/tasks/task_image.c index 196615e227..0f7f4ebc63 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -117,6 +117,7 @@ static int task_image_process( unsigned *height) { nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->image; + int retval = image_transfer_process( image->handle, nbio->image_type, @@ -366,6 +367,8 @@ bool rarch_task_push_image_load(const char *fullpath, nbio->image_type = IMAGE_TYPE_JPEG; else if (strstr(fullpath, ".bmp")) nbio->image_type = IMAGE_TYPE_BMP; + else if (strstr(fullpath, ".tga")) + nbio->image_type = IMAGE_TYPE_TGA; switch (cb_type_hash) {