Portable anymap format (PNM)
Definition in file pnm.c.
Extract PNM ASCII value.
- Parameters
-
image | PNM image |
pnm | PNM context |
- Return values
-
value | Value, or negative error |
Definition at line 46 of file pnm.c.
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",
#define EINVAL
Invalid argument.
userptr_t data
Raw file image.
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
pseudo_bit_t value[0x00020]
size_t ascii_len
Maximum length of ASCII values.
size_t len
Length of raw file image.
int isspace(int character)
Check to see if character is a space.
size_t offset
Current byte offset.
References pnm_context::ascii_len, copy_from_user(), image::data, DBGC, EINVAL, isspace(), len, image::len, image::name, pnm_context::offset, strtoul(), and value.
Referenced by pnm_pixbuf().
Extract PNM pixel data.
- Parameters
-
image | PNM image |
pnm | PNM context |
pixbuf | Pixel buffer |
- Return values
-
Definition at line 189 of file pnm.c.
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 ) {
#define EINVAL
Invalid argument.
int(* scalar)(struct image *image, struct pnm_context *pnm)
Extract scalar value.
uint32_t type
Operating system type.
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.
struct pnm_type * type
PNM type.
static int pnm_scale(struct image *image, struct pnm_context *pnm, unsigned int value)
Scale PNM scalar value.
uint16_t offset
Offset to command line.
userptr_t data
32-bit (8:8:8:8) xRGB pixel data, in host-endian order
uint32_t(* rgb)(uint32_t composite, unsigned int index)
Convert composite value to 24-bit RGB.
References copy_to_user(), pixel_buffer::data, DBGC, EINVAL, len, pixel_buffer::len, image::name, offset, pnm_scale(), pnm_type::rgb, pnm_type::scalar, type, pnm_context::type, and pixel_buffer::width.
Referenced by pnm_pixbuf().
Convert PNM image to pixel buffer.
- Parameters
-
image | PNM image |
pixbuf | Pixel buffer to fill in |
- Return values
-
Definition at line 315 of file pnm.c.
345 pnm.max = ( ( 1 << pnm.type->packing ) - 1 );
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",
361 image->
name, pnm.type->type, width, height, pnm.max );
367 goto err_alloc_pixbuf;
377 pixbuf_put ( *pixbuf );
#define EINVAL
Invalid argument.
struct arbelprm_rc_send_wqe rc
struct pixel_buffer * alloc_pixbuf(unsigned int width, unsigned int height)
Allocate pixel buffer.
#define PNM_ASCII_LEN
Default maximum length of ASCII values.
static struct pnm_type * pnm_type(struct image *image)
Determine PNM image type.
#define ENOTSUP
Operation not supported.
#define ENOMEM
Not enough space.
static int pnm_ascii(struct image *image, struct pnm_context *pnm)
Extract PNM ASCII value.
static int pnm_data(struct image *image, struct pnm_context *pnm, struct pixel_buffer *pixbuf)
Extract PNM pixel data.
References alloc_pixbuf(), pnm_context::ascii_len, DBGC, EINVAL, ENOMEM, ENOTSUP, pnm_type::flags, pnm_context::max, max, image::name, pnm_context::offset, pnm_type::packing, pnm_ascii(), PNM_ASCII_LEN, PNM_BITMAP, pnm_data(), pnm_type(), rc, pnm_context::type, and pnm_type::type.