Main Page | Data Structures | File List | Data Fields | Globals

mr_pnm_io.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "mr_error.h"
#include "mr_pnm_io.h"

Defines

#define PNM_MIN_MAGIC   '1'
#define PNM_MAX_MAGIC   '6'
#define PNM_ONE_BYTE_DEPTH   256
#define PNM_MAX_COLOR_VALUE   65536
#define PNM_MAX_LINE_WIDTH   70
#define PNM_COLOR_SIZE   3
#define PNM_MONO_SIZE   1
#define ONE_BYTE   8
#define PBM_BLACK   1
#define PBM_WHITE   0
#define PNM_GET_NITEMS(pnmtype)   (pnmtype == MR_PBM_RAW || pnmtype == MR_PBM_ASCII ? 2 : 3)
#define PNM_IS_COLOR(pnmtype)   (pnmtype == MR_PPM_ASCII || pnmtype == MR_PPM_RAW)
#define PNM_IS_ASCII(pnmtype)   (pnmtype < MR_PBM_RAW)
#define PNM_IS_DEPTH1(maxval)   (maxval < PNM_ONE_BYTE_DEPTH)
#define PNM_IS_DEPTH2(maxval)   (maxval >= PNM_ONE_BYTE_DEPTH)
#define BIT8   0x01
#define BIT7   0x02
#define BIT6   0x04
#define BIT5   0x08
#define BIT4   0x10
#define BIT3   0x20
#define BIT2   0x40
#define BIT1   0x80
#define IS_BIT_ON(octet, b)   ((octet) & b)
#define SET_BIT_ON(octet, b)   ((octet) | b)
#define SET_BIT_OFF(octet, b)   ((octet) & b)

Functions

static int pnm_alloc_data (MrPNMImage *image)
static void pbm_expand_n_bits (unsigned char *dst, unsigned short int *src, unsigned int n)
static void pbm_group_n_bytes (unsigned char *dst, unsigned short int *src, unsigned int n)
static int pnm_magic_number_fread (FILE *f, MrPNMImage *image)
static int pnm_magic_number_fwrite (FILE *f, MrPNMImage *image)
static int pnm_items_fread (FILE *f, MrPNMImage *image)
static int pnm_items_fwrite (FILE *f, MrPNMImage *image)
static int pnm_ascii_one_line_fread (FILE *f, MrPNMImage *image, unsigned char *p)
static int pnm_ascii_one_line_fwrite (FILE *f, MrPNMImage *image, unsigned char *p)
static int pnm_data_fread (FILE *f, MrPNMImage *image)
static int pnm_data_fwrite (FILE *f, MrPNMImage *image)
static int pnm_fread (FILE *f, MrPNMImage *image)
static int pnm_fwrite (FILE *f, MrPNMImage *image, const char *sign)
MrPNMImagemr_pnm_new ()
void mr_pnm_free (MrPNMImage *img)
MrPNMImagemr_pnm_new_from_file (const char *filename)
int mr_pnm_write_to_file (MrPNMImage *image, const char *filename)
void mr_pnm_draw_horizontal_line (MrPNMImage *pnm_img, unsigned int x, unsigned int y, unsigned int len, unsigned char r, unsigned char g, unsigned char b)
 Draw a horizontal line on a PNM image.
void mr_pnm_draw_rectangle (MrPNMImage *pnm_img, unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char r, unsigned char g, unsigned char b, short int fill)
 Draw a rectangle on a PNM image.

Variables

int mr_pnm_errno = MR_PNM_ELIBC

Define Documentation

#define BIT1   0x80
 

#define BIT2   0x40
 

#define BIT3   0x20
 

#define BIT4   0x10
 

#define BIT5   0x08
 

#define BIT6   0x04
 

#define BIT7   0x02
 

#define BIT8   0x01
 

#define IS_BIT_ON octet,
 )     ((octet) & b)
 

#define ONE_BYTE   8
 

#define PBM_BLACK   1
 

#define PBM_WHITE   0
 

#define PNM_COLOR_SIZE   3
 

#define PNM_GET_NITEMS pnmtype   )     (pnmtype == MR_PBM_RAW || pnmtype == MR_PBM_ASCII ? 2 : 3)
 

