#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 RGBSpectrum * | ReadImageEXR (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 RGBSpectrum * | ReadImageTGA (const string &name, int *w, int *h) |
static bool | WriteImagePFM (const string &filename, const float *rgb, int xres, int yres) |
static RGBSpectrum * | ReadImagePFM (const string &filename, int *xres, int *yres) |
RGBSpectrum * | ReadImage (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 |
License: GPL Online License Link: http://www.gnu.org/licenses/gpl.html
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 BUFFER_SIZE 80 |
Definition at line 561 of file imageio.cpp.
Referenced by ReadImagePFM().
#define SHORT | ( | x | ) | (x) |
Definition at line 224 of file imageio.cpp.
Referenced by writeShort().
#define TO_BYTE | ( | v | ) | (uint8_t(Clamp(255.f * powf((v), 1.f/2.3f), 0.f, 255.f))) |
Referenced by WriteImageTGA().
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.
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] |
Definition at line 346 of file imageio.cpp.
References tga_colormapspec_t::entrySize, tga_colormapspec_t::index, tga_colormapspec_t::length, readByte(), and readShort().
Referenced by ReadImageTGA().
static void readHeader | ( | tga_header_t * | dst, | |
FILE * | file | |||
) | [static] |
Definition at line 321 of file imageio.cpp.
References tga_header_t::colorMapType, tga_header_t::idLength, tga_header_t::imageType, and readByte().
Referenced by ReadImageTGA().
RGBSpectrum* ReadImage | ( | const string & | name, | |
int * | width, | |||
int * | height | |||
) |
Definition at line 45 of file imageio.cpp.
References Error(), ReadImageEXR(), ReadImagePFM(), and ReadImageTGA().
Referenced by ImageTexture< Tmemory, Treturn >::GetTexture(), GonioPhotometricLight::GonioPhotometricLight(), InfiniteAreaLight::InfiniteAreaLight(), and ProjectionLight::ProjectionLight().
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] |
Definition at line 384 of file imageio.cpp.
References tga_imagespec_t::attributeBits, tga_imagespec_t::height, tga_imagespec_t::pixelDepth, readByte(), readShort(), tga_imagespec_t::width, tga_imagespec_t::xOrigin, and tga_imagespec_t::yOrigin.
Referenced by ReadImageTGA().
static RGBSpectrum * ReadImageTGA | ( | const string & | name, | |
int * | width, | |||
int * | height | |||
) | [static] |
Loads a TGA image (not the RLE types though)
Definition at line 447 of file imageio.cpp.
References Assert, tga_imagespec_t::attributeBits, Error(), RGBSpectrum::FromRGB(), tga_imagespec_t::height, tga_header_t::imageType, Info(), tga_imagespec_t::pixelDepth, readColorMapSpec(), readHeader(), readImageSpec(), and tga_imagespec_t::width.
Referenced by ReadImage().
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] |
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] |
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] |
static void writeImageSpec | ( | int16_t | xOrigin, | |
int16_t | yOrigin, | |||
int16_t | width, | |||
int16_t | height, | |||
uchar | pixDepth, | |||
FILE * | file | |||
) | [static] |
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.
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. |
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().
bool hostLittleEndian [static] |
Definition at line 551 of file imageio.cpp.