This looks incredibly like Microsoft Shared Visual C++ code, using the MS
CImage and CDC classes, though I'm somewhat puzzled by CPixMap (the use of
PM[0] is impossible to understand without the definition of the CPixMap
type.)
If this *IS* Visual C++/MFC then why not implement read_png thus:
CImage *read_png(char *file_name) {
CImage *Image = new CImage();
if (Image != 0)
Image->Load(file_name);
return Image;
}
If that code results in an incorrectly loaded PNG I would be very
surprised...
As for displaying it, the code you quoted, using CDC::FillSolidRect, is just
going to fill those rectangles with RGB(0,128,255) and the color (COLORREF)
argument to CDC::FillSolidRect can't express a non-opaque color (COLORREF
has no alpha component). To quote from MSDN:
"When the ARGB value is converted to a COLORREF value, the alpha component
of the ARGB value is ignored."
So you will get black *with your load code* (because you premultiplied out.)
With the code I suggest above you will probably get black too, because
CImage is, IRC, natively pre-multiplied, but you might not.
BTW a CImage can be drawn directly onto a CDC with arbitrary scaling and
correct alpha handling, and correct color space handling, using
CImage::Draw, so why not use that?
John Bowler <
jbowler@...>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com_______________________________________________
png-mng-misc mailing list
png-mng-misc@...
https://lists.sourceforge.net/lists/listinfo/png-mng-misc