PizzaPNG

PizzaPNG is a C++ library for easy generation of image files in the PNG format, in software for Windows. License: MIT.

Features

  • Simple API.
  • No dependencies. libpng is unneeded.
  • Automatically removes unneeded meta chunks added by GDI+.
  • Supports inserting custom binary chunks.

Limitations

  • Only for Windows due to using GDI+.
  • Only 24-bit and 32-bit (24-bit with transparency) PNG files are supported.

Example

The program below generates a 123×42 green image with 50% opacity and saves it as a file named example.png.

#include <cstdint>
#include <fstream>
#include <string>

#include "pizza-png/Image.h"

using std::ios;

int main() {
    uint16_t width  = 123,
             height = 42;

    size_t pixelCount = width * height;

    MaratTanalin::PizzaPNG::Image image(width, height);

    for (size_t i = 0; i < pixelCount; i++) {
        image.addPixel(0, 255, 0, 127);
    }

    std::string pngData = image;

    std::ofstream fs("example.png", ios::out | ios::binary | ios::trunc);
    fs.write(pngData.c_str(), pngData.size());
    fs.close();
}