GNOME Bugzilla – Bug 595215
PNM encoder doesn't support ASCII encoding
Last modified: 2009-09-16 22:18:42 UTC
Created attachment 143196 [details] [review] Patch to add ASCII encoding support. The PNM encoder doesn't support ASCII encoding (the decoder doesn't, neither, but that's another story). Attached patch fixes this by adding an ascii property to the encoder. If set to true (it is off by default), the encoder produces files in ASCII encoding. While at it, I... - fixed the example - completed the documentation - removed some unused code from gstpnmutils.[c,h] - improved the readability of the code by splitting up type and encoding
Looks good, now only check in the decoder that the encoding is not ASCII and I'm going to commit this ;) Also I think the ASCII encoding is wrong. You're outputting a \n after the first byte and then every 20 bytes. What exactly is the difference between BITMAP and GRAYMAP?
Created attachment 143242 [details] [review] Patch to add ASCII encoding support. As requested, the decoder now refuses to handle ascii encoded files or files in bitmap format (1 pixel = 1 bit). I'll add this functionality later. By the way, the Gimp can load the ascii encoded files generated by this encoder, therefore the ASCII encoding can't be that wrong... The '\n' is added after 20 bytes (= 80 characters) to make the display on terminals easier. See for instance Wikipedia for details on the PNM format.
Ok, I've committed this. One minor thing though: You should add the encoding to the caps IMHO, this way the decoder can already declare from the caps that it doesn't support ASCII. Also the ASCII property could go away then and it could be selected depending on downstream caps. The problem with the ASCII encoding that I meant is, that you add a newline after the *first* byte (i == 0 && i % something == 0) and then after every 20 bytes (which is correct of course). That's not a real problem, it's just not beautiful ;) commit 93172c445311eadeef82107382bcfccdb47d33dc Author: Lutz Mueller <lutz@topfrose.de> Date: Wed Sep 16 08:22:19 2009 +0200 pnm: Support ASCII format for encoding and handle unsupported formats better Fixes bug #595215.
Any reason for not using gdkpixbuf for PxM encoding/decoding?
As far as I know, gdk-pixbuf can't be used for encoding. By the way: ASCII decoding support now at #595409.