BRL-CAD
fileformat.c File Reference
#include "common.h"
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <png.h>
#include "bio.h"
#include "bu/str.h"
#include "bu/log.h"
#include "bu/malloc.h"
#include "bn.h"
#include "vmath.h"
#include "icv.h"
Include dependency graph for fileformat.c:

Go to the source code of this file.

Macros

#define WRMODE   S_IRUSR|S_IRGRP|S_IROTH
 
#define CMP(name)   if (!bu_strncmp(filename, #name":", strlen(#name))) {bu_strlcpy(trimmedname, filename+strlen(#name)+1, BUFSIZ);return ICV_IMAGE_##name; }
 
#define CMP(name, ext)   if (!bu_strncmp(filename+strlen(filename)-strlen(#name)-1, "."#ext, strlen(#name)+1)) return ICV_IMAGE_##name;
 

Functions

FILE * fdopen (int, const char *)
 
double * uchar2double (unsigned char *data, long int size)
 
unsigned char * data2uchar (const icv_image_t *bif)
 
int bw_write (icv_image_t *bif, const char *filename)
 
icv_image_tbw_read (const char *filename, int width, int height)
 
int pix_write (icv_image_t *bif, const char *filename)
 
icv_image_tpix_read (const char *filename, int width, int height)
 
icv_image_tdpix_read (const char *filename, int width, int height)
 
int dpix_write (icv_image_t *bif, const char *filename)
 
int ppm_write (icv_image_t *bif, const char *filename)
 
icv_image_tppm_read (const char *filename)
 
ICV_IMAGE_FORMAT icv_guess_file_format (const char *filename, char *trimmedname)
 
HIDDEN int png_write (icv_image_t *bif, const char *filename)
 
icv_image_ticv_read (const char *filename, int format, int width, int height)
 
int icv_write (icv_image_t *bif, const char *filename, ICV_IMAGE_FORMAT format)
 
int icv_writeline (icv_image_t *bif, int y, void *data, ICV_DATA type)
 
int icv_writepixel (icv_image_t *bif, int x, int y, double *data)
 
icv_image_ticv_create (int width, int height, ICV_COLOR_SPACE color_space)
 
icv_image_ticv_zero (icv_image_t *bif)
 
int icv_destroy (icv_image_t *bif)
 

Detailed Description

image read/write routines

read/write images in a variety of formats.

Definition in file fileformat.c.

Macro Definition Documentation

#define WRMODE   S_IRUSR|S_IRGRP|S_IROTH

Definition at line 45 of file fileformat.c.

#define CMP (   name)    if (!bu_strncmp(filename, #name":", strlen(#name))) {bu_strlcpy(trimmedname, filename+strlen(#name)+1, BUFSIZ);return ICV_IMAGE_##name; }

Referenced by icv_guess_file_format().

#define CMP (   name,
  ext 
)    if (!bu_strncmp(filename+strlen(filename)-strlen(#name)-1, "."#ext, strlen(#name)+1)) return ICV_IMAGE_##name;

Function Documentation

FILE* fdopen ( int  ,
const char *   
)
double* uchar2double ( unsigned char *  data,
long int  size 
)
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.

Referenced by png_write().

int bw_write ( icv_image_t bif,
const char *  filename 
)

Definition at line 35 of file bw.c.

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

Referenced by icv_write().

Here is the call graph for this function:

icv_image_t* bw_read ( const char *  filename,
int  width,
int  height 
)

Definition at line 74 of file bw.c.

References BU_ALLOC, bu_free(), bu_log(), bu_malloc(), bu_realloc(), icv_image::channels, icv_image::color_space, data, icv_image::data, icv_image::gamma_corr, icv_image::height, ICV_COLOR_SPACE_GRAY, ICV_IMAGE_INIT, ICV_IMAGE_MAGIC, icv_image::magic, uchar2double(), icv_image::width, and OSL::Strings::width.

Referenced by icv_read().

Here is the call graph for this function:

int pix_write ( icv_image_t bif,
const char *  filename 
)

Definition at line 34 of file pix.c.

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

Referenced by icv_write().

Here is the call graph for this function:

icv_image_t* pix_read ( const char *  filename,
int  width,
int  height 
)

Definition at line 67 of file pix.c.

References BU_ALLOC, bu_free(), bu_log(), bu_malloc(), bu_realloc(), icv_image::channels, icv_image::color_space, data, icv_image::data, icv_image::height, ICV_COLOR_SPACE_RGB, ICV_IMAGE_INIT, ICV_IMAGE_MAGIC, icv_image::magic, uchar2double(), icv_image::width, and OSL::Strings::width.

Referenced by icv_read().

Here is the call graph for this function:

icv_image_t* dpix_read ( const char *  filename,
int  width,
int  height 
)

Definition at line 87 of file dpix.c.

References bu_log(), icv_image::data, ICV_COLOR_SPACE_RGB, icv_create(), icv_destroy(), icv_normalize(), and WRMODE.

Referenced by icv_read().

Here is the call graph for this function:

int dpix_write ( icv_image_t bif,
const char *  filename 
)

Definition at line 128 of file dpix.c.

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

Referenced by icv_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:

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:

HIDDEN int png_write ( icv_image_t bif,
const char *  filename 
)

Definition at line 111 of file fileformat.c.

References bu_log(), icv_image::channels, data, data2uchar(), icv_image::height, UNLIKELY, and icv_image::width.

Referenced by icv_write().

Here is the call graph for this function: