iPXE
pnm.h
Go to the documentation of this file.
00001 #ifndef _IPXE_PNM_H
00002 #define _IPXE_PNM_H
00003 
00004 /** @file
00005  *
00006  * Portable anymap format (PNM)
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/uaccess.h>
00014 #include <ipxe/image.h>
00015 
00016 /** PNM signature */
00017 struct pnm_signature {
00018         /** Magic byte ('P') */
00019         char magic;
00020         /** PNM type */
00021         char type;
00022         /** Whitespace */
00023         char space;
00024 } __attribute__ (( packed ));
00025 
00026 /** PNM magic byte */
00027 #define PNM_MAGIC 'P'
00028 
00029 /** PNM context */
00030 struct pnm_context {
00031         /** PNM type */
00032         struct pnm_type *type;
00033         /** Current byte offset */
00034         size_t offset;
00035         /** Maximum length of ASCII values */
00036         size_t ascii_len;
00037         /** Maximum pixel value */
00038         unsigned int max;
00039 };
00040 
00041 /** Default maximum length of ASCII values */
00042 #define PNM_ASCII_LEN 16
00043 
00044 /** PNM type */
00045 struct pnm_type {
00046         /** PNM type */
00047         char type;
00048         /** Number of scalar values per pixel */
00049         uint8_t depth;
00050         /** Number of pixels per composite value */
00051         uint8_t packing;
00052         /** Flags */
00053         uint8_t flags;
00054         /** Extract scalar value
00055          *
00056          * @v image             PNM image
00057          * @v pnm               PNM context
00058          * @ret value           Value, or negative error
00059          */
00060         int ( * scalar ) ( struct image *image, struct pnm_context *pnm );
00061         /** Convert composite value to 24-bit RGB
00062          *
00063          * @v composite         Composite value
00064          * @v index             Pixel index within this composite value
00065          * @ret rgb             24-bit RGB value
00066          */
00067         uint32_t ( * rgb ) ( uint32_t composite, unsigned int index );
00068 };
00069 
00070 /** PNM flags */
00071 enum pnm_flags {
00072         /** Bitmap format
00073          *
00074          * If set, this flag indicates that:
00075          *
00076          * - the maximum scalar value is predefined as being equal to
00077          *   (2^packing-1), and is not present within the file, and
00078          *
00079          * - the maximum length of ASCII values is 1.
00080          */
00081         PNM_BITMAP = 0x01,
00082 };
00083 
00084 extern struct image_type pnm_image_type __image_type ( PROBE_NORMAL );
00085 
00086 #endif /* _IPXE_PNM_H */