iPXE
Data Structures | Macros | Enumerations | Functions
png.h File Reference

Portable Network Graphics (PNG) format. More...

#include <stdint.h>
#include <byteswap.h>
#include <ipxe/image.h>

Go to the source code of this file.

Data Structures

struct  png_signature
 A PNG file signature. More...
 
struct  png_chunk_header
 A PNG chunk header. More...
 
struct  png_chunk_footer
 A PNG chunk footer. More...
 
struct  png_image_header
 A PNG image header. More...
 
struct  png_palette_entry
 A PNG palette entry. More...
 
struct  png_palette
 A PNG palette chunk. More...
 

Macros

#define PNG_SIGNATURE   { { 0x89, 'P', 'N', 'G', '\r', '\n', 0x1a, '\n' } }
 PNG file signature. More...
 
#define PNG_TYPE(first, second, third, fourth)   ( ( (first) << 24 ) | ( (second) << 16 ) | ( (third) << 8 ) | (fourth) )
 Define a canonical PNG chunk type. More...
 
#define PNG_TYPE_IHDR   PNG_TYPE ( 'I', 'H', 'D', 'R' )
 PNG image header chunk type. More...
 
#define PNG_COLOUR_TYPE_MASK   0x07
 PNG colour type mask. More...
 
#define PNG_TYPE_PLTE   PNG_TYPE ( 'P', 'L', 'T', 'E' )
 PNG palette chunk type. More...
 
#define PNG_PALETTE_COUNT   256
 Maximum number of PNG palette entries. More...
 
#define PNG_TYPE_IDAT   PNG_TYPE ( 'I', 'D', 'A', 'T' )
 PNG image data chunk type. More...
 
#define PNG_TYPE_IEND   PNG_TYPE ( 'I', 'E', 'N', 'D' )
 PNG image end chunk type. More...
 

Enumerations

enum  png_chunk_type_bits { PNG_CHUNK_ANCILLARY = 0x20000000UL, PNG_CHUNK_PRIVATE = 0x00200000UL, PNG_CHUNK_RESERVED = 0x00002000UL, PNG_CHUNK_SAFE = 0x00000020UL }
 PNG chunk type property bits. More...
 
enum  png_colour_type { PNG_COLOUR_TYPE_PALETTE = 0x01, PNG_COLOUR_TYPE_RGB = 0x02, PNG_COLOUR_TYPE_ALPHA = 0x04 }
 PNG colour type bits. More...
 
enum  png_compression_method { PNG_COMPRESSION_DEFLATE = 0x00, PNG_COMPRESSION_UNKNOWN = 0x01 }
 PNG compression methods. More...
 
enum  png_filter_method { PNG_FILTER_BASIC = 0x00, PNG_FILTER_UNKNOWN = 0x01 }
 PNG filter methods. More...
 
enum  png_interlace_method { PNG_INTERLACE_NONE = 0x00, PNG_INTERLACE_ADAM7 = 0x01, PNG_INTERLACE_UNKNOWN = 0x02 }
 PNG interlace methods. More...
 
enum  png_basic_filter_type {
  PNG_FILTER_BASIC_NONE = 0, PNG_FILTER_BASIC_SUB = 1, PNG_FILTER_BASIC_UP = 2, PNG_FILTER_BASIC_AVERAGE = 3,
  PNG_FILTER_BASIC_PAETH = 4
}
 PNG basic filter types. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 FILE_SECBOOT (PERMITTED)
 
static uint32_t png_canonical_type (uint32_t type)
 Canonicalise PNG chunk type. More...
 
struct image_type png_image_type __image_type (PROBE_NORMAL)
 

Detailed Description

Portable Network Graphics (PNG) format.

Definition in file png.h.

Macro Definition Documentation

◆ PNG_SIGNATURE

#define PNG_SIGNATURE   { { 0x89, 'P', 'N', 'G', '\r', '\n', 0x1a, '\n' } }

PNG file signature.

Definition at line 24 of file png.h.

◆ PNG_TYPE

#define PNG_TYPE (   first,
  second,
  third,
  fourth 
)    ( ( (first) << 24 ) | ( (second) << 16 ) | ( (third) << 8 ) | (fourth) )

Define a canonical PNG chunk type.

Parameters
firstFirst letter (in upper case)
secondSecond letter (in upper case)
thirdThird letter (in upper case)
fourthFourth letter (in upper case)
Return values
typeCanonical chunk type

Definition at line 73 of file png.h.

◆ PNG_TYPE_IHDR

#define PNG_TYPE_IHDR   PNG_TYPE ( 'I', 'H', 'D', 'R' )

PNG image header chunk type.

Definition at line 77 of file png.h.

◆ PNG_COLOUR_TYPE_MASK

#define PNG_COLOUR_TYPE_MASK   0x07

PNG colour type mask.

Definition at line 108 of file png.h.

◆ PNG_TYPE_PLTE

#define PNG_TYPE_PLTE   PNG_TYPE ( 'P', 'L', 'T', 'E' )

PNG palette chunk type.

Definition at line 137 of file png.h.

◆ PNG_PALETTE_COUNT

#define PNG_PALETTE_COUNT   256

Maximum number of PNG palette entries.

Definition at line 156 of file png.h.

◆ PNG_TYPE_IDAT

#define PNG_TYPE_IDAT   PNG_TYPE ( 'I', 'D', 'A', 'T' )

PNG image data chunk type.

Definition at line 159 of file png.h.

◆ PNG_TYPE_IEND

#define PNG_TYPE_IEND   PNG_TYPE ( 'I', 'E', 'N', 'D' )

