You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pnm.h 1.7KB

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