The bug arises because Unreal is outputting .bmp files with the BI_BITFIELDS compression flag set - although it is not using any known valid compression format. There are three acceptable flag conditions in the file linked above the error thrown (line 132). The first acceptable “compression” is actually a 32 bit file where the last 8 bits (alpha) are ignored. The other two appear to be the 565 and 555 methods of compression (see The BI_BITFIELDS bitmap type - virtualdub.org).
PIL, when noting that the compression flag is set, does not expect an uncompressed 24bit file. The standard 24-bit(888) which Unreal appears to be using should not have the compression flag bit set.
Is there any reason as to why the flag bit is set for Unreal screenshots? Is there any way around this weird bitmap format that the engine is outputting so that I can leverage the automated process I have defined?
(I am aware that my use case is a very esoteric one however it does highlight an issue with the bitmap files being created through screenshots)
You do bring up a really great issue. Since it has been some time since this was originally posted, I would like to follow up and see if you were able to find a work-around, or if the issue was resolved.
Since this post, we have had some updates to our features and some fixes. I looked in the release notes and did not find anything specifically related to this issue, but I could be overlooking it.
One workaround I would suggest would be to use the High Resolution Screenshot feature. ‘You can save rich frame data including HDR colors and 16-bit pixel depth into an OpenEXR file. This is really useful for offline compositing work.’
If you are willing, try updating to version 4.6 and see if this does not resolve your issue. If you are still experiencing it however, let me know and we can further investigate.
Thank you for looking into this issue. I have just tried to take a normal screenshot using 4.6 and encountered the same issue when attempting a convert using PIL as mentioned initially. In relation to the HighResShot command I recall having a number of issues with it reliably creating the file (generating a friendlier png file) using this method and as a result focussed on finding a solution that was able to deal with the bmp file as it was being generated rather than settings within UE4 itself.
To this end I eventually created a working solution by interfacing with the ImageMagick (http://www.imagemagick.org/) library. This solution, whilst not as straightforward to implement as PIL originally was, seems to be less concerned with this particular inconsistency with the screenshot being handled and achieved the aims of the project at the time.