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
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
12#include <stdint.h>
13#include <ipxe/image.h>
14
15/** 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 */
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 */
44struct 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 */
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
83extern struct image_type pnm_image_type __image_type ( PROBE_NORMAL );
84
85#endif /* _IPXE_PNM_H */
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
long index
Definition bigint.h:65
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
Executable images.
#define PROBE_NORMAL
Normal image probe priority.
Definition image.h:156
#define __image_type(probe_order)
An executable image type.
Definition image.h:170
#define __attribute__(x)
Definition compiler.h:10
pnm_flags
PNM flags.
Definition pnm.h:70
@ PNM_BITMAP
Bitmap format.
Definition pnm.h:80
An executable image type.
Definition image.h:95
An executable image.
Definition image.h:24
PNM context.
Definition pnm.h:29
unsigned int max
Maximum pixel value.
Definition pnm.h:37
size_t ascii_len
Maximum length of ASCII values.
Definition pnm.h:35
struct pnm_type * type
PNM type.
Definition pnm.h:31
size_t offset
Current byte offset.
Definition pnm.h:33
PNM signature.
Definition pnm.h:16
char type
PNM type.
Definition pnm.h:20
char magic
Magic byte ('P')
Definition pnm.h:18
char space
Whitespace.
Definition pnm.h:22
PNM type.
Definition pnm.h:44
uint8_t packing
Number of pixels per composite value.
Definition pnm.h:50
uint8_t depth
Number of scalar values per pixel.
Definition pnm.h:48
char type
PNM type.
Definition pnm.h:46
int(* scalar)(struct image *image, struct pnm_context *pnm)
Extract scalar value.
Definition pnm.h:59
uint32_t(* rgb)(uint32_t composite, unsigned int index)
Convert composite value to 24-bit RGB.
Definition pnm.h:66
uint8_t flags
Flags.
Definition pnm.h:52