78 if (
len > (
sizeof ( buf ) - 1 ) )
79 len = (
sizeof ( buf ) - 1 );
85 pnm->
offset += ( endp - buf );
90 DBGC (
image,
"PNM %s invalid ASCII integer\n",
112 DBGC (
image,
"PNM %s ran out of binary data\n",
131 unsigned int value ) {
134 DBGC (
image,
"PNM %s has out-of-range value %d (max %d)\n",
138 return ( ( 255 *
value ) / pnm->
max );
151 return ( ( ( composite <<
index ) & 0x80 ) ? 0x000000 : 0xffffff );
164 return ( ( composite << 16 ) | ( composite << 8 ) | composite );
191 unsigned int pixels = pixbuf->
pixels;
192 unsigned int index = 0;
193 unsigned int xpos = 0;
199 while (
index < pixels ) {
203 for ( i = 0 ; i <
type->depth ; i++ ) {
210 composite = ( ( composite << 8 ) |
scalar );
214 for ( i = 0 ; i <
type->packing ; i++ ) {
215 if (
index >= pixels ) {
216 DBGC (
image,
"PNM %s has too many pixels\n",
221 if ( ++xpos == pixbuf->
width ) {
295 for ( i = 0 ; i < (
sizeof (
pnm_types ) /
341 pnm.max = ( ( 1 << pnm.type->packing ) - 1 );
344 if ( ( max = pnm_ascii ( image, &pnm ) ) < 0 ) {
350 if ( pnm.max == 0 ) {
351 DBGC ( image,
"PNM %s has invalid maximum value 0\n",
356 DBGC (
image,
"PNM %s is type %c width %d height %d max %d\n",
357 image->
name, pnm.type->type, width, height, pnm.max );
363 goto err_alloc_pixbuf;
373 pixbuf_put ( *pixbuf );
#define NULL
NULL pointer (VOID *)
u8 signature
CPU signature.
struct arbelprm_rc_send_wqe rc
pseudo_bit_t value[0x00020]
#define assert(condition)
Assert a condition at run-time.
int isspace(int character)
Check to see if character is a space.
static int isdigit(int character)
Check if character is a decimal digit.
uint32_t type
Operating system type.
#define __unused
Declare a variable or data structure as unused.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define EINVAL
Invalid argument.
#define ENOEXEC
Exec format error.
#define ENOMEM
Not enough space.
#define ENOTSUP
Operation not supported.
#define PROBE_NORMAL
Normal image probe priority.
#define __image_type(probe_order)
An executable image type.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct pixel_buffer * alloc_pixbuf(unsigned int width, unsigned int height)
Allocate pixel buffer.
static int pnm_ascii(struct image *image, struct pnm_context *pnm)
Extract PNM ASCII value.
static struct pnm_type * pnm_type(struct image *image)
Determine PNM image type.
static int pnm_scale(struct image *image, struct pnm_context *pnm, unsigned int value)
Scale PNM scalar value.
static int pnm_probe(struct image *image)
Probe PNM image.
static struct pnm_type pnm_types[]
PNM image types.
static int pnm_pixbuf(struct image *image, struct pixel_buffer **pixbuf)
Convert PNM image to pixel buffer.
static uint32_t pnm_pixmap(uint32_t composite, unsigned int index __unused)
Convert PNM pixmap composite value to RGB.
static uint32_t pnm_greymap(uint32_t composite, unsigned int index __unused)
Convert PNM greymap composite value to RGB.
static int pnm_data(struct image *image, struct pnm_context *pnm, struct pixel_buffer *pixbuf)
Extract PNM pixel data.
static int pnm_binary(struct image *image, struct pnm_context *pnm)
Extract PNM binary value.
static uint32_t pnm_bitmap(uint32_t composite, unsigned int index)
Convert PNM bitmap composite value to RGB.
Portable anymap format (PNM)
#define PNM_ASCII_LEN
Default maximum length of ASCII values.
@ PNM_BITMAP
Bitmap format.
#define PNM_MAGIC
PNM magic byte.
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
An executable image type.
const void * data
Read-only data.
size_t len
Length of raw file image.
unsigned int pixels
Total number of pixels.
uint32_t * data
32-bit (8:8:8:8) xRGB pixel data, in host-endian order
unsigned int max
Maximum pixel value.
size_t ascii_len
Maximum length of ASCII values.
struct pnm_type * type
PNM type.
size_t offset
Current byte offset.
int(* scalar)(struct image *image, struct pnm_context *pnm)
Extract scalar value.