iPXE
pnm.h
Go to the documentation of this file.
1 #ifndef _IPXE_PNM_H
2 #define _IPXE_PNM_H
3 
4 /** @file
5  *
6  * Portable anymap format (PNM)
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <ipxe/image.h>
14 
15 /** PNM signature */
16 struct pnm_signature {
17  /** Magic byte ('P') */
18  char magic;
19  /** PNM type */
20  char type;
21  /** Whitespace */
22  char space;
23 } __attribute__ (( packed ));
24 
25 /** PNM magic byte */
26 #define PNM_MAGIC 'P'
27 
28 /** PNM context */
29 struct pnm_context {
30  /** PNM type */
31  struct pnm_type *type;
32  /** Current byte offset */
33  size_t offset;
34  /** Maximum length of ASCII values */
35  size_t ascii_len;
36  /** Maximum pixel value */
37  unsigned int max;
38 };
39 
40 /** Default maximum length of ASCII values */
41 #define PNM_ASCII_LEN 16
42 
43 /** PNM type */
44 struct pnm_type {
45  /** PNM type */
46  char type;
47  /** Number of scalar values per pixel */
49  /** Number of pixels per composite value */
51  /** Flags */
53  /** Extract scalar value
54  *
55  * @v image PNM image
56  * @v pnm PNM context
57  * @ret value Value, or negative error
58  */
59  int ( * scalar ) ( struct image *image, struct pnm_context *pnm );
60  /** Convert composite value to 24-bit RGB
61  *
62  * @v composite Composite value
63  * @v index Pixel index within this composite value
64  * @ret rgb 24-bit RGB value
65  */
66  uint32_t ( * rgb ) ( uint32_t composite, unsigned int index );
67 };
68 
69 /** PNM flags */
70 enum pnm_flags {
71  /** Bitmap format
72  *
73  * If set, this flag indicates that:
74  *
75  * - the maximum scalar value is predefined as being equal to
76  * (2^packing-1), and is not present within the file, and
77  *
78  * - the maximum length of ASCII values is 1.
79  */
80  PNM_BITMAP = 0x01,
81 };
82 
83 extern struct image_type pnm_image_type __image_type ( PROBE_NORMAL );
84 
85 #endif /* _IPXE_PNM_H */
#define __attribute__(x)
Definition: compiler.h:10
char space
Whitespace.
Definition: pnm.h:22
int(* scalar)(struct image *image, struct pnm_context *pnm)
Extract scalar value.
Definition: pnm.h:59
uint8_t flags
Flags.
Definition: pnm.h:52
struct image_type pnm_image_type __image_type(PROBE_NORMAL)
An executable image type.
Definition: image.h:94
long index
Definition: bigint.h:62
#define PROBE_NORMAL
Normal image probe priority.
Definition: image.h:155
char type
PNM type.
Definition: pnm.h:20
An executable image.
Definition: image.h:23
unsigned int max
Maximum pixel value.
Definition: pnm.h:37
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
pnm_flags
PNM flags.
Definition: pnm.h:70
Executable images.
size_t ascii_len
Maximum length of ASCII values.
Definition: pnm.h:35
uint8_t packing
Number of pixels per composite value.
Definition: pnm.h:50
unsigned char uint8_t
Definition: stdint.h:10
PNM type.
Definition: pnm.h:44
unsigned int uint32_t
Definition: stdint.h:12
struct pnm_type * type
PNM type.
Definition: pnm.h:31
PNM signature.
Definition: pnm.h:16
char type
PNM type.
Definition: pnm.h:46
char magic
Magic byte ('P')
Definition: pnm.h:18
Bitmap format.
Definition: pnm.h:80
uint8_t depth
Number of scalar values per pixel.
Definition: pnm.h:48
size_t offset
Current byte offset.
Definition: pnm.h:33
uint32_t(* rgb)(uint32_t composite, unsigned int index)
Convert composite value to 24-bit RGB.
Definition: pnm.h:66
PNM context.
Definition: pnm.h:29