#define PNM_IS_ASCII pnmtype   )     (pnmtype < MR_PBM_RAW)
 

#define PNM_IS_COLOR pnmtype   )     (pnmtype == MR_PPM_ASCII || pnmtype == MR_PPM_RAW)
 

#define PNM_IS_DEPTH1 maxval   )     (maxval < PNM_ONE_BYTE_DEPTH)
 

#define PNM_IS_DEPTH2 maxval   )     (maxval >= PNM_ONE_BYTE_DEPTH)
 

#define PNM_MAX_COLOR_VALUE   65536
 

#define PNM_MAX_LINE_WIDTH   70
 

#define PNM_MAX_MAGIC   '6'
 

#define PNM_MIN_MAGIC   '1'
 

#define PNM_MONO_SIZE   1
 

#define PNM_ONE_BYTE_DEPTH   256
 

#define SET_BIT_OFF octet,
 )     ((octet) & b)
 

#define SET_BIT_ON octet,
 )     ((octet) | b)
 


Function Documentation

void mr_pnm_draw_horizontal_line MrPNMImage image,
unsigned int  x,
unsigned int  y,
unsigned int  len,
unsigned char  r,
unsigned char  g,
unsigned char  b
 

Draw a horizontal line on a PNM image.

Parameters:
image the image where draw
x x coordinate of the left extremity
y y coordinate of the left extremity
len the length of the line
r value for the red channel
g value for the green channel
b value for the blue channel

void mr_pnm_draw_rectangle MrPNMImage image,
unsigned int  x,
unsigned int  y,
unsigned int  w,
unsigned int  h,
unsigned char  r,
unsigned char  g,
unsigned char  b,
short int  fill
 

Draw a rectangle on a PNM image.

Parameters:
image the image where draw
x x coordinate of the upper left corner of the rectangle
y y coordinate of the upper left corner of the rectangle
w width of the rectangle
h height of the rectangle
r value for the red channel
g value for the green channel
b value for the blue channel
fill 1 : the rectangle is filled

void mr_pnm_free MrPNMImage img  ) 
 

Destroy a pnm image structure. !!! also destroy the pixels data !!! !!! you can call it with NULL parameter !!!

MrPNMImage* mr_pnm_new  ) 
 

Create a pnm image structure with fields sets to 0.

MrPNMImage* mr_pnm_new_from_file const char *  filename  ) 
 

Get a PNM type image from the specified file. Returns: The PNM image structure or NULL in case of errors.

int mr_pnm_write_to_file MrPNMImage image,
const char *  filename
 

Write a PNM image to a file. Returns: 0 if successfull -1 in case of errors.

static void pbm_expand_n_bits unsigned char *  dst,
unsigned short int *  src,
unsigned int  n
[static]
 

static void pbm_group_n_bytes unsigned char *  dst,
unsigned short int *  src,
unsigned int  n
[static]
 

static int pnm_alloc_data MrPNMImage image  )  [static]
 

static int pnm_ascii_one_line_fread FILE *  f,
MrPNMImage image,
unsigned char *  p
[static]
 

static int pnm_ascii_one_line_fwrite FILE *  f,
MrPNMImage image,
unsigned char *  p
[static]
 

static int pnm_data_fread FILE *  f,
MrPNMImage image
[static]
 

static int pnm_data_fwrite FILE *  f,
MrPNMImage image
[static]
 

static int pnm_fread FILE *  f,
MrPNMImage image
[static]
 

static int pnm_fwrite FILE *  f,
MrPNMImage image,
const char *  sign
[static]
 

static int pnm_items_fread FILE *  f,
MrPNMImage image
[static]
 

static int pnm_items_fwrite FILE *  f,
MrPNMImage image
[static]
 

static int pnm_magic_number_fread FILE *  f,
MrPNMImage image
[static]
 

static int pnm_magic_number_fwrite FILE *  f,
MrPNMImage image
[static]
 


Variable Documentation

int mr_pnm_errno = MR_PNM_ELIBC
 

Integer to indicates what went wrong (i.e. errno). Its value is significant only when the call returned an error (usually -1).


Generated on Sun Apr 9 17:29:41 2006 for MusicReco by  doxygen 1.4.4