Ylva And Malin
Data Structures | Macros | Typedefs | Functions | Variables
lodepng.cpp File Reference
#include "lodepng.h"
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for lodepng.cpp:

Data Structures

struct  uivector
 
struct  ucvector
 
struct  HuffmanTree
 
struct  BPMNode
 
struct  BPMLists
 
struct  Hash
 
struct  ColorTree
 

Macros

#define CERROR_BREAK(errorvar, code)
 
#define ERROR_BREAK(code)   CERROR_BREAK(error, code)
 
#define CERROR_RETURN_ERROR(errorvar, code)
 
#define CERROR_TRY_RETURN(call)
 
#define CERROR_RETURN(errorvar, code)
 
#define addBitToStream(bitpointer, bitstream, bit)
 
#define READBIT(bitpointer, bitstream)   ((bitstream[bitpointer >> 3] >> (bitpointer & 0x7)) & (unsigned char)1)
 
#define FIRST_LENGTH_CODE_INDEX   257
 
#define LAST_LENGTH_CODE_INDEX   285
 
#define NUM_DEFLATE_CODE_SYMBOLS   288
 
#define NUM_DISTANCE_SYMBOLS   32
 
#define NUM_CODE_LENGTH_CODES   19
 
#define DEFAULT_WINDOWSIZE   2048
 

Typedefs

typedef struct uivector uivector
 
typedef struct ucvector ucvector
 
typedef struct HuffmanTree HuffmanTree
 
typedef struct BPMNode BPMNode
 
typedef struct BPMLists BPMLists
 
typedef struct Hash Hash
 
typedef struct ColorTree ColorTree
 

Functions

unsigned lodepng_read32bitInt (const unsigned char *buffer)
 
unsigned lodepng_load_file (unsigned char **out, size_t *outsize, const char *filename)
 
unsigned lodepng_save_file (const unsigned char *buffer, size_t buffersize, const char *filename)
 
unsigned lodepng_huffman_code_lengths (unsigned *lengths, const unsigned *frequencies, size_t numcodes, unsigned maxbitlen)
 
unsigned lodepng_inflate (unsigned char **out, size_t *outsize, const unsigned char *in, size_t insize, const LodePNGDecompressSettings *settings)
 
unsigned lodepng_deflate (unsigned char **out, size_t *outsize, const unsigned char *in, size_t insize, const LodePNGCompressSettings *settings)
 
unsigned lodepng_zlib_decompress (unsigned char **out, size_t *outsize, const unsigned char *in, size_t insize, const LodePNGDecompressSettings *settings)
 
unsigned lodepng_zlib_compress (unsigned char **out, size_t *outsize, const unsigned char *in, size_t insize, const LodePNGCompressSettings *settings)
 
void lodepng_compress_settings_init (LodePNGCompressSettings *settings)
 
void lodepng_decompress_settings_init (LodePNGDecompressSettings *settings)
 
unsigned lodepng_crc32 (const unsigned char *data, size_t length)
 
unsigned lodepng_chunk_length (const unsigned char *chunk)
 
void lodepng_chunk_type (char type[5], const unsigned char *chunk)
 
unsigned char lodepng_chunk_type_equals (const unsigned char *chunk, const char *type)
 
unsigned char lodepng_chunk_ancillary (const unsigned char *chunk)
 
unsigned char lodepng_chunk_private (const unsigned char *chunk)
 
unsigned char lodepng_chunk_safetocopy (const unsigned char *chunk)
 
unsigned char * lodepng_chunk_data (unsigned char *chunk)
 
const unsigned char * lodepng_chunk_data_const (const unsigned char *chunk)
 
unsigned lodepng_chunk_check_crc (const unsigned char *chunk)
 
void lodepng_chunk_generate_crc (unsigned char *chunk)
 
unsigned char * lodepng_chunk_next (unsigned char *chunk)
 
const unsigned char * lodepng_chunk_next_const (const unsigned char *chunk)
 
unsigned lodepng_chunk_append (unsigned char **out, size_t *outlength, const unsigned char *chunk)
 
unsigned lodepng_chunk_create (unsigned char **out, size_t *outlength, unsigned length, const char *type, const unsigned char *data)
 
void lodepng_color_mode_init (LodePNGColorMode *info)
 
void lodepng_color_mode_cleanup (LodePNGColorMode *info)
 
