1 /**
2  * @file gdipluspixelformats.h
3  * Copyright 2012, 2013 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 /* Created by Markus Koenig <markus@stber-koenig.de> */
25 #ifndef __GDIPLUS_PIXELFORMATS_H
26 #define __GDIPLUS_PIXELFORMATS_H
27 #pragma GCC system_header
28 #include <_mingw.h>
29 
30 /*
31  * GDI+ pixel formats
32  */
33 
34 typedef DWORD ARGB;
35 typedef INT PixelFormat;
36 
37 #define PixelFormatIndexed ((INT) 0x00010000)
38 #define PixelFormatGDI ((INT) 0x00020000)
39 #define PixelFormatAlpha ((INT) 0x00040000)
40 #define PixelFormatPAlpha ((INT) 0x00080000)
41 #define PixelFormatExtended ((INT) 0x00100000)
42 #define PixelFormatCanonical ((INT) 0x00200000)
43 #define PixelFormatUndefined ((INT) 0)
44 #define PixelFormatDontCare ((INT) 0)
45 #define PixelFormat1bppIndexed ((INT) \
46 	(1 | (1<<8) | PixelFormatIndexed | PixelFormatGDI))
47 #define PixelFormat4bppIndexed ((INT) \
48 	(2 | (4<<8) | PixelFormatIndexed | PixelFormatGDI))
49 #define PixelFormat8bppIndexed ((INT) \
50 	(3 | (8<<8) | PixelFormatIndexed | PixelFormatGDI))
51 #define PixelFormat16bppGrayScale ((INT) \
52 	(4 | (16<<8) | PixelFormatExtended))
53 #define PixelFormat16bppRGB555 ((INT) \
54 	(5 | (16<<8) | PixelFormatGDI))
55 #define PixelFormat16bppRGB565 ((INT) \
56 	(6 | (16<<8) | PixelFormatGDI))
57 #define PixelFormat16bppARGB1555 ((INT) \
58 	(7 | (16<<8) | PixelFormatAlpha | PixelFormatGDI))
59 #define PixelFormat24bppRGB ((INT) \
60 	(8 | (24<<8) | PixelFormatGDI))
61 #define PixelFormat32bppRGB ((INT) \
62 	(9 | (32<<8) | PixelFormatGDI))
63 #define PixelFormat32bppARGB ((INT) \
64 	(10 | (32<<8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical))
65 #define PixelFormat32bppPARGB ((INT) \
66 	(11 | (32<<8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI))
67 #define PixelFormat48bppRGB ((INT) \
68 	(12 | (48<<8) | PixelFormatExtended))
69 #define PixelFormat64bppARGB ((INT) \
70 	(13 | (64<<8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended))
71 #define PixelFormat64bppPARGB ((INT) \
72 	(14 | (64<<8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended))
73 #define PixelFormatMax ((INT) 15)
74 
75 typedef enum PaletteFlags {
76 	PaletteFlagsHasAlpha = 1,
77 	PaletteFlagsGrayScale = 2,
78 	PaletteFlagsHalftone = 4
79 } PaletteFlags;
80 
81 typedef enum PaletteType {
82 	PaletteTypeCustom = 0,
83 	PaletteTypeOptimal = 1,
84 	PaletteTypeFixedBW = 2,
85 	PaletteTypeFixedHalftone8 = 3,
86 	PaletteTypeFixedHalftone27 = 4,
87 	PaletteTypeFixedHalftone64 = 5,
88 	PaletteTypeFixedHalftone125 = 6,
89 	PaletteTypeFixedHalftone216 = 7,
90 	PaletteTypeFixedHalftone252 = 8,
91 	PaletteTypeFixedHalftone256 = 9
92 } PaletteType;
93 
94 typedef struct ColorPalette {
95 	UINT Flags;
96 	UINT Count;
97 	ARGB Entries[1];
98 } ColorPalette;
99 
GetPixelFormatSize(PixelFormat pixfmt)100 static __inline__ UINT GetPixelFormatSize(PixelFormat pixfmt)
101 {
102 	return (((UINT) pixfmt) & 0xff00U) >> 8;
103 }
104 
IsAlphaPixelFormat(PixelFormat pixfmt)105 static __inline__ BOOL IsAlphaPixelFormat(PixelFormat pixfmt)
106 {
107 	return (pixfmt & PixelFormatAlpha) != 0;
108 }
109 
IsCanonicalPixelFormat(PixelFormat pixfmt)110 static __inline__ BOOL IsCanonicalPixelFormat(PixelFormat pixfmt)
111 {
112 	return (pixfmt & PixelFormatCanonical) != 0;
113 }
114 
IsExtendedPixelFormat(PixelFormat pixfmt)115 static __inline__ BOOL IsExtendedPixelFormat(PixelFormat pixfmt)
116 {
117 	return (pixfmt & PixelFormatExtended) != 0;
118 }
119 
IsIndexedPixelFormat(PixelFormat pixfmt)120 static __inline__ BOOL IsIndexedPixelFormat(PixelFormat pixfmt)
121 {
122 	return (pixfmt & PixelFormatIndexed) != 0;
123 }
124 
125 #endif /* __GDIPLUS_PIXELFORMATS_H */
126