Blame src/lodepng.h

Packit 1c1d7e
/*
Packit 1c1d7e
LodePNG version 20080927
Packit 1c1d7e
Packit 1c1d7e
Copyright (c) 2005-2008 Lode Vandevenne
Packit 1c1d7e
Packit 1c1d7e
This software is provided 'as-is', without any express or implied
Packit 1c1d7e
warranty. In no event will the authors be held liable for any damages
Packit 1c1d7e
arising from the use of this software.
Packit 1c1d7e
Packit 1c1d7e
Permission is granted to anyone to use this software for any purpose,
Packit 1c1d7e
including commercial applications, and to alter it and redistribute it
Packit 1c1d7e
freely, subject to the following restrictions:
Packit 1c1d7e
Packit 1c1d7e
    1. The origin of this software must not be misrepresented; you must not
Packit 1c1d7e
    claim that you wrote the original software. If you use this software
Packit 1c1d7e
    in a product, an acknowledgment in the product documentation would be
Packit 1c1d7e
    appreciated but is not required.
Packit 1c1d7e
Packit 1c1d7e
    2. Altered source versions must be plainly marked as such, and must not be
Packit 1c1d7e
    misrepresented as being the original software.
Packit 1c1d7e
Packit 1c1d7e
    3. This notice may not be removed or altered from any source
Packit 1c1d7e
    distribution.
Packit 1c1d7e
*/
Packit 1c1d7e
Packit 1c1d7e
/** Minified version of LodePNG, with only the encoder code */
Packit 1c1d7e
Packit 1c1d7e
#ifndef LODEPNG_H
Packit 1c1d7e
#define LODEPNG_H
Packit 1c1d7e
Packit 1c1d7e
#include <stdio.h>
Packit 1c1d7e
#include <stdlib.h>
Packit 1c1d7e
#include <string.h>
Packit 1c1d7e
Packit 1c1d7e
/* ////////////////////////////////////////////////////////////////////////// */
Packit 1c1d7e
/* LodeFlate & LodeZlib Setting structs                                       */
Packit 1c1d7e
/* ////////////////////////////////////////////////////////////////////////// */
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
typedef struct LodeZlib_DeflateSettings /*deflate = compress*/
Packit 1c1d7e
{
Packit 1c1d7e
  /*LZ77 related settings*/
Packit 1c1d7e
  unsigned btype; /*the block type for LZ*/
Packit 1c1d7e
  unsigned useLZ77; /*whether or not to use LZ77*/
Packit 1c1d7e
  unsigned windowSize; /*the maximum is 32768*/
Packit 1c1d7e
} LodeZlib_DeflateSettings;
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
/* ////////////////////////////////////////////////////////////////////////// */
Packit 1c1d7e
/* LodePNG                                                                    */
Packit 1c1d7e
/* ////////////////////////////////////////////////////////////////////////// */
Packit 1c1d7e
Packit 1c1d7e
typedef struct LodePNG_InfoColor /*info about the color type of an image*/
Packit 1c1d7e
{
Packit 1c1d7e
  /*header (IHDR)*/
Packit 1c1d7e
  unsigned colorType; /*color type*/
Packit 1c1d7e
  unsigned bitDepth;  /*bits per sample*/
Packit 1c1d7e
Packit 1c1d7e
  /*palette (PLTE)*/
Packit 1c1d7e
  unsigned char* palette; /*palette in RGBARGBA... order*/
Packit 1c1d7e
  size_t palettesize; /*palette size in number of colors (amount of bytes is 4 * palettesize)*/
Packit 1c1d7e
Packit 1c1d7e
  /*transparent color key (tRNS)*/
Packit 1c1d7e
  unsigned key_defined; /*is a transparent color key given?*/
Packit 1c1d7e
  unsigned key_r;       /*red component of color key*/
Packit 1c1d7e
  unsigned key_g;       /*green component of color key*/
Packit 1c1d7e
  unsigned key_b;       /*blue component of color key*/
Packit 1c1d7e
} LodePNG_InfoColor;
Packit 1c1d7e
Packit 1c1d7e
typedef struct LodePNG_InfoPng /*information about the PNG image, except pixels and sometimes except width and height*/
Packit 1c1d7e
{
Packit 1c1d7e
  /*header (IHDR), palette (PLTE) and transparency (tRNS)*/
Packit 1c1d7e
  unsigned width;             /*width of the image in pixels (ignored by encoder, but filled in by decoder)*/
Packit 1c1d7e
  unsigned height;            /*height of the image in pixels (ignored by encoder, but filled in by decoder)*/
Packit 1c1d7e
  unsigned compressionMethod; /*compression method of the original file*/
Packit 1c1d7e
  unsigned filterMethod;      /*filter method of the original file*/
Packit 1c1d7e
  unsigned interlaceMethod;   /*interlace method of the original file*/
Packit 1c1d7e
  LodePNG_InfoColor color;    /*color type and bits, palette, transparency*/
Packit 1c1d7e
} LodePNG_InfoPng;
Packit 1c1d7e
Packit 1c1d7e
typedef struct LodePNG_InfoRaw /*contains user-chosen information about the raw image data, which is independent of the PNG image*/
Packit 1c1d7e
{
Packit 1c1d7e
  LodePNG_InfoColor color;
Packit 1c1d7e
} LodePNG_InfoRaw;
Packit 1c1d7e
Packit 1c1d7e
unsigned LodePNG_InfoColor_addPalette(LodePNG_InfoColor* info, unsigned char r, unsigned char g, unsigned char b, unsigned char a); /*add 1 color to the palette*/
Packit 1c1d7e
Packit 1c1d7e
typedef struct LodePNG_EncodeSettings
Packit 1c1d7e
{
Packit 1c1d7e
  LodeZlib_DeflateSettings zlibsettings; /*settings for the zlib encoder, such as window size, ...*/
Packit 1c1d7e
Packit 1c1d7e
  unsigned autoLeaveOutAlphaChannel; /*automatically use color type without alpha instead of given one, if given image is opaque*/
Packit 1c1d7e
  unsigned force_palette; /*force creating a PLTE chunk if colortype is 2 or 6 (= a suggested palette). If colortype is 3, PLTE is _always_ created.*/
Packit 1c1d7e
} LodePNG_EncodeSettings;
Packit 1c1d7e
Packit 1c1d7e
void LodePNG_EncodeSettings_init(LodePNG_EncodeSettings* settings);
Packit 1c1d7e
Packit 1c1d7e
typedef struct LodePNG_Encoder
Packit 1c1d7e
{
Packit 1c1d7e
  LodePNG_EncodeSettings settings;
Packit 1c1d7e
  LodePNG_InfoPng infoPng; /*the info specified by the user may not be changed by the encoder. The encoder will try to generate a PNG close to the given info.*/
Packit 1c1d7e
  LodePNG_InfoRaw infoRaw; /*put the properties of the input raw image in here*/
Packit 1c1d7e
  unsigned error;
Packit 1c1d7e
} LodePNG_Encoder;
Packit 1c1d7e
Packit 1c1d7e
void LodePNG_Encoder_init(LodePNG_Encoder* encoder);
Packit 1c1d7e
void LodePNG_Encoder_cleanup(LodePNG_Encoder* encoder);
Packit 1c1d7e
void LodePNG_Encoder_copy(LodePNG_Encoder* dest, const LodePNG_Encoder* source);
Packit 1c1d7e
Packit 1c1d7e
/*This function allocates the out buffer and stores the size in *outsize.*/
Packit 1c1d7e
void LodePNG_encode(LodePNG_Encoder* encoder, unsigned char** out, size_t* outsize, const unsigned char* image, unsigned w, unsigned h);
Packit 1c1d7e
Packit 1c1d7e
/*free functions allowing to load and save a file from/to harddisk*/
Packit 1c1d7e
/*This function allocates the out buffer and stores the size in *outsize.*/
Packit 1c1d7e
//unsigned LodePNG_loadFile(unsigned char** out, size_t* outsize, const char* filename);
Packit 1c1d7e
unsigned LodePNG_saveFile(const unsigned char* buffer, size_t buffersize, const char* filename);
Packit 1c1d7e
Packit 1c1d7e
#endif
Packit 1c1d7e