PNG image end chunk type.

Definition at line 176 of file png.h.

Enumeration Type Documentation

◆ png_chunk_type_bits

PNG chunk type property bits.

Enumerator
PNG_CHUNK_ANCILLARY 

Chunk is ancillary.

PNG_CHUNK_PRIVATE 

Chunk is private.

PNG_CHUNK_RESERVED 

Reserved.

PNG_CHUNK_SAFE 

Chunk is safe to copy.

Definition at line 41 of file png.h.

41  {
42  /** Chunk is ancillary */
43  PNG_CHUNK_ANCILLARY = 0x20000000UL,
44  /** Chunk is private */
45  PNG_CHUNK_PRIVATE = 0x00200000UL,
46  /** Reserved */
47  PNG_CHUNK_RESERVED = 0x00002000UL,
48  /** Chunk is safe to copy */
49  PNG_CHUNK_SAFE = 0x00000020UL,
50 };
Chunk is ancillary.
Definition: png.h:43
Reserved.
Definition: png.h:47
Chunk is private.
Definition: png.h:45
Chunk is safe to copy.
Definition: png.h:49

◆ png_colour_type

PNG colour type bits.

Enumerator
PNG_COLOUR_TYPE_PALETTE 

Palette is used.

PNG_COLOUR_TYPE_RGB 

RGB colour is used.

PNG_COLOUR_TYPE_ALPHA 

Alpha channel is used.

Definition at line 98 of file png.h.

98  {
99  /** Palette is used */
101  /** RGB colour is used */
102  PNG_COLOUR_TYPE_RGB = 0x02,
103  /** Alpha channel is used */
104  PNG_COLOUR_TYPE_ALPHA = 0x04,
105 };
RGB colour is used.
Definition: png.h:102
Alpha channel is used.
Definition: png.h:104
Palette is used.
Definition: png.h:100

◆ png_compression_method

PNG compression methods.

Enumerator
PNG_COMPRESSION_DEFLATE 

DEFLATE compression with 32kB sliding window.

PNG_COMPRESSION_UNKNOWN 

First unknown compression method.

Definition at line 111 of file png.h.

111  {
112  /** DEFLATE compression with 32kB sliding window */
114  /** First unknown compression method */
116 };
DEFLATE compression with 32kB sliding window.
Definition: png.h:113
First unknown compression method.
Definition: png.h:115

◆ png_filter_method

PNG filter methods.

Enumerator
PNG_FILTER_BASIC 

Adaptive filtering with five basic types.

PNG_FILTER_UNKNOWN 

First unknown filter method.

Definition at line 119 of file png.h.

119  {
120  /** Adaptive filtering with five basic types */
121  PNG_FILTER_BASIC = 0x00,
122  /** First unknown filter method */
123  PNG_FILTER_UNKNOWN = 0x01,
124 };
First unknown filter method.
Definition: png.h:123
Adaptive filtering with five basic types.
Definition: png.h:121

◆ png_interlace_method

PNG interlace methods.

Enumerator
PNG_INTERLACE_NONE 

No interlacing.

PNG_INTERLACE_ADAM7 

Adam7 interlacing.

PNG_INTERLACE_UNKNOWN 

First unknown interlace method.

Definition at line 127 of file png.h.

127  {
128  /** No interlacing */
129  PNG_INTERLACE_NONE = 0x00,
130  /** Adam7 interlacing */
131  PNG_INTERLACE_ADAM7 = 0x01,
132  /** First unknown interlace method */
133  PNG_INTERLACE_UNKNOWN = 0x02,
134 };
Adam7 interlacing.
Definition: png.h:131
No interlacing.
Definition: png.h:129
First unknown interlace method.
Definition: png.h:133

◆ png_basic_filter_type

PNG basic filter types.

Enumerator
PNG_FILTER_BASIC_NONE 

No filtering.

PNG_FILTER_BASIC_SUB 

Left byte used as predictor.

PNG_FILTER_BASIC_UP 

Above byte used as predictor.

PNG_FILTER_BASIC_AVERAGE 

Above and left bytes used as predictors.

PNG_FILTER_BASIC_PAETH 

Paeth filter.

Definition at line 162 of file png.h.

162  {
163  /** No filtering */
165  /** Left byte used as predictor */
167  /** Above byte used as predictor */
169  /** Above and left bytes used as predictors */
171  /** Paeth filter */
173 };
No filtering.
Definition: png.h:164
Above byte used as predictor.
Definition: png.h:168
Above and left bytes used as predictors.
Definition: png.h:170
Paeth filter.
Definition: png.h:172
Left byte used as predictor.
Definition: png.h:166

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ png_canonical_type()

static uint32_t png_canonical_type ( uint32_t  type)
inlinestatic

Canonicalise PNG chunk type.

Parameters
typeRaw chunk type
Return values
typeCanonicalised chunk type (excluding property bits)

Definition at line 59 of file png.h.

59  {
62 }
Chunk is ancillary.
Definition: png.h:43
uint32_t type
Operating system type.
Definition: ena.h:12
#define htonl(value)
Definition: byteswap.h:134
Reserved.
Definition: png.h:47
Chunk is private.
Definition: png.h:45
Chunk is safe to copy.
Definition: png.h:49

References htonl, PNG_CHUNK_ANCILLARY, PNG_CHUNK_PRIVATE, PNG_CHUNK_RESERVED, PNG_CHUNK_SAFE, and type.

◆ __image_type()

struct image_type png_image_type __image_type ( PROBE_NORMAL  )