BRL-CAD
ppm.c File Reference
#include "common.h"
#include <string.h>
#include "bu/log.h"
#include "bu/malloc.h"
#include "icv.h"
Include dependency graph for ppm.c:

Go to the source code of this file.

Functions

unsigned char * data2uchar (const icv_image_t *bif)
 
double * uchar2double (unsigned char *data, long int size)
 
int image_flip (unsigned char *buf, int width, int height)
 
int ppm_write (icv_image_t *bif, const char *filename)
 
HIDDEN void ppm_nextline (FILE *fp)
 
icv_image_tppm_read (const char *filename)
 

Detailed Description

This file contains reading and writing routines for ppm format.

Definition in file ppm.c.

Function Documentation

unsigned char* data2uchar ( const icv_image_t bif)

Converts double data of icv_image to unsigned char data. This function also does gamma correction using the gamma_corr parameter of the image structure.

This is mainly used for saving pix, bw and ppm type images. Gamma correction prevents bad color aliasing.

Definition at line 79 of file encoding.c.

References bn_rand0to1, bn_rand_init, bu_malloc(), icv_image::channels, icv_image::data, icv_image::gamma_corr, icv_image::height, ICV_IMAGE_VAL_PTR, icv_image::width, and ZERO.

Referenced by ppm_write().

Here is the call graph for this function:

double* uchar2double ( unsigned char *  data,
long int  size 
)

Referenced by ppm_read().

int image_flip ( unsigned char *  buf,
int  width,
int  height 
)

Definition at line 39 of file ppm.c.

References bu_free(), and bu_malloc().

Referenced by ppm_read(), and ppm_write().

Here is the call graph for this function:

int ppm_write ( icv_image_t bif,
const char *  filename 
)

Definition at line 54 of file ppm.c.

References bu_log(), icv_image::color_space, data, data2uchar(), icv_image::height, ICV_COLOR_SPACE_GRAY, ICV_COLOR_SPACE_RGB, icv_gray2rgb(), image_flip(), and icv_image::width.

Referenced by icv_write().

Here is the call graph for this function:

HIDDEN void ppm_nextline ( FILE *  fp)

Definition at line 90 of file ppm.c.

Referenced by ppm_read().

icv_image_t* ppm_read ( const char *  filename)

Definition at line 111 of file ppm.c.

References BU_ALLOC, bu_fgets(), bu_free(), bu_log(), bu_malloc(), icv_image::channels, icv_image::color_space, data, icv_image::data, icv_image::height, ICV_COLOR_SPACE_RGB, ICV_IMAGE_INIT, ICV_IMAGE_MAGIC, image_flip(), icv_image::magic, ppm_nextline(), uchar2double(), and icv_image::width.

Referenced by icv_read().

Here is the call graph for this function: