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)
 
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 23 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 72 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 76 of file png.h.

◆ PNG_COLOUR_TYPE_MASK

#define PNG_COLOUR_TYPE_MASK   0x07

PNG colour type mask.

Definition at line 107 of file png.h.

◆ PNG_TYPE_PLTE

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

PNG palette chunk type.

Definition at line 136 of file png.h.

◆ PNG_PALETTE_COUNT

#define PNG_PALETTE_COUNT   256

Maximum number of PNG palette entries.

Definition at line 155 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 158 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 175 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 40 of file png.h.

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

◆ 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 97 of file png.h.

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

◆ 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 110 of file png.h.

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

◆ 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 118 of file png.h.

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

◆ 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 126 of file png.h.

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

◆ 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 161 of file png.h.

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

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ 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 58 of file png.h.

58  {
61 }
Chunk is ancillary.
Definition: png.h:42
#define htonl(value)
Definition: byteswap.h:133
Reserved.
Definition: png.h:46
uint32_t type
Operating system type.
Definition: ena.h:12
Chunk is private.
Definition: png.h:44
Chunk is safe to copy.
Definition: png.h:48

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  )