Load image data into preallocated buffers BUG
cyang812 opened this issue · 2 comments
cyang812 commented
when I use ok_png_read_to_buffer()
or ok_jpg_read_to_buffer()
to decode image and storage raw data in a buffer , I can't get the data in there, and error_message
is empty.
I find something wrong in your code, maybe I use it wrong.
In the ok_png.c
line 750, you check the dst_buffer
and create it. But if the dst_buffer is preallocated, you do nothing. So I add a else
case like this else{png->data = decoder->dst_buffer;}
, then it's correct.
It's the same case in the ok_jpg.c
line 1586.
Excuse me for bad english!
brackeen commented
That is intentional. png->data
is not set in that case, so that ok_png_free
doesn't deallocate data
. The decoded data will be in the buffer your code provides.
cyang812 commented
OK, I get it.
Thanks a lot.