wxImage - 2-color TIFFs are inverted on load

Roger Hyde wrote:

I may have other problems. wxWindows is converting the images to 32-bit when it loads them, rather than maintaining the 1-bit black/white. I can't figure out how to use wxBitmap.SetDepth() to get back to 1-bit for writing back out to disk. This will be a problem even if I get the inversion thing sorted out!

wxBitmap is always the same depth as the display since it will normally
be used for displaying an image on the screen. There has been some work
in 2.5 to allow other bit-depths and such, but in 2.4 you are stuck as
far as wxWindows goes. If PIL can't do it then there are probably some
3rd-party modules somewhere that can deal with your image format.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Roger Hyde wrote:

I may have other problems. wxWindows is converting the images to 32-bit when it loads them, rather than maintaining the 1-bit black/white. I can't figure out how to use wxBitmap.SetDepth() to get back to 1-bit for writing back out to disk. This will be a problem even if I get the inversion thing sorted out!

wxBitmap is always the same depth as the display since it will normally
be used for displaying an image on the screen. There has been some work
in 2.5 to allow other bit-depths and such, but in 2.4 you are stuck as
far as wxWindows goes. If PIL can't do it then there are probably some
3rd-party modules somewhere that can deal with your image format.

You can do this (read/write 1-bit images) with PythonMagick; just threshold the image and save it. I've recently started using PythonMagick and it has a lot of potential and a nice addition to Python image processing.

PythonMagick (http://www.procoders.net/moinmoin/PythonMagick) is a thin wrapper on GraphicsMagick (http://www.graphicsmagick.org/) which is a fork of ImageMagick. Magick documentation can be found at (http://www.graphicsmagick.org/www/Magick++/Documentation.html). It does many of the same things that PIL does (and I use them both) but it has one big advantage, it works with 16-bit (and 48-bit color) images. As far as using Python and supporting greater than 8-bit depth, its the only game in town. Currently there is no Linux support (has something to do with boost??). The downside is that its still young and imature but hopefully that will change soon. If you like it, send a friendly email to its creator, Achim Domma (domma@procoders.net). I got it working with wxPython and I'd be happy to post some example code if there's interest.

Bob

Bob Klimek wrote:

PythonMagick (http://www.procoders.net/moinmoin/PythonMagick) is a thin wrapper on GraphicsMagick (http://www.graphicsmagick.org/) which is a fork of ImageMagick.

[...]

I got it working with wxPython and I'd be happy to post some example code if there's interest.

Yes, please put a page in the wxPyWiki about it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!