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 ) /
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",
363 goto err_alloc_pixbuf;
373 pixbuf_put ( *pixbuf );
#define EINVAL
Invalid argument.
static int pnm_probe(struct image *image)
Probe PNM image.
struct arbelprm_rc_send_wqe rc
struct pixel_buffer * alloc_pixbuf(unsigned int width, unsigned int height)
Allocate pixel buffer.
int(* scalar)(struct image *image, struct pnm_context *pnm)
Extract scalar value.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
const void * data
Read-only data.
static int pnm_binary(struct image *image, struct pnm_context *pnm)
Extract PNM binary value.
#define ENOEXEC
Exec format error.
#define PNM_ASCII_LEN
Default maximum length of ASCII values.
uint32_t type
Operating system type.
struct image_type pnm_image_type __image_type(PROBE_NORMAL)
PNM image type.
An executable image type.
static struct pnm_type * pnm_type(struct image *image)
Determine PNM image type.
#define PROBE_NORMAL
Normal image probe priority.
unsigned int pixels
Total number of pixels.
static struct pnm_type pnm_types[]
PNM image types.
unsigned int max
Maximum pixel value.
char * name
Name of this image type.
#define ENOTSUP
Operation not supported.
static int isdigit(int character)
Check if character is a decimal digit.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
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.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
pseudo_bit_t value[0x00020]
#define __unused
Declare a variable or data structure as unused.
uint32_t * data
32-bit (8:8:8:8) xRGB pixel data, in host-endian order
static int pnm_ascii(struct image *image, struct pnm_context *pnm)
Extract PNM ASCII value.
size_t ascii_len
Maximum length of ASCII values.
static uint32_t pnm_bitmap(uint32_t composite, unsigned int index)
Convert PNM bitmap composite value to RGB.
size_t len
Length of raw file image.
uint8_t packing
Number of pixels per composite value.
int isspace(int character)
Check to see if character is a space.
struct pnm_type * type
PNM type.
static int pnm_scale(struct image *image, struct pnm_context *pnm, unsigned int value)
Scale PNM scalar value.
Portable anymap format (PNM)
int(* pixbuf)(struct image *image, struct pixel_buffer **pixbuf)
Create pixel buffer from image.
#define PNM_MAGIC
PNM magic byte.
static uint32_t pnm_greymap(uint32_t composite, unsigned int index __unused)
Convert PNM greymap composite value to RGB.
u8 signature
CPU signature.
#define NULL
NULL pointer (VOID *)
size_t offset
Current byte offset.
static int pnm_data(struct image *image, struct pnm_context *pnm, struct pixel_buffer *pixbuf)
Extract PNM pixel data.