How can I create PNG Files from an array of bytes or read a PNG file to create an array of bytes?
I looked up the format but it looks nothing like a bitmap and I read the GDI doesn't support PNG's. So how does LibPNG do it then? I don't want to use LibPNG or anything. I want to do it myself. I tried changing BI_RGB to BI_PNG but that just corrupts it all. There isn't a single tutorial out there on reading and using the PNG format with C++. Any ideas or links on how to read it? I read the entire format I just don't know where to start.
For bitmaps I use:
Pixels.clear();
memset(&Info, 0, sizeof(BITMAPINFO));
Info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
Info.bmiHeader.biPlanes = 1;
Info.bmiHeader.biBitCount = BitsPerPixel;
Info.bmiHeader.biCompression = BI_RGB;
Info.bmiHeader.biWidth = width;
Info.bmiHeader.biHeight = height;
Info.bmiHeader.biSizeImage = size = ((width * BitsPerPixel + 31) / 32) * 4 * height;
bFileHeader.bfType = 0x4D42;
bFileHeader.bfSize = bFileHeader.bfOffBits + size;
bFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(Info.bmiHeader);
Pixels.resize(width * height);
//CreateFile... Reads pixels and flip rows. :)