Menu

#156 Fixed some issues with the EXR file reading

open
nobody
None
5
2022-10-03
2022-10-03
No

Hello,
While attempting to use FreeImage to read some EXR files from the OpenEXR sample images, I noticed that many of them would not open correctly and some of them would outright crash the program. Here are two patches to fix the issues.

The first one (CIStream_read.diff) fixes the return value of the C_IStream::read. According to the OpenEXR IStream documentation, the read function "reads the last byte from the file it returns false, otherwise it returns true". The implementation was doing exactly the opposite. This fixes the file reading in most cases. This patch can be applied on the vanilla trunk of FreeImage.

The second patch (slice_make_openexr313.patch) is for the crash in case the image had negative values in its datawindow min values. The offset was calculated wrong in this case. Since OpenEXR 3 provides a function for calculating that stuff internally, I opted to use the OpenEXR 3.1.3 patch by Neil Bickford as a base for this patch. If someone wishes to do this fix for the trunk and OpenEXR 2, they can probably check the correct maths from the OpenEXR 3 Slice::Make function. The image that reproduces the crash is ScanLines/Blobbies.exr from the sample images linked above.

Cheers,
Jouni Pänkäläinen

2 Attachments

Discussion

Anonymous
Anonymous

Add attachments
Cancel