unsigned lodepng_color_mode_copy (LodePNGColorMode *dest, const LodePNGColorMode *source)
 
void lodepng_palette_clear (LodePNGColorMode *info)
 
unsigned lodepng_palette_add (LodePNGColorMode *info, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
 
unsigned lodepng_get_bpp (const LodePNGColorMode *info)
 
unsigned lodepng_get_channels (const LodePNGColorMode *info)
 
unsigned lodepng_is_greyscale_type (const LodePNGColorMode *info)
 
unsigned lodepng_is_alpha_type (const LodePNGColorMode *info)
 
unsigned lodepng_is_palette_type (const LodePNGColorMode *info)
 
unsigned lodepng_has_palette_alpha (const LodePNGColorMode *info)
 
unsigned lodepng_can_have_alpha (const LodePNGColorMode *info)
 
size_t lodepng_get_raw_size (unsigned w, unsigned h, const LodePNGColorMode *color)
 
size_t lodepng_get_raw_size_lct (unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth)
 
void lodepng_clear_text (LodePNGInfo *info)
 
unsigned lodepng_add_text (LodePNGInfo *info, const char *key, const char *str)
 
void lodepng_clear_itext (LodePNGInfo *info)
 
unsigned lodepng_add_itext (LodePNGInfo *info, const char *key, const char *langtag, const char *transkey, const char *str)
 
void lodepng_info_init (LodePNGInfo *info)
 
void lodepng_info_cleanup (LodePNGInfo *info)
 
unsigned lodepng_info_copy (LodePNGInfo *dest, const LodePNGInfo *source)
 
void lodepng_info_swap (LodePNGInfo *a, LodePNGInfo *b)
 
unsigned lodepng_convert (unsigned char *out, const unsigned char *in, const LodePNGColorMode *mode_out, const LodePNGColorMode *mode_in, unsigned w, unsigned h)
 
void lodepng_color_profile_init (LodePNGColorProfile *profile)
 
unsigned lodepng_get_color_profile (LodePNGColorProfile *profile, const unsigned char *in, unsigned w, unsigned h, const LodePNGColorMode *mode)
 
unsigned lodepng_auto_choose_color (LodePNGColorMode *mode_out, const unsigned char *image, unsigned w, unsigned h, const LodePNGColorMode *mode_in)
 
unsigned lodepng_inspect (unsigned *w, unsigned *h, LodePNGState *state, const unsigned char *in, size_t insize)
 
unsigned lodepng_decode (unsigned char **out, unsigned *w, unsigned *h, LodePNGState *state, const unsigned char *in, size_t insize)
 
unsigned lodepng_decode_memory (unsigned char **out, unsigned *w, unsigned *h, const unsigned char *in, size_t insize, LodePNGColorType colortype, unsigned bitdepth)
 
unsigned lodepng_decode32 (unsigned char **out, unsigned *w, unsigned *h, const unsigned char *in, size_t insize)
 
unsigned lodepng_decode24 (unsigned char **out, unsigned *w, unsigned *h, const unsigned char *in, size_t insize)
 
unsigned lodepng_decode_file (unsigned char **out, unsigned *w, unsigned *h, const char *filename, LodePNGColorType colortype, unsigned bitdepth)
 
unsigned lodepng_decode32_file (unsigned char **out, unsigned *w, unsigned *h, const char *filename)
 
unsigned lodepng_decode24_file (unsigned char **out, unsigned *w, unsigned *h, const char *filename)
 
void lodepng_decoder_settings_init (LodePNGDecoderSettings *settings)
 
void lodepng_state_init (LodePNGState *state)
 
void lodepng_state_cleanup (LodePNGState *state)
 
void lodepng_state_copy (LodePNGState *dest, const LodePNGState *source)
 
unsigned lodepng_encode (unsigned char **out, size_t *outsize, const unsigned char *image, unsigned w, unsigned h, LodePNGState *state)
 
unsigned lodepng_encode_memory (unsigned char **out, size_t *outsize, const unsigned char *image, unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth)
 
unsigned lodepng_encode32 (unsigned char **out, size_t *outsize, const unsigned char *image, unsigned w, unsigned h)
 
unsigned lodepng_encode24 (unsigned char **out, size_t *outsize, const unsigned char *image, unsigned w, unsigned h)
 
unsigned lodepng_encode_file (const char *filename, const unsigned char *image, unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth)
 
unsigned lodepng_encode32_file (const char *filename, const unsigned char *image, unsigned w, unsigned h)
 
unsigned lodepng_encode24_file (const char *filename, const unsigned char *image, unsigned w, unsigned h)
 
void lodepng_encoder_settings_init (LodePNGEncoderSettings *settings)
 
const char * lodepng_error_text (unsigned code)
 

Variables

const char * LODEPNG_VERSION_STRING = "20170917"
 
const LodePNGCompressSettings lodepng_default_compress_settings = {2, 1, 2048 , 3, 128, 1, 0, 0, 0}
 
const LodePNGDecompressSettings lodepng_default_decompress_settings = {0, 0, 0, 0}
 

Macro Definition Documentation

#define addBitToStream (   bitpointer,
  bitstream,
  bit 
)
Value:
{\
/*add a new byte at the end*/\
if(((*bitpointer) & 7) == 0) ucvector_push_back(bitstream, (unsigned char)0);\
/*earlier bit of huffman code is in a lesser significant bit of an earlier byte*/\
(bitstream->data[bitstream->size - 1]) |= (bit << ((*bitpointer) & 0x7));\
++(*bitpointer);\
}
int GLenum UINT size
Definition: wglext.h:321
int GLenum UINT void * data
Definition: wglext.h:321
#define CERROR_BREAK (   errorvar,
  code 
)
Value:
{\
errorvar = code;\
break;\
}
#define CERROR_RETURN (   errorvar,
  code 
)
Value:
{\
errorvar = code;\
return;\
}
#define CERROR_RETURN_ERROR (   errorvar,
  code 
)
Value:
{\
errorvar = code;\
return code;\
}
#define CERROR_TRY_RETURN (   call)
Value:
{\
unsigned error = call;\
if(error) return error;\
}
#define DEFAULT_WINDOWSIZE   2048
#define ERROR_BREAK (   code)    CERROR_BREAK(error, code)
#define FIRST_LENGTH_CODE_INDEX   257
#define LAST_LENGTH_CODE_INDEX   285
#define NUM_CODE_LENGTH_CODES   19
#define NUM_DEFLATE_CODE_SYMBOLS   288
#define NUM_DISTANCE_SYMBOLS   32
#define READBIT (   bitpointer,
  bitstream 
)    ((bitstream[bitpointer >> 3] >> (bitpointer & 0x7)) & (unsigned char)1)

