diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index a9e7e934cb..a761387f8c 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -29,6 +29,7 @@ #ifdef HAVE_RPNG #include #endif +#include #include #include "../general.h" @@ -37,7 +38,8 @@ enum video_image_format { IMAGE_FORMAT_NONE = 0, IMAGE_FORMAT_TGA, - IMAGE_FORMAT_PNG + IMAGE_FORMAT_PNG, + IMAGE_FORMAT_JPEG }; bool video_texture_image_set_color_shifts( @@ -225,6 +227,8 @@ static enum video_image_format video_texture_image_get_type(const char *path) return IMAGE_FORMAT_TGA; if (strstr(path, ".png")) return IMAGE_FORMAT_PNG; + if (strstr(path, ".jpg") || strstr(path, ".jpeg")) + return IMAGE_FORMAT_JPEG; return IMAGE_FORMAT_NONE; } @@ -273,6 +277,10 @@ bool video_texture_image_load(struct texture_image *out_img, goto success; #endif break; + case IMAGE_FORMAT_JPEG: + if (rjpeg_image_load(ptr, out_img, file_len)) + goto success; + break; default: case IMAGE_FORMAT_NONE: break; diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 254a27222f..7ee00c5fcf 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -867,4 +867,3 @@ error: rjpeg_free(rjpg); return false; } - diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h new file mode 100644 index 0000000000..4ed6c0a575 --- /dev/null +++ b/libretro-common/include/formats/rjpeg.h @@ -0,0 +1,40 @@ +/* Copyright (C) 2010-2015 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rjpeg.h). + * --------------------------------------------------------------------------------------- + * + * 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. + */ + +#ifndef __LIBRETRO_SDK_FORMAT_RJPEG_H__ +#define __LIBRETRO_SDK_FORMAT_RJPEG_H__ + +#include +#include + +#include + +#include + +RETRO_BEGIN_DECLS + +bool rjpeg_image_load(uint8_t *buf, void *data, size_t size); + +RETRO_END_DECLS + +#endif +