forked from kornelski/pngquant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rwpng.h
96 lines (76 loc) · 2.92 KB
/
rwpng.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*---------------------------------------------------------------------------
pngquant: RGBA -> RGBA-palette quantization program rwpng.h
---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
be held liable for any damages arising in any way from the use of
this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. Redistributions of source code must retain the above copyright
notice, disclaimer, and this list of conditions.
2. Redistributions in binary form must reproduce the above copyright
notice, disclaimer, and this list of conditions in the documenta-
tion and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this
software must display the following acknowledgment:
This product includes software developed by Greg Roelofs
and contributors for the book, "PNG: The Definitive Guide,"
published by O'Reilly and Associates.
---------------------------------------------------------------------------*/
#ifndef RWPNG_H
#define RWPNG_H
#include "png.h" /* libpng header; includes zlib.h */
#include <setjmp.h>
#ifndef USE_COCOA
#define USE_COCOA 0
#endif
typedef enum {
SUCCESS = 0,
MISSING_ARGUMENT = 1,
READ_ERROR = 2,
INVALID_ARGUMENT = 4,
NOT_OVERWRITING_ERROR = 15,
CANT_WRITE_ERROR = 16,
OUT_OF_MEMORY_ERROR = 17,
WRONG_ARCHITECTURE = 18, // Missing SSE3
PNG_OUT_OF_MEMORY_ERROR = 24,
LIBPNG_FATAL_ERROR = 25,
LIBPNG_INIT_ERROR = 35,
TOO_LOW_QUALITY = 99,
} pngquant_error;
typedef struct {
jmp_buf jmpbuf;
png_uint_32 width;
png_uint_32 height;
double gamma;
unsigned char **row_pointers;
unsigned char *rgba_data;
png_size_t file_size;
} png24_image;
typedef struct {
jmp_buf jmpbuf;
png_uint_32 width;
png_uint_32 height;
double gamma;
unsigned char **row_pointers;
unsigned char *indexed_data;
unsigned int num_palette;
unsigned int num_trans;
png_color palette[256];
unsigned char trans[256];
char fast_compression;
} png8_image;
typedef union {
jmp_buf jmpbuf;
png24_image png24;
png8_image png8;
} rwpng_png_image;
/* prototypes for public functions in rwpng.c */
void rwpng_version_info(FILE *fp);
pngquant_error rwpng_read_image24(FILE *infile, png24_image *mainprog_ptr);
pngquant_error rwpng_write_image8(FILE *outfile, png8_image *mainprog_ptr);
pngquant_error rwpng_write_image24(FILE *outfile, png24_image *mainprog_ptr);
#endif