imageio.cpp File Reference

#include "stdafx.h"
#include "imageio.h"
#include "pbrt.h"
#include "spectrum.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  tga_header_t
struct  tga_colormapspec_t
struct  tga_imagespec_t

Defines

#define SHORT(x)   (x)
#define TO_BYTE(v)   (uint8_t(Clamp(255.f * powf((v), 1.f/2.3f), 0.f, 255.f)))
#define BUFFER_SIZE   80

Typedefs

typedef uint8_t byte
typedef unsigned char uchar

Functions

static RGBSpectrumReadImageEXR (const string &name, int *width, int *height)
static void WriteImageEXR (const string &name, float *pixels, float *alpha, int xRes, int yRes, int totalXRes, int totalYRes, int xOffset, int yOffset)
static void WriteImageTGA (const string &name, float *pixels, float *alpha, int xRes, int yRes, int totalXRes, int totalYRes, int xOffset, int yOffset)
static RGBSpectrumReadImageTGA (const string &name, int *w, int *h)
static bool WriteImagePFM (const string &filename, const float *rgb, int xres, int yres)
static RGBSpectrumReadImagePFM (const string &filename, int *xres, int *yres)
RGBSpectrumReadImage (const string &name, int *width, int *height)
void WriteImage (const string &name, float *pixels, float *alpha, int xRes, int yRes, int totalXRes, int totalYRes, int xOffset, int yOffset)
static bool writeByte (FILE *f, uchar b)
static bool writeShort (FILE *f, int16_t s)
static uchar readByte (FILE *f)
static int16_t readShort (FILE *f)
static void writeHeader (uchar idLength, uchar colorMapType, uchar imageType, FILE *file)
static void readHeader (tga_header_t *dst, FILE *file)
static void writeColorMapSpec (int16_t index, int16_t length, uchar entrySize, FILE *file)
static void readColorMapSpec (tga_colormapspec_t *dst, FILE *file)
static void writeImageSpec (int16_t xOrigin, int16_t yOrigin, int16_t width, int16_t height, uchar pixDepth, FILE *file)
static void readImageSpec (tga_imagespec_t *dst, FILE *file)
static int isWhitespace (char c)
static int readWord (FILE *fp, char *buffer, int bufferLength)

Variables

static bool hostLittleEndian

Detailed Description

License

License: GPL Online License Link: http://www.gnu.org/licenses/gpl.html

Author:
Copyright (c) 2003-2009 Jaakko Keranen <jaakko.keranen@iki.fi>
Copyright (c) 2009 Daniel Swanson <danij@dengine.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Definition in file imageio.cpp.


Define Documentation

#define BUFFER_SIZE   80

Definition at line 561 of file imageio.cpp.

Referenced by ReadImagePFM().

#define SHORT (  )     (x)

Definition at line 224 of file imageio.cpp.

Referenced by writeShort().

#define TO_BYTE (  )     (uint8_t(Clamp(255.f * powf((v), 1.f/2.3f), 0.f, 255.f)))

Referenced by WriteImageTGA().


Typedef Documentation

typedef uint8_t byte

gl_tga.c: TGA file format (TARGA) reader/writer.

Definition at line 213 of file imageio.cpp.

typedef unsigned char uchar

Definition at line 216 of file imageio.cpp.


Function Documentation

static int isWhitespace ( char  c  )  [inline, static]

Definition at line 563 of file imageio.cpp.

Referenced by readWord().

static uchar readByte ( FILE *  f  )  [static]

Definition at line 277 of file imageio.cpp.

Referenced by readColorMapSpec(), readHeader(), and readImageSpec().

static void readColorMapSpec ( tga_colormapspec_t dst,
FILE *  file 
) [static]
static void readHeader ( tga_header_t dst,
FILE *  file 
) [static]
RGBSpectrum* ReadImage ( const string &  name,
int *  width,
int *  height 
)
static RGBSpectrum* ReadImageEXR ( const string &  name,
int *  width,
int *  height 
) [static]

Referenced by ReadImage().

static RGBSpectrum * ReadImagePFM ( const string &  filename,
int *  xres,
int *  yres 
) [static]

Definition at line 601 of file imageio.cpp.

References BUFFER_SIZE, Error(), RGBSpectrum::FromRGB(), and readWord().

Referenced by ReadImage().

static void readImageSpec ( tga_imagespec_t dst,
FILE *  file 
) [static]
static RGBSpectrum * ReadImageTGA ( const string &  name,
int *  width,
int *  height 
) [static]
static int16_t readShort ( FILE *  f  )  [static]

