66{
71 int color_type, bit_depth;
73 int num_trans;
77 int unit_type;
79 int num_palette;
86 int cp_compression;
87
90 {
92 }
93
96 {
99 }
100
101
103 {
106 }
108 png_set_chunk_malloc_max(
png_ptr, 0);
109
110
113 {
115 }
116
117
119
120
122
123
126
127
128 if (bit_depth > 8)
130
131
132 transparency = png_get_tRNS(
png_ptr,
info_ptr, &trans, &num_trans, &trans_values);
133 if (!transparency)
134 num_trans = 0;
135
138 {
139
142 png_set_tRNS_to_alpha(
png_ptr);
144 }
145
146 switch (color_type)
147 {
149
151
153 This->decoder_frame.bpp = bit_depth * 4;
154 switch (bit_depth)
155 {
156 case 8:
158 This->decoder_frame.pixel_format = GUID_WICPixelFormat32bppBGRA;
159 break;
160 case 16:
This->decoder_frame.pixel_format = GUID_WICPixelFormat64bppRGBA;
break;
161 default:
162 ERR(
"invalid RGBA bit depth: %i\n", bit_depth);
165 }
166 break;
168 This->decoder_frame.bpp = bit_depth;
169 if (!transparency)
170 {
171 switch (bit_depth)
172 {
173 case 1:
This->decoder_frame.pixel_format = GUID_WICPixelFormatBlackWhite;
break;
174 case 2:
This->decoder_frame.pixel_format = GUID_WICPixelFormat2bppGray;
break;
175 case 4:
This->decoder_frame.pixel_format = GUID_WICPixelFormat4bppGray;
break;
176 case 8:
This->decoder_frame.pixel_format = GUID_WICPixelFormat8bppGray;
break;
177 case 16:
This->decoder_frame.pixel_format = GUID_WICPixelFormat16bppGray;
break;
178 default:
179 ERR(
"invalid grayscale bit depth: %i\n", bit_depth);
182 }
183 break;
184 }
185
187 This->decoder_frame.bpp = bit_depth;
188 switch (bit_depth)
189 {
190 case 1:
This->decoder_frame.pixel_format = GUID_WICPixelFormat1bppIndexed;
break;
191 case 2:
This->decoder_frame.pixel_format = GUID_WICPixelFormat2bppIndexed;
break;
192 case 4:
This->decoder_frame.pixel_format = GUID_WICPixelFormat4bppIndexed;
break;
193 case 8:
This->decoder_frame.pixel_format = GUID_WICPixelFormat8bppIndexed;
break;
194 default:
195 ERR(
"invalid indexed color bit depth: %i\n", bit_depth);
198 }
199 break;
201 This->decoder_frame.bpp = bit_depth * 3;
202 switch (bit_depth)
203 {
204 case 8:
206 This->decoder_frame.pixel_format = GUID_WICPixelFormat24bppBGR;
207 break;
208 case 16:
This->decoder_frame.pixel_format = GUID_WICPixelFormat48bppRGB;
break;
209 default:
210 ERR(
"invalid RGB color bit depth: %i\n", bit_depth);
213 }
214 break;
215 default:
216 ERR(
"invalid color type %i\n", color_type);
219 }
220
223
225
227 {
228 This->decoder_frame.dpix = xres * 0.0254;
229 This->decoder_frame.dpiy = yres * 0.0254;
230 }
231 else
232 {
233 WARN(
"no pHYs block present\n");
234 This->decoder_frame.dpix =
This->decoder_frame.dpiy = 96.0;
235 }
236
237 ret = png_get_iCCP(
png_ptr,
info_ptr, &cp_name, &cp_compression, &cp_profile, &cp_len);
239 {
240 This->decoder_frame.num_color_contexts = 1;
241 This->color_profile_len = cp_len;
243 if (!
This->color_profile)
244 {
247 }
248 memcpy(
This->color_profile, cp_profile, cp_len);
249 }
250 else
251 This->decoder_frame.num_color_contexts = 0;
252
254 {
257 {
258 ERR(
"paletted image with no PLTE chunk\n");
261 }
262
263 if (num_palette > 256)
264 {
265 ERR(
"palette has %i colors?!\n", num_palette);
268 }
269
270 This->decoder_frame.num_colors = num_palette;
271 for (
i=0;
i<num_palette;
i++)
272 {
274 This->decoder_frame.palette[
i] = (
alpha << 24 |
275 png_palette[
i].
red << 16|
276 png_palette[
i].
green << 8|
277 png_palette[
i].
blue);
278 }
279 }
281 num_palette = 1 << bit_depth;
282
283 This->decoder_frame.num_colors = num_palette;
284 for (
i=0;
i<num_palette;
i++)
285 {
287 BYTE val =
i * 255 / (num_palette - 1);
289 }
290 }
291 else
292 {
293 This->decoder_frame.num_colors = 0;
294 }
295
296 This->stride = (
This->decoder_frame.width *
This->decoder_frame.bpp + 7) / 8;
298
300 if (!
This->image_bits)
301 {
304 }
305
307 if (!row_pointers)
308 {
311 }
312
313 for (
i=0;
i<
This->decoder_frame.height;
i++)
314 row_pointers[
i] =
This->image_bits +
i *
This->stride;
315
316 png_read_image(
png_ptr, row_pointers);
317
320
321
322
327
329
331
336 {
341 }
343}
GLclampf GLclampf GLclampf alpha
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static void user_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
static GLint image_size(GLint width, GLint height, GLenum format, GLenum type)
#define PNG_COLOR_TYPE_RGB
#define PNG_COLOR_TYPE_RGB_ALPHA
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_COLOR_TYPE_GRAY
#define PNG_COLOR_TYPE_PALETTE
#define png_jmpbuf(png_ptr)
#define PNG_CRC_QUIET_USE
#define PNG_RESOLUTION_METER
#define PNG_LIBPNG_VER_STRING
png_const_structrp png_const_inforp info_ptr
@ WICBitmapDecoderCapabilityCanDecodeSomeImages
@ WICBitmapDecoderCapabilityCanEnumerateMetadata
@ WICBitmapDecoderCapabilityCanDecodeAllImages
#define WINCODEC_ERR_UNKNOWNIMAGEFORMAT