[wxPython] How can I save a 8-bit bitmap?

"Maurizio Turatti" <mturatti@ais.it> (MT) writes:

Hi,
My app (wxPython 2.1.15) loads a big BMP image (5000x5000 pixels, 8-bit
depth) then divides it in blocks, with GetSubBitmap. The problem is
that it saves a 24-bit image, so the question is:
is there a way to preserve the color depth of my bitmap (it could save
me a lot of disk space...)? I tried also to Get and then Set the
palette, but it was the same.
This is a piece of the python code:

     ...
                palette = self.bmp.GetPalette()
                subbmp = self.bmp.GetSubBitmap(rect)
                subbmp.SetPalette(palette)
                subbmp.SaveFile(fname, wxBITMAP_TYPE_BMP)
     ...

Should I try to save in another format?

BMP is a silly format as it is not compressed. Better use PNG (with wxImage
or by using PIL, the Python imaging library).

···

--
Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: Piet.van.Oostrum@freeler.nl