This is a RLE compression routine written in MFC. I wrote this because I could not find handy code for such thing.
RLE compression is useful when saving SIMPLE Windows bitmap. Especially my implementation is rather stupid and not optimized. Therefore, if the source bitmap is complex (like the one in the demo app window shown above), you could even get a bigger bitmap file after compression. :)
The compression routine is wrapped in an MFC bitmap control class,
CDVDBitmapControl, which you can put in a dialog conveniently. The usage is easy:
- Add a static control (say
IDC_STATIC_BITMAP) in the dialog for the bitmap control
- Add a
#include "DVDBitmapControl.h" in the header file of your dialog
- Add a member variable (say
m_bmp) of type
CDVDBitmapControl in your dialog class.
OnInitDialog(), add this line:
m_bmp.SubclassDlgItem( IDC_STATIC_BITMAP, this);
m_bmp.LoadBitmapFile(CString) to load bitmap into control
m_bmp.SaveBitmapFile(CString) to save bitmap into 8-bit RLE bitmap
If you need only the compression code, you can extract the
CDVDBitmapControl::EndOfLine() routines from
DVDBitmapControl.cpp. It is quite straight forward to use them (with some substitutions for bitmap width, bitmap height in code).
I did not write the decompression part because Windows API
LoadImage() already does it.
PS: in the demo app, if the loaded bitmap is not in 256 color, [Save] will not work.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.