Typedef Documentation

typedef struct BPMLists BPMLists
typedef struct BPMNode BPMNode
typedef struct ColorTree ColorTree
typedef struct Hash Hash
typedef struct HuffmanTree HuffmanTree
typedef struct ucvector ucvector
typedef struct uivector uivector

Function Documentation

unsigned lodepng_add_itext ( LodePNGInfo info,
const char *  key,
const char *  langtag,
const char *  transkey,
const char *  str 
)

Here is the caller graph for this function:

unsigned lodepng_add_text ( LodePNGInfo info,
const char *  key,
const char *  str 
)

Here is the caller graph for this function:

unsigned lodepng_auto_choose_color ( LodePNGColorMode mode_out,
const unsigned char *  image,
unsigned  w,
unsigned  h,
const LodePNGColorMode mode_in 
)

Here is the caller graph for this function:

unsigned lodepng_can_have_alpha ( const LodePNGColorMode info)

Here is the caller graph for this function:

unsigned char lodepng_chunk_ancillary ( const unsigned char *  chunk)

Here is the caller graph for this function:

unsigned lodepng_chunk_append ( unsigned char **  out,
size_t *  outlength,
const unsigned char *  chunk 
)

Here is the caller graph for this function:

unsigned lodepng_chunk_check_crc ( const unsigned char *  chunk)

Here is the caller graph for this function:

unsigned lodepng_chunk_create ( unsigned char **  out,
size_t *  outlength,
unsigned  length,
const char *  type,
const unsigned char *  data 
)

Here is the caller graph for this function:

unsigned char* lodepng_chunk_data ( unsigned char *  chunk)
const unsigned char* lodepng_chunk_data_const ( const unsigned char *  chunk)

Here is the caller graph for this function:

void lodepng_chunk_generate_crc ( unsigned char *  chunk)

Here is the caller graph for this function:

unsigned lodepng_chunk_length ( const unsigned char *  chunk)

Here is the caller graph for this function:

