Loading PNGs with GDI+ from an IStream

Louis Solomon / SteelBytes
13/Feb/04

Problem 
------- 
loading images from a custom istream using gdi+ functions works for all 
image types I tried, EXCEPT for PNG files !!! 


Cause 
----- 
I was using a custom istream that implemented IUnknown, ISequentialStream, 
IStream. when loading the png, gdi+ was querying for a IImageBytes (defined 
in GdiplusImaging.h). why does the png loader section of gdi+ use this, and 
no other image loader ? ask MS :-) 


Solution 
-------- 
implement IImageBytes. note, since my istream was actually a section of 
memory mapped file, no fancy locking was required to implement LockBytes() & 
UnlockBytes().