From 09aac8a320dd8ffc6df00eef09e21b3e21d33f6d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 1 Sep 2015 12:39:17 +0200 Subject: [PATCH] Create rpng_nbio_is_valid --- libretro-common/formats/png/rpng_nbio.c | 11 +++++++++++ libretro-common/include/formats/rpng.h | 2 ++ tasks/task_file_transfer.c | 4 +--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/libretro-common/formats/png/rpng_nbio.c b/libretro-common/formats/png/rpng_nbio.c index 5ffc56af89..63ed17a89f 100644 --- a/libretro-common/formats/png/rpng_nbio.c +++ b/libretro-common/formats/png/rpng_nbio.c @@ -248,3 +248,14 @@ bool rpng_nbio_load_image_argb_start(struct rpng_t *rpng) return true; } + +bool rpng_nbio_is_valid(struct rpng_t *rpng) +{ + if (rpng->has_ihdr) + return true; + if (rpng->has_idat) + return true; + if (rpng->has_iend) + return true; + return false; +} diff --git a/libretro-common/include/formats/rpng.h b/libretro-common/include/formats/rpng.h index fdd3ca2032..d4d2342e16 100644 --- a/libretro-common/include/formats/rpng.h +++ b/libretro-common/include/formats/rpng.h @@ -105,6 +105,8 @@ bool rpng_load_image_argb(const char *path, uint32_t **data, struct rpng_t *rpng_nbio_load_image_argb_init(const char *path); +bool rpng_nbio_is_valid(struct rpng_t *rpng); + void rpng_nbio_load_image_free(struct rpng_t *rpng); bool rpng_nbio_load_image_argb_iterate(uint8_t *buf, diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index a423677b26..3c83736256 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -185,9 +185,7 @@ static int cb_image_menu_generic(nbio_handle_t *nbio) if (!nbio) return -1; - if ( !nbio->image.handle->has_ihdr || - !nbio->image.handle->has_idat || - !nbio->image.handle->has_iend) + if (!rpng_nbio_is_valid(nbio->image.handle)) return -1; retval = rpng_nbio_load_image_argb_process(nbio->image.handle,