unsigned char* lodepng_chunk_next ( unsigned char *  chunk)

Here is the caller graph for this function:

const unsigned char* lodepng_chunk_next_const ( const unsigned char *  chunk)

Here is the caller graph for this function:

unsigned char lodepng_chunk_private ( const unsigned char *  chunk)
unsigned char lodepng_chunk_safetocopy ( const unsigned char *  chunk)
void lodepng_chunk_type ( char  type[5],
const unsigned char *  chunk 
)
unsigned char lodepng_chunk_type_equals ( const unsigned char *  chunk,
const char *  type 
)

Here is the caller graph for this function:

void lodepng_clear_itext ( LodePNGInfo info)
void lodepng_clear_text ( LodePNGInfo info)
void lodepng_color_mode_cleanup ( LodePNGColorMode info)

Here is the caller graph for this function:

unsigned lodepng_color_mode_copy ( LodePNGColorMode dest,
const LodePNGColorMode source 
)

Here is the caller graph for this function:

void lodepng_color_mode_init ( LodePNGColorMode info)

Here is the caller graph for this function:

void lodepng_color_profile_init ( LodePNGColorProfile profile)

Here is the caller graph for this function:

void lodepng_compress_settings_init ( LodePNGCompressSettings settings)

Here is the caller graph for this function:

unsigned lodepng_convert ( unsigned char *  out,
const unsigned char *  in,
const LodePNGColorMode mode_out,
const LodePNGColorMode mode_in,
unsigned  w,
unsigned  h 
)

Here is the caller graph for this function:

unsigned lodepng_crc32 ( const unsigned char *  data,
size_t  length 
)

Here is the caller graph for this function:

unsigned lodepng_decode ( unsigned char **  out,
unsigned *  w,
unsigned *  h,
LodePNGState state,
const unsigned char *  in,
size_t  insize 
)

Here is the caller graph for this function:

unsigned lodepng_decode24 ( unsigned char **  out,
unsigned *  w,
unsigned *  h,
const unsigned char *  in,
size_t  insize 
)
unsigned lodepng_decode24_file ( unsigned char **  out,
unsigned *  w,
unsigned *  h,
const char *  filename 
)
unsigned lodepng_decode32 ( unsigned char **  out,
unsigned *  w,
unsigned *  h,
const unsigned char *  in,
size_t  insize 
)
unsigned lodepng_decode32_file ( unsigned char **  out,
unsigned *  w,
unsigned *  h,
const char *  filename 
)

Here is the caller graph for this function:

unsigned lodepng_decode_file ( unsigned char **  out,
unsigned *  w,
unsigned *  h,
const char *  filename,
LodePNGColorType  colortype,
unsigned  bitdepth 
)

Here is the caller graph for this function:

unsigned lodepng_decode_memory ( unsigned char **  out,
unsigned *  w,
unsigned *  h,
const unsigned char *  in,
size_t  insize,
LodePNGColorType  colortype,
unsigned  bitdepth 
)

Here is the caller graph for this function:

void lodepng_decoder_settings_init ( LodePNGDecoderSettings settings)

Here is the caller graph for this function:

void lodepng_decompress_settings_init ( LodePNGDecompressSettings settings)

Here is the caller graph for this function:

unsigned lodepng_deflate ( unsigned char **  out,
size_t *  outsize,
const unsigned char *  in,
size_t  insize,
const LodePNGCompressSettings settings 
)

Here is the caller graph for this function:

unsigned lodepng_encode ( unsigned char **  out,
size_t *  outsize,
const unsigned char *  image,
unsigned  w,
unsigned  h,
LodePNGState state 
)

Here is the caller graph for this function:

unsigned lodepng_encode24 ( unsigned char **  out,
size_t *  outsize,
const unsigned char *  image,
unsigned  w,
unsigned  h 
)
unsigned lodepng_encode24_file ( const char *  filename,
const unsigned char *  image,
unsigned  w,
unsigned  h 
)
unsigned lodepng_encode32 ( unsigned char **  out,
size_t *  outsize,
const unsigned char *  image,
unsigned  w,
unsigned  h 
)
unsigned lodepng_encode32_file ( const char *  filename,
const unsigned char *  image,
unsigned  w,
unsigned  h 
)
unsigned lodepng_encode_file ( const char *  filename,
const unsigned char *  image,
unsigned  w,
unsigned  h,
LodePNGColorType  colortype,
unsigned  bitdepth 
)

