On Tuesday, November 15, 2016 at 2:46:31 PM UTC-5, ruben safir wrote:
> Does anyone know of any sample code for reading PNG files that doesn't
> include using libpng.... just straight direct access.
On Windows and with a C++ compiler, you can use the built-in
Gdiplus::Bitmap object and load the png and then write it out
as a standard .bmp format, which is much easier to access
line-by-line.
See:
Bitmap class:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms534420(v=vs.85).aspx
Basically, load the image, convert it to a HBITMAP which you then
BitBlt onto another HBITMAP you've created using CreateDIBSection().
In that one you obtain a pointer to the bits and can write them out
in any format you desire:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms536295(v=vs.85).aspx
Some steps in this operation:
Make sure structures are packed to 1-byte (and not the default 8-
or 16-bytes).
Use GdiplusStartup() to engage the Gdiplus engine.
Use the image->GetWidth() and image->GetHeight() to determine size.
Use image->LockBits() to obtain a BitmapData object.
Use image->GetHorizontalResolution() * 39.700787f to get pixels
per meter for the output bmp setting. And GetVerticalResolution().
Use image->unlockBits() when finished.
Use GdiplusShutdown() to disengage the Gdiplus engine.
Best regards,
Rick C. Hodgin