bkaradzic / bimg

Image library.
BSD 2-Clause "Simplified" License
327 stars 268 forks source link

image_decode.cpp解析png图片错误 #40

Closed dsafa22 closed 4 years ago

dsafa22 commented 4 years ago

我在使用image_decode.cpp中的imageParse方法解析png图片遇到问题。 问题原因:

ImageContainer* input = imageParseDds     (_allocator, _data, _size, _err)        ;
        input = NULL == input ? imageParseKtx     (_allocator, _data, _size, _err) : input;
        input = NULL == input ? imageParsePvr3    (_allocator, _data, _size, _err) : input;
        input = NULL == input ? imageParseGnf     (_allocator, _data, _size, _err) : input;
        input = NULL == input ? imageParseLodePng (_allocator, _data, _size, _err) : input;
        input = NULL == input ? imageParseTinyExr (_allocator, _data, _size, _err) : input;
        input = NULL == input ? imageParseJpeg    (_allocator, _data, _size, _err) : input;
        input = NULL == input ? imageParseStbImage(_allocator, _data, _size, _err) : input;

在执行imageParseLodePng方法前,_err因为不是其他格式被设置错误

BX_ERROR_SET(_err, BIMG_ERROR, "Invalid header magic.");

imageParseLodePng执行完之后,_err还是存在,没有被重置,导致错误。

--- Google translate ---

I'm having trouble parsing png images using the imageParse method in image_decode.cpp. problem causes:

ImageContainer * input = imageParseDds (_allocator, _data, _size, _err); input = NULL == input? imageParseKtx (_allocator, _data, _size, _err): input; input = NULL == input? imageParsePvr3 (_allocator, _data, _size, _err): input; input = NULL == input? imageParseGnf (_allocator, _data, _size, _err): input; input = NULL == input? imageParseLodePng (_allocator, _data, _size, _err): input; input = NULL == input? imageParseTinyExr (_allocator, _data, _size, _err): input; input = NULL == input? imageParseJpeg (_allocator, _data, _size, _err): input; input = NULL == input? imageParseStbImage (_allocator, _data, _size, _err): input;

Before executing the imageParseLodePng method, _err was set incorrectly because it is not in another format

BX_ERROR_SET (_err, BIMG_ERROR, "Invalid header magic.");

After imageParseLodePng is executed, _err still exists and has not been reset, resulting in an error.

bkaradzic commented 4 years ago

This issue was fixed, grab latest...

dsafa22 commented 4 years ago

High efficiency!