Newer
Older
Import / research / 3d-experiments / Framework / PngImage.h
//  BlockyFroggy
//  Copyright © 2017 John Ryland.
//  All rights reserved.
#pragma once
#ifndef PNG_IMAGE_H
#define PNG_IMAGE_H

/*
  Modified version of PicoPNG, original written by Lode Vandevenne
  Modification by John Ryland
*/
#include <vector>
#include <cstdint>

/*
decodePNG: The picoPNG function, decodes a PNG file buffer in memory, into a raw pixel buffer.
out_image: output parameter, this will contain the raw pixels after decoding.
  By default the output is 32-bit RGBA color.
  The std::vector is automatically resized to the correct size.
image_width: output_parameter, this will contain the width of the image in pixels.
image_height: output_parameter, this will contain the height of the image in pixels.
in_png: pointer to the buffer of the PNG file in memory. To get it from a file on
  disk, load it and store it in a memory buffer yourself first.
in_size: size of the input PNG file in bytes.
return: 0 if success, not 0 if some error occured.
*/
int decodePNG(std::vector<uint8_t>& out_image, uint32_t& image_width, uint32_t& image_height, const uint8_t* in_png, size_t in_size);


#endif // PNG_IMAGE_H