Here is the caller graph for this function:

unsigned lodepng_encode_memory ( unsigned char **  out,
size_t *  outsize,
const unsigned char *  image,
unsigned  w,
unsigned  h,
LodePNGColorType  colortype,
unsigned  bitdepth 
)

Here is the caller graph for this function:

void lodepng_encoder_settings_init ( LodePNGEncoderSettings settings)

Here is the caller graph for this function:

const char* lodepng_error_text ( unsigned  code)

Here is the caller graph for this function:

unsigned lodepng_get_bpp ( const LodePNGColorMode info)

Here is the caller graph for this function:

unsigned lodepng_get_channels ( const LodePNGColorMode info)
unsigned lodepng_get_color_profile ( LodePNGColorProfile profile,
const unsigned char *  in,
unsigned  w,
unsigned  h,
const LodePNGColorMode mode 
)

Here is the caller graph for this function:

size_t lodepng_get_raw_size ( unsigned  w,
unsigned  h,
const LodePNGColorMode color 
)

Here is the caller graph for this function:

size_t lodepng_get_raw_size_lct ( unsigned  w,
unsigned  h,
LodePNGColorType  colortype,
unsigned  bitdepth 
)

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned lodepng_has_palette_alpha ( const LodePNGColorMode info)

Here is the caller graph for this function:

unsigned lodepng_huffman_code_lengths ( unsigned *  lengths,
const unsigned *  frequencies,
size_t  numcodes,
unsigned  maxbitlen 
)

Here is the caller graph for this function:

unsigned lodepng_inflate ( unsigned char **  out,
size_t *  outsize,
const unsigned char *  in,
size_t  insize,
const LodePNGDecompressSettings settings 
)

Here is the caller graph for this function:

void lodepng_info_cleanup ( LodePNGInfo info)

Here is the caller graph for this function:

unsigned lodepng_info_copy ( LodePNGInfo dest,
const LodePNGInfo source 
)

Here is the caller graph for this function:

void lodepng_info_init ( LodePNGInfo info)

Here is the caller graph for this function:

void lodepng_info_swap ( LodePNGInfo a,
LodePNGInfo b 
)
unsigned lodepng_inspect ( unsigned *  w,
unsigned *  h,
LodePNGState state,
const unsigned char *  in,
size_t  insize 
)

Here is the caller graph for this function:

unsigned lodepng_is_alpha_type ( const LodePNGColorMode info)

Here is the caller graph for this function:

unsigned lodepng_is_greyscale_type ( const LodePNGColorMode info)

Here is the caller graph for this function:

unsigned lodepng_is_palette_type ( const LodePNGColorMode info)
unsigned lodepng_load_file ( unsigned char **  out,
size_t *  outsize,
const char *  filename 
)

Here is the caller graph for this function:

unsigned lodepng_palette_add ( LodePNGColorMode info,
unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a 
)

Here is the caller graph for this function:

void lodepng_palette_clear ( LodePNGColorMode info)

Here is the caller graph for this function:

unsigned lodepng_read32bitInt ( const unsigned char *  buffer)

Here is the caller graph for this function:

unsigned lodepng_save_file ( const unsigned char *  buffer,
size_t  buffersize,
const char *  filename 
)

Here is the caller graph for this function:

void lodepng_state_cleanup ( LodePNGState state)

Here is the caller graph for this function:

void lodepng_state_copy ( LodePNGState dest,
const LodePNGState source 
)

Here is the caller graph for this function:

void lodepng_state_init ( LodePNGState state)

Here is the caller graph for this function:

unsigned lodepng_zlib_compress ( unsigned char **  out,
size_t *  outsize,
const unsigned char *  in,
size_t  insize,
const LodePNGCompressSettings settings 
)

Here is the caller graph for this function:

unsigned lodepng_zlib_decompress ( unsigned char **  out,
size_t *  outsize,
const unsigned char *  in,
size_t  insize,
const LodePNGDecompressSettings settings 
)

Here is the caller graph for this function:

Variable Documentation

const LodePNGCompressSettings lodepng_default_compress_settings = {2, 1, 2048 , 3, 128, 1, 0, 0, 0}
const LodePNGDecompressSettings lodepng_default_decompress_settings = {0, 0, 0, 0}
const char* LODEPNG_VERSION_STRING = "20170917"