From c4a6e1fd4dcde1a1287395d6f15ea2a000f4192a Mon Sep 17 00:00:00 2001 From: ocpalo Date: Wed, 31 Aug 2022 20:39:19 +0300 Subject: [PATCH] decode chunks and calculate checksums --- modules/imgcodecs/src/grfmt_spng.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/imgcodecs/src/grfmt_spng.cpp b/modules/imgcodecs/src/grfmt_spng.cpp index 8bcbbe21c7..e3c61164e4 100644 --- a/modules/imgcodecs/src/grfmt_spng.cpp +++ b/modules/imgcodecs/src/grfmt_spng.cpp @@ -121,7 +121,6 @@ bool SPngDecoder::readHeader() } m_ctx = ctx; - spng_set_crc_action(ctx, SPNG_CRC_USE, SPNG_CRC_USE); if (!m_buf.empty()) spng_set_png_stream((struct spng_ctx *)m_ctx, (spng_rw_fn *)readDataFromBuf, this); @@ -336,7 +335,7 @@ bool SPngDecoder::readData(Mat &img) else { AutoBuffer imageBuffer(image_size); - spng_decode_image(png_ptr, imageBuffer.data(), image_size, fmt, 0); + ret = spng_decode_image(png_ptr, imageBuffer.data(), image_size, fmt, 0); int step = m_width * img.channels(); if (fmt == SPNG_FMT_RGB8) { @@ -469,16 +468,17 @@ bool SPngDecoder::readData(Mat &img) if (ret == SPNG_EOI) { + ret = spng_decode_chunks(png_ptr); + if(ret == SPNG_OK) result = true; struct spng_exif exif_s{}; ret = spng_get_exif(png_ptr, &exif_s); if (ret == SPNG_OK) { if (exif_s.data && exif_s.length > 0) { - m_exif.parseExif((unsigned char *)exif_s.data, exif_s.length); + result = m_exif.parseExif((unsigned char *)exif_s.data, exif_s.length); } } - result = true; } } }