Niotso  git revision 558726a9f13d7c3423a683dd2f4323589b66c310
The New Implementation of The Sims Online
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
opngreduc.h
Go to the documentation of this file.
1 /*
2  * opngreduc.h - libpng extension: lossless image reductions.
3  *
4  * Copyright (C) 2003-2011 Cosmin Truta.
5  * This software is distributed under the same licensing and warranty terms
6  * as libpng.
7  *
8  * This code is functional, although it is still work in progress.
9  * Upon completion, it will be submitted for incorporation into libpng.
10  */
11 
12 #ifndef OPNGREDUC_H
13 #define OPNGREDUC_H
14 
15 #include <png.h>
16 
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 
23 #ifdef PNG_INFO_IMAGE_SUPPORTED
24 
25 /*
26  * Indicate whether the image information is valid, i.e.
27  * all the required critical information is present in the png structures.
28  */
29 int PNGAPI opng_validate_image(png_structp png_ptr, png_infop info_ptr);
30 
31 #endif /* PNG_INFO_IMAGE_SUPPORTED */
32 
33 
34 #ifndef OPNG_NO_IMAGE_REDUCTIONS
35 #define OPNG_IMAGE_REDUCTIONS_SUPPORTED
36 #endif
37 
38 #ifdef OPNG_IMAGE_REDUCTIONS_SUPPORTED
39 
40 #ifndef PNG_INFO_IMAGE_SUPPORTED
41 #error OPNG_IMAGE_REDUCTIONS_SUPPORTED requires PNG_INFO_IMAGE_SUPPORTED
42 #endif
43 
44 #ifndef PNG_tRNS_SUPPORTED
45 #error OPNG_IMAGE_REDUCTIONS_SUPPORTED requires proper transparency support
46 #endif
47 
48 /*
49  * Reduce the image (bit depth + color type + palette) without
50  * losing any information. The image data must be present
51  * (e.g. after calling png_set_rows(), or after loading IDAT).
52  */
53 png_uint_32 PNGAPI opng_reduce_image(png_structp png_ptr, png_infop info_ptr,
54  png_uint_32 reductions);
55 
56 /*
57  * PNG reduction flags.
58  */
59 #define OPNG_REDUCE_NONE 0x0000
60 #define OPNG_REDUCE_16_TO_8 0x0001 /* discard bits 8-15 */
61 #define OPNG_REDUCE_8_TO_4_2_1 0x0002 /* discard bits 4-7, 2-7 or 1-7 */
62 #define OPNG_REDUCE_RGB_TO_GRAY 0x0004 /* ...also RGBA to GA */
63 #define OPNG_REDUCE_STRIP_ALPHA 0x0008 /* ...and create tRNS if needed */
64 #define OPNG_REDUCE_RGB_TO_PALETTE 0x0010 /* ...also RGBA to palette/tRNS */
65 #define OPNG_REDUCE_PALETTE_TO_RGB 0x0020 /* TODO */
66 #define OPNG_REDUCE_GRAY_TO_PALETTE 0x0040 /* ...also GA to palette/tRNS */
67 #define OPNG_REDUCE_PALETTE_TO_GRAY 0x0080 /* ...also palette/tRNS to GA */
68 #define OPNG_REDUCE_PALETTE_SLOW 0x0100 /* TODO: remove all sterile entries
69  and reorder PLTE */
70 #define OPNG_REDUCE_PALETTE_FAST 0x0200 /* remove trailing sterile entries
71  only; do not reorder PLTE */
72 #define OPNG_REDUCE_ANCILLARY 0x1000 /* TODO */
73 
74 #define OPNG_REDUCE_BIT_DEPTH \
75  (OPNG_REDUCE_16_TO_8 | OPNG_REDUCE_8_TO_4_2_1)
76 
77 #define OPNG_REDUCE_COLOR_TYPE \
78  (OPNG_REDUCE_RGB_TO_GRAY | OPNG_REDUCE_STRIP_ALPHA | \
79  OPNG_REDUCE_RGB_TO_PALETTE | OPNG_REDUCE_PALETTE_TO_RGB | \
80  OPNG_REDUCE_GRAY_TO_PALETTE | OPNG_REDUCE_PALETTE_TO_GRAY)
81 
82 #define OPNG_REDUCE_PALETTE \
83  (OPNG_REDUCE_PALETTE_SLOW | OPNG_REDUCE_PALETTE_FAST)
84 
85 #define OPNG_REDUCE_ALL \
86  (OPNG_REDUCE_BIT_DEPTH | OPNG_REDUCE_COLOR_TYPE | \
87  OPNG_REDUCE_PALETTE | OPNG_REDUCE_ANCILLARY)
88 
89 #endif /* OPNG_IMAGE_REDUCTIONS_SUPPORTED */
90 
91 
92 #ifdef __cplusplus
93 } /* extern "C" */
94 #endif
95 
96 
97 #endif /* OPNGREDUC_H */