COMImageLib
Once upon a time, in a galaxy far far away, I was writting a small piece of code to capture a screenshot in Windows. It wasn’t difficult to capture the screenshot, nor convert it to a device independant bitmap, nor output it as a .bmp file. But bmp files are huge, and these screenshots were going to be uploaded to a software issue tracking website. So, I decided to convert them to the much more compressable PNG image file format.
It would have been socially inacceptable for me to link libpng and zlib into the very low-level dll that this image capturing was being put into. I decided to make a COM module which would wrap libpng and zlib together. This way, the existence of the COM module could be detected and PNG files used, otherwise BMP files could be used as a last resort measure.
All this COM module can do is convert a BMP file to a PNG file. I hardly wrote any actual code, though. I yoinked the BMP -> PNG conversion from the web page of Jason Summers, and wrote a dead simple interface:
interface IPngImage : IDispatch
{
[id(1), helpstring("method ConvertBMPToPNG")]
HRESULT ConvertBMPToPNG([in] BSTR bsBMP, [in] BSTR bsPNG);
};
Happily this was all I needed. However, if you need something different, this COM module provides a nice framework for doing any work with PNG files since it statically links with pre-built libpng and zlib libraries (included in the source).