Definition at line 286 of file imageio.cpp.

Referenced by readColorMapSpec(), and readImageSpec().

static int readWord ( FILE *  fp,
char *  buffer,
int  bufferLength 
) [static]

Definition at line 576 of file imageio.cpp.

References isWhitespace().

Referenced by ReadImagePFM().

static bool writeByte ( FILE *  f,
uchar  b 
) [static]

Definition at line 262 of file imageio.cpp.

Referenced by writeColorMapSpec(), writeHeader(), and writeImageSpec().

static void writeColorMapSpec ( int16_t  index,
int16_t  length,
uchar  entrySize,
FILE *  file 
) [static]
Parameters:
index Index of first color map entry.
length Total number of color map entries.
entrySize Number of bits in a color map entry; 15/16/24/32.
file Handle to the file to be written to.

Definition at line 336 of file imageio.cpp.

References writeByte(), and writeShort().

Referenced by WriteImageTGA().

static void writeHeader ( uchar  idLength,
uchar  colorMapType,
uchar  imageType,
FILE *  file 
) [static]
Parameters:
idLength Identification field size in bytes (max 255). 0 indicates no identification field.
colorMapType Type of the color map, 0 or 1: 0 = color map data is not present. 1 = color map data IS present.
imageType Image data type code, one of: 0 = no image data is present. 1 = uncompressed, color mapped image. 2 = uncompressed, true-color image. 3 = uncompressed, grayscale image. 9 = run-length encoded, color mapped image. 10 = run-length encoded, true-color image. 11 = run-length encoded, grayscale image.
file Handle to the file to be written to.

Definition at line 311 of file imageio.cpp.

References writeByte().

Referenced by WriteImageTGA().

void WriteImage ( const string &  name,
float *  pixels,
float *  alpha,
int  xRes,
int  yRes,
int  totalXRes,
int  totalYRes,
int  xOffset,
int  yOffset 
)

Definition at line 69 of file imageio.cpp.

References Error(), WriteImageEXR(), WriteImagePFM(), and WriteImageTGA().

Referenced by SHWriteImage().

static void WriteImageEXR ( const string &  name,
float *  pixels,
float *  alpha,
int  xRes,
int  yRes,
int  totalXRes,
int  totalYRes,
int  xOffset,
int  yOffset 
) [static]

Referenced by WriteImage().

static bool WriteImagePFM ( const string &  filename,
const float *  rgb,
int  xres,
int  yres 
) [static]

Definition at line 690 of file imageio.cpp.

References Error().

Referenced by WriteImage().

static void writeImageSpec ( int16_t  xOrigin,
int16_t  yOrigin,
int16_t  width,
int16_t  height,
uchar  pixDepth,
FILE *  file 
) [static]
Parameters:
xOrigin X coordinate of lower left corner.
yOrigin Y coordinate of lower left corner.
width Width of the image in pixels.
height Height of the image in pixels.
pixDepth Number of bits per pixel, one of; 16/24/32.
file Handle to the file to be written to.

attributeBits:4; // Attribute bits associated with each pixel. reserved:1; // A reserved bit; must be 0. screenOrigin:1; // Location of screen origin; must be 0. dataInterleave:2; // TGA_INTERLEAVE_*

Definition at line 363 of file imageio.cpp.

References writeByte(), and writeShort().

Referenced by WriteImageTGA().

void WriteImageTGA ( const string &  name,
float *  pixels,
float *  alpha,
int  xRes,
int  yRes,
int  totalXRes,
int  totalYRes,
int  xOffset,
int  yOffset 
) [static]

Save the rgb8888 buffer as Targa 24.

Parameters:
filename Path to the file to be written to (need not exist).
w Width of the image in pixels.
h Height of the image in pixels.
buf Ptr to the image data to be written.
Returns:
Non-zero iff successful.

Definition at line 405 of file imageio.cpp.

References Error(), TO_BYTE, writeColorMapSpec(), writeHeader(), and writeImageSpec().

Referenced by WriteImage().

static bool writeShort ( FILE *  f,
int16_t  s 
) [static]

Definition at line 269 of file imageio.cpp.

References SHORT.

Referenced by writeColorMapSpec(), and writeImageSpec().


Variable Documentation

bool hostLittleEndian [static]

Definition at line 551 of file imageio.cpp.

Generated on Sat Aug 28 20:00:12 2010 for pbrt by  doxygen 1.6.3