diff --git a/libretro-common/formats/png/Makefile b/libretro-common/formats/png/Makefile index b757cf4da2..ea84697cb4 100644 --- a/libretro-common/formats/png/Makefile +++ b/libretro-common/formats/png/Makefile @@ -8,7 +8,7 @@ CFLAGS += -DHAVE_IMLIB2 LDFLAGS += -lImlib2 endif -SOURCES := rpng.c rpng_test.c ../../file/nbio/nbio_stdio.c +SOURCES := rpng_nbio.c rpng_test.c ../../file/nbio/nbio_stdio.c OBJS := $(SOURCES:.c=.o) CFLAGS += -Wall -pedantic -std=gnu99 -O0 -g -DHAVE_ZLIB -DHAVE_ZLIB_DEFLATE -DRPNG_TEST -I../../include diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index c77d76997d..5d536c154a 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -693,19 +693,27 @@ bool rpng_load_image_argb_iterate(FILE *file, struct png_chunk *chunk, break; case PNG_CHUNK_IDAT: - if (!(*has_ihdr) || *has_iend || (ihdr->color_type == 3 && !(*has_plte))) - return false; + { + if (!(*has_ihdr) || *has_iend || (ihdr->color_type == 3 && !(*has_plte))) + return false; - if (!png_realloc_idat(chunk, idat_buf)) - return false; + if (!png_realloc_idat(chunk, idat_buf)) + return false; - if (fread(idat_buf->data + idat_buf->size, 1, chunk->size, file) != chunk->size) - return false; + if (fread(idat_buf->data + idat_buf->size, 1, chunk->size, file) != chunk->size) + return false; - *increment_size = sizeof(uint32_t); - idat_buf->size += chunk->size; + *increment_size = sizeof(uint32_t); + idat_buf->size += chunk->size; - *has_idat = true; + for (i = 0; i < idat_buf->size; i++) + { + fprintf(stderr, "%c", idat_buf->data[i]); + } + fprintf(stderr, "\n"); + + *has_idat = true; + } break; case PNG_CHUNK_IEND: diff --git a/libretro-common/formats/png/rpng_nbio.c b/libretro-common/formats/png/rpng_nbio.c index 1e57ebd97e..f028908b7e 100644 --- a/libretro-common/formats/png/rpng_nbio.c +++ b/libretro-common/formats/png/rpng_nbio.c @@ -618,10 +618,12 @@ bool rpng_load_image_argb_iterate(uint8_t *buf, { unsigned i; +#if 0 for (i = 0; i < 4; i++) { fprintf(stderr, "chunktype: %c\n", chunk->type[i]); } +#endif switch (png_chunk_type(chunk)) { @@ -675,9 +677,13 @@ bool rpng_load_image_argb_iterate(uint8_t *buf, if (!png_realloc_idat(chunk, idat_buf)) return false; + buf += 8; + for (i = 0; i < chunk->size; i++) idat_buf->data[i + idat_buf->size] = buf[i]; + idat_buf->size += chunk->size; + *has_idat = true; break; @@ -810,9 +816,11 @@ bool rpng_load_image_argb(const char *path, uint32_t **data, buff_data += 4 + 4 + chunk.size + 4; } +#if 0 fprintf(stderr, "has_ihdr: %d\n", has_ihdr); fprintf(stderr, "has_idat: %d\n", has_idat); fprintf(stderr, "has_iend: %d\n", has_iend); +#endif if (!has_ihdr || !has_idat || !has_iend) GOTO_END_ERROR();