From 4e04588d2dcf311c6184c81f4f7072eb4ec7e3e3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 08:23:49 +0200 Subject: [PATCH] Create rarch_main_data_image_iterate --- tasks/task_image.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index c13ccda678..9ca18a88ff 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -108,25 +108,38 @@ static int cb_nbio_default(void *data, size_t len) return 0; } +static int rarch_main_data_image_iterate( + nbio_handle_t *nbio, + unsigned *width, + unsigned *height, + int *retval) +{ +#ifdef HAVE_RPNG + *retval = rpng_nbio_load_image_argb_process( + (rpng_t*)nbio->image.handle, + &nbio->image.ti.pixels, + width, height); +#endif + + nbio->image.ti.width = *width; + nbio->image.ti.height = *height; + + return *retval; +} + #ifdef HAVE_RPNG static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) { + int retval = 0; unsigned width = 0, height = 0; - int retval; if (!nbio) return -1; if (!rpng_is_valid((rpng_t*)nbio->image.handle)) return -1; - retval = rpng_nbio_load_image_argb_process( - (rpng_t*)nbio->image.handle, - &nbio->image.ti.pixels, &width, &height); - - nbio->image.ti.width = width; - nbio->image.ti.height = height; - - switch (retval) + switch (rarch_main_data_image_iterate(nbio, + &width, &height, &retval)) { case IMAGE_PROCESS_ERROR: case IMAGE_PROCESS_ERROR_END: @@ -189,6 +202,7 @@ error: return -1; } + static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) { unsigned i, width = 0, height = 0; @@ -199,16 +213,8 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.processing_pos_increment; i++) { - /* TODO/FIXME -add JPEG equivalents as well */ - retval = rpng_nbio_load_image_argb_process( - (rpng_t*)nbio->image.handle, - &nbio->image.ti.pixels, - &width, &height); - - nbio->image.ti.width = width; - nbio->image.ti.height = height; - - if (retval != IMAGE_PROCESS_NEXT) + if (rarch_main_data_image_iterate(nbio, + &width, &height, &retval) != IMAGE_PROCESS_NEXT) break; }