2 * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
31 #include <ipxe/umalloc.h>
32 #include <ipxe/pixbuf.h>
33 #include <ipxe/deflate.h>
38 * Portable Network Graphics (PNG) format
40 * The PNG format is defined in RFC 2083.
45 /** Offset within image */
49 struct pixel_buffer *pixbuf;
54 unsigned int colour_type;
55 /** Number of channels */
56 unsigned int channels;
57 /** Number of interlace passes */
59 /** Palette, in iPXE's pixel buffer format */
60 uint32_t palette[PNG_PALETTE_COUNT];
62 /** Decompression buffer for raw PNG data */
63 struct deflate_chunk raw;
65 struct deflate deflate;
68 /** A PNG interlace pass */
69 struct png_interlace {
72 /** X starting indent */
73 unsigned int x_indent;
74 /** Y starting indent */
75 unsigned int y_indent;
77 unsigned int x_stride;
79 unsigned int y_stride;
86 /** PNG file signature */
87 static struct png_signature png_signature = PNG_SIGNATURE;
89 /** Number of interlacing passes */
90 static uint8_t png_interlace_passes[] = {
91 [PNG_INTERLACE_NONE] = 1,
92 [PNG_INTERLACE_ADAM7] = 7,
96 * Transcribe PNG chunk type name (for debugging)
99 * @ret name Chunk type name
101 static const char * png_type_name ( uint32_t type ) {
104 char name[ sizeof ( uint32_t ) + 1 /* NUL */ ];
112 * Calculate PNG interlace pass parameters
115 * @v pass Pass number (0=first pass)
116 * @v interlace Interlace pass to fill in
118 static void png_interlace ( struct png_context *png, unsigned int pass,
119 struct png_interlace *interlace ) {
120 unsigned int grid_width_log2;
121 unsigned int grid_height_log2;
122 unsigned int x_indent;
123 unsigned int y_indent;
124 unsigned int x_stride_log2;
125 unsigned int y_stride_log2;
126 unsigned int x_stride;
127 unsigned int y_stride;
132 assert ( png->passes > 0 );
134 /* Store pass number */
135 interlace->pass = pass;
137 /* Calculate interlace grid dimensions */
138 grid_width_log2 = ( png->passes / 2 );
139 grid_height_log2 = ( ( png->passes - 1 ) / 2 );
141 /* Calculate starting indents */
142 interlace->x_indent = x_indent =
144 ( 1 << ( grid_width_log2 - ( pass / 2 ) - 1 ) ) : 0 );
145 interlace->y_indent = y_indent =
146 ( ( pass && ! ( pass & 1 ) ) ?
147 ( 1 << ( grid_height_log2 - ( ( pass - 1 ) / 2 ) - 1 ) ) : 0);
149 /* Calculate strides */
150 x_stride_log2 = ( grid_width_log2 - ( pass / 2 ) );
152 ( grid_height_log2 - ( pass ? ( ( pass - 1 ) / 2 ) : 0 ) );
153 interlace->x_stride = x_stride = ( 1 << x_stride_log2 );
154 interlace->y_stride = y_stride = ( 1 << y_stride_log2 );
156 /* Calculate pass dimensions */
157 width = png->pixbuf->width;
158 height = png->pixbuf->height;
160 ( ( width - x_indent + x_stride - 1 ) >> x_stride_log2 );
162 ( ( height - y_indent + y_stride - 1 ) >> y_stride_log2 );
166 * Calculate PNG pixel length
169 * @ret pixel_len Pixel length
171 static unsigned int png_pixel_len ( struct png_context *png ) {
173 return ( ( ( png->channels * png->depth ) + 7 ) / 8 );
177 * Calculate PNG scanline length
180 * @v interlace Interlace pass
181 * @ret scanline_len Scanline length (including filter byte)
183 static size_t png_scanline_len ( struct png_context *png,
184 struct png_interlace *interlace ) {
186 return ( 1 /* Filter byte */ +
187 ( ( interlace->width * png->channels * png->depth ) + 7 ) / 8);
191 * Handle PNG image header chunk
195 * @v len Chunk length
196 * @ret rc Return status code
198 static int png_image_header ( struct image *image, struct png_context *png,
200 struct png_image_header ihdr;
201 struct png_interlace interlace;
205 if ( len != sizeof ( ihdr ) ) {
206 DBGC ( image, "PNG %s invalid IHDR length %zd\n",
211 DBGC ( image, "PNG %s duplicate IHDR\n", image->name );
215 /* Extract image header */
216 copy_from_user ( &ihdr, image->data, png->offset, len );
217 DBGC ( image, "PNG %s %dx%d depth %d type %d compression %d filter %d "
218 "interlace %d\n", image->name, ntohl ( ihdr.width ),
219 ntohl ( ihdr.height ), ihdr.depth, ihdr.colour_type,
220 ihdr.compression, ihdr.filter, ihdr.interlace );
223 if ( ihdr.compression >= PNG_COMPRESSION_UNKNOWN ) {
224 DBGC ( image, "PNG %s unknown compression method %d\n",
225 image->name, ihdr.compression );
228 if ( ihdr.filter >= PNG_FILTER_UNKNOWN ) {
229 DBGC ( image, "PNG %s unknown filter method %d\n",
230 image->name, ihdr.filter );
233 if ( ihdr.interlace >= PNG_INTERLACE_UNKNOWN ) {
234 DBGC ( image, "PNG %s unknown interlace method %d\n",
235 image->name, ihdr.interlace );
239 /* Allocate pixel buffer */
240 png->pixbuf = alloc_pixbuf ( ntohl ( ihdr.width ),
241 ntohl ( ihdr.height ) );
242 if ( ! png->pixbuf ) {
243 DBGC ( image, "PNG %s could not allocate pixel buffer\n",
248 /* Extract bit depth */
249 png->depth = ihdr.depth;
250 if ( ( png->depth == 0 ) ||
251 ( ( png->depth & ( png->depth - 1 ) ) != 0 ) ) {
252 DBGC ( image, "PNG %s invalid depth %d\n",
253 image->name, png->depth );
257 /* Calculate number of channels */
258 png->colour_type = ihdr.colour_type;
260 if ( ! ( ihdr.colour_type & PNG_COLOUR_TYPE_PALETTE ) ) {
261 if ( ihdr.colour_type & PNG_COLOUR_TYPE_RGB )
263 if ( ihdr.colour_type & PNG_COLOUR_TYPE_ALPHA )
267 /* Calculate number of interlace passes */
268 png->passes = png_interlace_passes[ihdr.interlace];
270 /* Calculate length of raw data buffer */
271 for ( pass = 0 ; pass < png->passes ; pass++ ) {
272 png_interlace ( png, pass, &interlace );
273 if ( interlace.width == 0 )
275 png->raw.len += ( interlace.height *
276 png_scanline_len ( png, &interlace ) );
279 /* Allocate raw data buffer */
280 png->raw.data = umalloc ( png->raw.len );
281 if ( ! png->raw.data ) {
282 DBGC ( image, "PNG %s could not allocate data buffer\n",
291 * Handle PNG palette chunk
295 * @v len Chunk length
296 * @ret rc Return status code
298 static int png_palette ( struct image *image, struct png_context *png,
300 size_t offset = png->offset;
301 struct png_palette_entry palette;
304 /* Populate palette */
305 for ( i = 0 ; i < ( sizeof ( png->palette ) /
306 sizeof ( png->palette[0] ) ) ; i++ ) {
308 /* Stop when we run out of palette data */
309 if ( len < sizeof ( palette ) )
312 /* Extract palette entry */
313 copy_from_user ( &palette, image->data, offset,
314 sizeof ( palette ) );
315 png->palette[i] = ( ( palette.red << 16 ) |
316 ( palette.green << 8 ) |
317 ( palette.blue << 0 ) );
318 DBGC2 ( image, "PNG %s palette entry %d is %#06x\n",
319 image->name, i, png->palette[i] );
321 /* Move to next entry */
322 offset += sizeof ( palette );
323 len -= sizeof ( palette );
330 * Handle PNG image data chunk
334 * @v len Chunk length
335 * @ret rc Return status code
337 static int png_image_data ( struct image *image, struct png_context *png,
339 struct deflate_chunk in;
342 /* Deflate this chunk */
343 deflate_chunk_init ( &in, image->data, png->offset,
344 ( png->offset + len ) );
345 if ( ( rc = deflate_inflate ( &png->deflate, &in, &png->raw ) ) != 0 ) {
346 DBGC ( image, "PNG %s could not decompress: %s\n",
347 image->name, strerror ( rc ) );
355 * Unfilter byte using the "None" filter
357 * @v current Filtered current byte
358 * @v left Unfiltered left byte
359 * @v above Unfiltered above byte
360 * @v above_left Unfiltered above-left byte
361 * @ret current Unfiltered current byte
363 static unsigned int png_unfilter_none ( unsigned int current,
364 unsigned int left __unused,
365 unsigned int above __unused,
366 unsigned int above_left __unused ) {
372 * Unfilter byte using the "Sub" filter
374 * @v current Filtered current byte
375 * @v left Unfiltered left byte
376 * @v above Unfiltered above byte
377 * @v above_left Unfiltered above-left byte
378 * @ret current Unfiltered current byte
380 static unsigned int png_unfilter_sub ( unsigned int current,
382 unsigned int above __unused,
383 unsigned int above_left __unused ) {
385 return ( current + left );
389 * Unfilter byte using the "Up" filter
391 * @v current Filtered current byte
392 * @v left Unfiltered left byte
393 * @v above Unfiltered above byte
394 * @v above_left Unfiltered above-left byte
395 * @ret current Unfiltered current byte
397 static unsigned int png_unfilter_up ( unsigned int current,
398 unsigned int left __unused,
400 unsigned int above_left __unused ) {
402 return ( current + above );
406 * Unfilter byte using the "Average" filter
408 * @v current Filtered current byte
409 * @v left Unfiltered left byte
410 * @v above Unfiltered above byte
411 * @v above_left Unfiltered above-left byte
412 * @ret current Unfiltered current byte
414 static unsigned int png_unfilter_average ( unsigned int current,
417 unsigned int above_left __unused ) {
419 return ( current + ( ( above + left ) >> 1 ) );
423 * Paeth predictor function (defined in RFC 2083)
428 * @ret predictor Predictor pixel
430 static unsigned int png_paeth_predictor ( unsigned int a, unsigned int b,
437 /* Algorithm as defined in RFC 2083 section 6.6 */
442 if ( ( pa <= pb ) && ( pa <= pc ) ) {
444 } else if ( pb <= pc ) {
452 * Unfilter byte using the "Paeth" filter
454 * @v current Filtered current byte
455 * @v above_left Unfiltered above-left byte
456 * @v above Unfiltered above byte
457 * @v left Unfiltered left byte
458 * @ret current Unfiltered current byte
460 static unsigned int png_unfilter_paeth ( unsigned int current,
463 unsigned int above_left ) {
465 return ( current + png_paeth_predictor ( left, above, above_left ) );
473 * @v current Filtered current byte
474 * @v left Unfiltered left byte
475 * @v above Unfiltered above byte
476 * @v above_left Unfiltered above-left byte
477 * @ret current Unfiltered current byte
479 unsigned int ( * unfilter ) ( unsigned int current,
482 unsigned int above_left );
485 /** PNG filter types */
486 static struct png_filter png_filters[] = {
487 [PNG_FILTER_BASIC_NONE] = { png_unfilter_none },
488 [PNG_FILTER_BASIC_SUB] = { png_unfilter_sub },
489 [PNG_FILTER_BASIC_UP] = { png_unfilter_up },
490 [PNG_FILTER_BASIC_AVERAGE] = { png_unfilter_average },
491 [PNG_FILTER_BASIC_PAETH] = { png_unfilter_paeth },
495 * Unfilter one interlace pass of PNG raw data
499 * @v interlace Interlace pass
500 * @ret rc Return status code
502 * This routine may assume that it is impossible to overrun the raw
503 * data buffer, since the size is determined by the image dimensions.
505 static int png_unfilter_pass ( struct image *image, struct png_context *png,
506 struct png_interlace *interlace ) {
507 size_t offset = png->raw.offset;
508 size_t pixel_len = png_pixel_len ( png );
509 size_t scanline_len = png_scanline_len ( png, interlace );
510 struct png_filter *filter;
511 unsigned int scanline;
519 /* On the first scanline of a pass, above bytes are assumed to
524 /* Iterate over each scanline in turn */
525 for ( scanline = 0 ; scanline < interlace->height ; scanline++ ) {
527 /* Extract filter byte and determine filter type */
528 copy_from_user ( &filter_type, png->raw.data, offset++,
529 sizeof ( filter_type ) );
530 if ( filter_type >= ( sizeof ( png_filters ) /
531 sizeof ( png_filters[0] ) ) ) {
532 DBGC ( image, "PNG %s unknown filter type %d\n",
533 image->name, filter_type );
536 filter = &png_filters[filter_type];
537 assert ( filter->unfilter != NULL );
538 DBGC2 ( image, "PNG %s pass %d scanline %d filter type %d\n",
539 image->name, interlace->pass, scanline, filter_type );
541 /* At the start of a line, both above-left and left
542 * bytes are taken to be zero.
547 /* Iterate over each byte (not pixel) in turn */
548 for ( byte = 0 ; byte < ( scanline_len - 1 ) ; byte++ ) {
550 /* Extract predictor bytes, if applicable */
551 if ( byte >= pixel_len ) {
552 copy_from_user ( &left, png->raw.data,
553 ( offset - pixel_len ),
556 if ( scanline > 0 ) {
557 copy_from_user ( &above, png->raw.data,
558 ( offset - scanline_len ),
561 if ( ( scanline > 0 ) && ( byte >= pixel_len ) ) {
562 copy_from_user ( &above_left, png->raw.data,
563 ( offset - scanline_len -
565 sizeof ( above_left ) );
568 /* Unfilter current byte */
569 copy_from_user ( ¤t, png->raw.data,
570 offset, sizeof ( current ) );
571 current = filter->unfilter ( current, left, above,
573 copy_to_user ( png->raw.data, offset++,
574 ¤t, sizeof ( current ) );
579 png->raw.offset = offset;
585 * Unfilter PNG raw data
589 * @ret rc Return status code
591 * This routine may assume that it is impossible to overrun the raw
592 * data buffer, since the size is determined by the image dimensions.
594 static int png_unfilter ( struct image *image, struct png_context *png ) {
595 struct png_interlace interlace;
599 /* Process each interlace pass */
601 for ( pass = 0 ; pass < png->passes ; pass++ ) {
603 /* Calculate interlace pass parameters */
604 png_interlace ( png, pass, &interlace );
606 /* Skip zero-width rows (which have no filter bytes) */
607 if ( interlace.width == 0 )
610 /* Unfilter this pass */
611 if ( ( rc = png_unfilter_pass ( image, png,
612 &interlace ) ) != 0 )
615 assert ( png->raw.offset == png->raw.len );
621 * Calculate PNG pixel component value
623 * @v raw Raw component value
624 * @v alpha Alpha value
625 * @v max Maximum raw/alpha value
626 * @ret value Component value in range 0-255
628 static inline unsigned int png_pixel ( unsigned int raw, unsigned int alpha,
631 /* The basic calculation is 255*(raw/max)*(value/max). We use
632 * fixed-point arithmetic (scaling up to the maximum range for
633 * a 32-bit integer), in order to get the same results for
634 * alpha blending as the test cases (produced using
637 return ( ( ( ( ( 0xff00 * raw * alpha ) / max ) / max ) + 0x80 ) >> 8 );
641 * Fill one interlace pass of PNG pixels
645 * @v interlace Interlace pass
647 * This routine may assume that it is impossible to overrun either the
648 * raw data buffer or the pixel buffer, since the sizes of both are
649 * determined by the image dimensions.
651 static void png_pixels_pass ( struct image *image,
652 struct png_context *png,
653 struct png_interlace *interlace ) {
654 size_t raw_offset = png->raw.offset;
655 uint8_t channel[png->channels];
656 int is_indexed = ( png->colour_type & PNG_COLOUR_TYPE_PALETTE );
657 int is_rgb = ( png->colour_type & PNG_COLOUR_TYPE_RGB );
658 int has_alpha = ( png->colour_type & PNG_COLOUR_TYPE_ALPHA );
659 size_t pixbuf_y_offset;
660 size_t pixbuf_offset;
661 size_t pixbuf_x_stride;
662 size_t pixbuf_y_stride;
676 /* We only ever use the top byte of 16-bit pixels. Model this
677 * as a bit depth of 8 with a stride of more than one.
680 raw_stride = ( ( depth + 7 ) / 8 );
683 max = ( ( 1 << depth ) - 1 );
685 /* Calculate pixel buffer offset and strides */
686 pixbuf_y_offset = ( ( ( interlace->y_indent * png->pixbuf->width ) +
687 interlace->x_indent ) * sizeof ( pixel ) );
688 pixbuf_x_stride = ( interlace->x_stride * sizeof ( pixel ) );
689 pixbuf_y_stride = ( interlace->y_stride * png->pixbuf->width *
691 DBGC2 ( image, "PNG %s pass %d %dx%d at (%d,%d) stride (%d,%d)\n",
692 image->name, interlace->pass, interlace->width,
693 interlace->height, interlace->x_indent, interlace->y_indent,
694 interlace->x_stride, interlace->y_stride );
696 /* Iterate over each scanline in turn */
697 for ( y = 0 ; y < interlace->height ; y++ ) {
699 /* Skip filter byte */
702 /* Iterate over each pixel in turn */
704 pixbuf_offset = pixbuf_y_offset;
705 for ( x = 0 ; x < interlace->width ; x++ ) {
707 /* Extract sample value */
708 for ( c = 0 ; c < png->channels ; c++ ) {
710 /* Get sample value into high bits of current */
714 copy_from_user ( ¤t,
717 sizeof ( current ) );
718 raw_offset += raw_stride;
722 /* Extract sample value */
723 channel[c] = ( current >> ( 8 - depth ) );
726 /* Convert to native pixel format */
730 pixel = png->palette[channel[0]];
734 /* Determine alpha value */
735 alpha = ( has_alpha ?
736 channel[ png->channels - 1 ] : max );
738 /* Convert to RGB value */
740 for ( c = 0 ; c < 3 ; c++ ) {
741 raw = channel[ is_rgb ? c : 0 ];
742 value = png_pixel ( raw, alpha, max );
743 assert ( value <= 255 );
744 pixel = ( ( pixel << 8 ) | value );
749 copy_to_user ( png->pixbuf->data, pixbuf_offset,
750 &pixel, sizeof ( pixel ) );
751 pixbuf_offset += pixbuf_x_stride;
754 /* Move to next output row */
755 pixbuf_y_offset += pixbuf_y_stride;
759 png->raw.offset = raw_offset;
768 * This routine may assume that it is impossible to overrun either the
769 * raw data buffer or the pixel buffer, since the sizes of both are
770 * determined by the image dimensions.
772 static void png_pixels ( struct image *image, struct png_context *png ) {
773 struct png_interlace interlace;
776 /* Process each interlace pass */
778 for ( pass = 0 ; pass < png->passes ; pass++ ) {
780 /* Calculate interlace pass parameters */
781 png_interlace ( png, pass, &interlace );
783 /* Skip zero-width rows (which have no filter bytes) */
784 if ( interlace.width == 0 )
787 /* Unfilter this pass */
788 png_pixels_pass ( image, png, &interlace );
790 assert ( png->raw.offset == png->raw.len );
794 * Handle PNG image end chunk
798 * @v len Chunk length
799 * @ret rc Return status code
801 static int png_image_end ( struct image *image, struct png_context *png,
807 DBGC ( image, "PNG %s invalid IEND length %zd\n",
811 if ( ! png->pixbuf ) {
812 DBGC ( image, "PNG %s missing pixel buffer (no IHDR?)\n",
816 if ( ! deflate_finished ( &png->deflate ) ) {
817 DBGC ( image, "PNG %s decompression not complete\n",
821 if ( png->raw.offset != png->raw.len ) {
822 DBGC ( image, "PNG %s incorrect decompressed length (expected "
823 "%zd, got %zd)\n", image->name, png->raw.len,
828 /* Unfilter raw data */
829 if ( ( rc = png_unfilter ( image, png ) ) != 0 )
832 /* Fill pixel buffer */
833 png_pixels ( image, png );
838 /** A PNG chunk handler */
839 struct png_chunk_handler {
847 * @v len Chunk length
848 * @ret rc Return status code
850 int ( * handle ) ( struct image *image, struct png_context *png,
854 /** PNG chunk handlers */
855 static struct png_chunk_handler png_chunk_handlers[] = {
856 { htonl ( PNG_TYPE_IHDR ), png_image_header },
857 { htonl ( PNG_TYPE_PLTE ), png_palette },
858 { htonl ( PNG_TYPE_IDAT ), png_image_data },
859 { htonl ( PNG_TYPE_IEND ), png_image_end },
868 * @v len Chunk length
869 * @ret rc Return status code
871 static int png_chunk ( struct image *image, struct png_context *png,
872 uint32_t type, size_t len ) {
873 struct png_chunk_handler *handler;
876 DBGC ( image, "PNG %s chunk type %s offset %zd length %zd\n",
877 image->name, png_type_name ( type ), png->offset, len );
879 /* Handle according to chunk type */
880 for ( i = 0 ; i < ( sizeof ( png_chunk_handlers ) /
881 sizeof ( png_chunk_handlers[0] ) ) ; i++ ) {
882 handler = &png_chunk_handlers[i];
883 if ( handler->type == type )
884 return handler->handle ( image, png, len );
887 /* Fail if unknown chunk type is critical */
888 if ( ! ( type & htonl ( PNG_CHUNK_ANCILLARY ) ) ) {
889 DBGC ( image, "PNG %s unknown critical chunk type %s\n",
890 image->name, png_type_name ( type ) );
894 /* Ignore non-critical unknown chunk types */
899 * Convert PNG image to pixel buffer
902 * @v pixbuf Pixel buffer to fill in
903 * @ret rc Return status code
905 static int png_pixbuf ( struct image *image, struct pixel_buffer **pixbuf ) {
906 struct png_context *png;
907 struct png_chunk_header header;
908 struct png_chunk_footer footer;
913 /* Allocate and initialise context */
914 png = zalloc ( sizeof ( *png ) );
919 png->offset = sizeof ( struct png_signature );
920 deflate_init ( &png->deflate, DEFLATE_ZLIB );
925 /* Extract chunk header */
926 remaining = ( image->len - png->offset );
927 if ( remaining < sizeof ( header ) ) {
928 DBGC ( image, "PNG %s truncated chunk header at offset "
929 "%zd\n", image->name, png->offset );
933 copy_from_user ( &header, image->data, png->offset,
935 png->offset += sizeof ( header );
937 /* Validate chunk length */
938 chunk_len = ntohl ( header.len );
939 if ( remaining < ( sizeof ( header ) + chunk_len +
940 sizeof ( footer ) ) ) {
941 DBGC ( image, "PNG %s truncated chunk data/footer at "
942 "offset %zd\n", image->name, png->offset );
948 if ( ( rc = png_chunk ( image, png, header.type,
952 /* Move to next chunk */
953 png->offset += ( chunk_len + sizeof ( footer ) );
955 } while ( png->offset < image->len );
957 /* Check that we finished with an IEND chunk */
958 if ( header.type != htonl ( PNG_TYPE_IEND ) ) {
959 DBGC ( image, "PNG %s did not finish with IEND\n",
965 /* Return pixel buffer */
966 *pixbuf = pixbuf_get ( png->pixbuf );
974 pixbuf_put ( png->pixbuf );
975 ufree ( png->raw.data );
985 * @ret rc Return status code
987 static int png_probe ( struct image *image ) {
988 struct png_signature signature;
991 if ( image->len < sizeof ( signature ) ) {
992 DBGC ( image, "PNG %s is too short\n", image->name );
996 /* Check signature */
997 copy_from_user ( &signature, image->data, 0, sizeof ( signature ) );
998 if ( memcmp ( &signature, &png_signature, sizeof ( signature ) ) != 0 ){
999 DBGC ( image, "PNG %s has invalid signature\n", image->name );
1006 /** PNG image type */
1007 struct image_type png_image_type __image_type ( PROBE_NORMAL ) = {
1010 .pixbuf = png_pixbuf,