61 if ( buf[0] ==
'#' ) {
63 }
else if ( !
isspace ( buf[0] ) ) {
77 if (
len > (
sizeof ( buf ) - 1 ) )
78 len = (
sizeof ( buf ) - 1 );
84 pnm->
offset += ( endp - buf );
89 DBGC (
image,
"PNM %s invalid ASCII integer\n",
111 DBGC (
image,
"PNM %s ran out of binary data\n",
132 unsigned int value ) {
135 DBGC (
image,
"PNM %s has out-of-range value %d (max %d)\n",
139 return ( ( 255 *
value ) / pnm->
max );
152 return ( ( ( composite <<
index ) & 0x80 ) ? 0x000000 : 0xffffff );
165 return ( ( composite << 16 ) | ( composite << 8 ) | composite );
193 unsigned int xpos = 0;
200 while ( offset < pixbuf->
len ) {
204 for ( i = 0 ; i <
type->depth ; i++ ) {
211 composite = ( ( composite << 8 ) |
scalar );
215 for ( i = 0 ; i <
type->packing ; i++ ) {
217 DBGC (
image,
"PNM %s has too many pixels\n",
221 rgb =
type->rgb ( composite, i );
225 if ( ++xpos == pixbuf->
width ) {
299 for ( i = 0 ; i < (
sizeof (
pnm_types ) /
354 if ( pnm.
max == 0 ) {
355 DBGC (
image,
"PNM %s has invalid maximum value 0\n",
360 DBGC (
image,
"PNM %s is type %c width %d height %d max %d\n",
367 goto err_alloc_pixbuf;
377 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.
userptr_t data
Raw file image.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
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.
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
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.
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.
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.
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.
static __always_inline void copy_to_user(userptr_t dest, off_t dest_off, const void *src, size_t len)
Copy data to user buffer.
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.
uint16_t offset
Offset to command line.
static uint32_t pnm_greymap(uint32_t composite, unsigned int index __unused)
Convert PNM greymap composite value to RGB.
userptr_t data
32-bit (8:8:8:8) xRGB pixel data, in host-endian order
u8 signature
CPU signature.
#define NULL
NULL pointer (VOID *)
size_t offset
Current byte offset.
uint32_t(* rgb)(uint32_t composite, unsigned int index)
Convert composite value to 24-bit RGB.
static int pnm_data(struct image *image, struct pnm_context *pnm, struct pixel_buffer *pixbuf)
Extract PNM pixel data.