Blame src/lodepng.h

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