Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load image data into preallocated buffers BUG #2

Closed
cyang812 opened this issue Apr 11, 2018 · 2 comments
Closed

Load image data into preallocated buffers BUG #2

cyang812 opened this issue Apr 11, 2018 · 2 comments
Labels

Comments

@cyang812
Copy link

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
Copy link
Owner

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
Copy link
Author

OK, I get it.

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants