aiko_engine_mp
aiko_engine_mp copied to clipboard
Fix to let load_image work with P4 and P1 type PBM files
I was today years old when I found out there's two different PBM image formats: http://netpbm.sourceforge.net/doc/pbm.html P4 doesn't have a creator comment, P1 does.
P4 [ whitespace ] [width] [height] [whitespace] [image data]
P1 [whitespace] # creator comment [whitespace] [width] [height] [image data]
This patch detects if the file format is P1 and skips over the creator comment to find the width and height.
Thank you for that, I noticed the same issue when
- taking animated gif
- splitting the gif in frame by frame
- converting each frame to PBM.
My problem was that I had file #1:
P4
#Created with GIMP
128 64
file #2:
P4
128 64
From what you said, my first file should have said P1, but it said P4
If you look at tux_64.pbm in the source code, you will also see tux_64.pbm
P4
# CREATOR: GIMP PNM Filter Version 1.1
64 64
So, I don't know what the spec says, but it's probably better to have the parser check the 2nd line, and skip t if it's a comment, regardless of the P value.
I'd be happy to merge this if you test that against both kinds of files and you make sure that the pbm examples in examples/ , still work.