Blender V2.61 - r43446
|
#include <string.h>
#include "imbuf.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_global.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "IMB_allocimbuf.h"
#include "IMB_filetype.h"
#include "IMB_filter.h"
#include "tiffio.h"
Go to the source code of this file.
Classes | |
struct | ImbTIFFMemFile |
Defines | |
#define | IMB_TIFF_GET_MEMFILE(x) ((ImbTIFFMemFile*)(x)); |
#define | IMB_TIFF_NCB 4 |
Typedefs | |
typedef struct ImbTIFFMemFile | ImbTIFFMemFile |
Functions | |
static tsize_t | imb_tiff_ReadProc (thandle_t handle, tdata_t data, tsize_t n) |
static tsize_t | imb_tiff_WriteProc (thandle_t handle, tdata_t data, tsize_t n) |
static toff_t | imb_tiff_SeekProc (thandle_t handle, toff_t ofs, int whence) |
static int | imb_tiff_CloseProc (thandle_t handle) |
static toff_t | imb_tiff_SizeProc (thandle_t handle) |
static int | imb_tiff_DummyMapProc (thandle_t fd, tdata_t *pbase, toff_t *psize) |
static void | imb_tiff_DummyUnmapProc (thandle_t fd, tdata_t base, toff_t size) |
static TIFF * | imb_tiff_client_open (ImbTIFFMemFile *memFile, unsigned char *mem, size_t size) |
int | imb_is_a_tiff (unsigned char *mem) |
static void | scanline_contig_16bit (float *rectf, unsigned short *sbuf, int scanline_w, int spp) |
static void | scanline_contig_32bit (float *rectf, float *fbuf, int scanline_w, int spp) |
static void | scanline_separate_16bit (float *rectf, unsigned short *sbuf, int scanline_w, int chan) |
static void | scanline_separate_32bit (float *rectf, float *fbuf, int scanline_w, int chan) |
static void | imb_read_tiff_resolution (ImBuf *ibuf, TIFF *image) |
static int | imb_read_tiff_pixels (ImBuf *ibuf, TIFF *image, int premul) |
void | imb_inittiff (void) |
ImBuf * | imb_loadtiff (unsigned char *mem, size_t size, int flags) |
void | imb_loadtiletiff (ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect) |
int | imb_savetiff (ImBuf *ibuf, const char *name, int flags) |
Definition in file tiff.c.
#define IMB_TIFF_GET_MEMFILE | ( | x | ) | ((ImbTIFFMemFile*)(x)); |
Definition at line 88 of file tiff.c.
Referenced by imb_tiff_CloseProc(), imb_tiff_ReadProc(), imb_tiff_SeekProc(), and imb_tiff_SizeProc().
#define IMB_TIFF_NCB 4 |
Checks whether a given memory buffer contains a TIFF file.
This method uses the format identifiers from: http://www.faqs.org/faqs/graphics/fileformats-faq/part4/section-9.html The first four bytes of big-endian and little-endian TIFF files respectively are (hex): 4d 4d 00 2a 49 49 2a 00 Note that TIFF files on *any* platform can be either big- or little-endian; it's not platform-specific.
AFAICT, libtiff doesn't provide a method to do this automatically, and hence my manual comparison. - Jonathan Merritt (lancelet) 4th Sept 2005.
Definition at line 308 of file tiff.c.
Referenced by imb_is_a_tiff(), and imb_loadtiff().
typedef struct ImbTIFFMemFile ImbTIFFMemFile |
int imb_is_a_tiff | ( | unsigned char * | mem | ) |
ImBuf* imb_loadtiff | ( | unsigned char * | mem, |
size_t | size, | ||
int | flags | ||
) | [read] |
Loads a TIFF file.
mem,: | Memory containing the TIFF file. |
size,: | Size of the mem buffer. |
flags,: | If flags has IB_test set then the file is not actually loaded, but all other operations take place. |
Definition at line 505 of file tiff.c.
References ImBuf::flags, ImBuf::ftype, IB_premul, IB_test, IB_tilecache, imb_addtilesImBuf(), IMB_allocImBuf(), imb_is_a_tiff(), imb_read_tiff_pixels(), imb_tiff_client_open(), IMB_TIFF_NCB, ImBuf::mipmap, ImBuf::miptot, and NULL.
void imb_loadtiletiff | ( | ImBuf * | ibuf, |
unsigned char * | mem, | ||
size_t | size, | ||
int | tx, | ||
int | ty, | ||
unsigned int * | rect | ||
) |
Definition at line 614 of file tiff.c.
References ImBuf::flags, IB_premul, IMB_premultiply_rect(), imb_tiff_client_open(), ImBuf::miplevel, NULL, ImBuf::tilex, ImBuf::tiley, ImBuf::x, ImBuf::y, and ImBuf::ytiles.
static int imb_read_tiff_pixels | ( | ImBuf * | ibuf, |
TIFF * | image, | ||
int | premul | ||
) | [static] |
Definition at line 379 of file tiff.c.
References B_ENDIAN, ENDIAN_ORDER, ImBuf::flags, IB_premul, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, IB_rect, IB_rectfloat, IMB_allocImBuf(), IMB_convert_rgba_to_abgr(), IMB_freeImBuf(), IMB_premultiply_alpha(), imb_read_tiff_resolution(), ImBuf::mall, NULL, ImBuf::planes, ImBuf::profile, ImBuf::rect, ImBuf::rect_float, scanline_contig_16bit(), scanline_contig_32bit(), scanline_separate_16bit(), scanline_separate_32bit(), ImBuf::x, and ImBuf::y.
Referenced by imb_loadtiff().
static void imb_read_tiff_resolution | ( | ImBuf * | ibuf, |
TIFF * | image | ||
) | [static] |
int imb_savetiff | ( | ImBuf * | ibuf, |
const char * | name, | ||
int | flags | ||
) |
Saves a TIFF file.
ImBuf structures with 1, 3 or 4 bytes per pixel (GRAY, RGB, RGBA respectively) are accepted, and interpreted correctly. Note that the TIFF convention is to use pre-multiplied alpha, which can be achieved within Blender by setting "Premul" alpha handling. Other alpha conventions are not strictly correct, but are permitted anyhow.
ibuf,: | Image buffer. |
name,: | Name of the TIFF file to create. |
flags,: | Currently largely ignored. |
Definition at line 671 of file tiff.c.
References copy_v3_v3(), FTOUSHORT, ImBuf::ftype, i, IB_mem, IB_PROFILE_LINEAR_RGB, linearrgb_to_srgb_v3_v3(), NULL, ImBuf::planes, ImBuf::ppm, ImBuf::profile, ImBuf::rect, ImBuf::rect_float, ImBuf::x, and ImBuf::y.
static TIFF* imb_tiff_client_open | ( | ImbTIFFMemFile * | memFile, |
unsigned char * | mem, | ||
size_t | size | ||
) | [static] |
Definition at line 279 of file tiff.c.
References imb_tiff_CloseProc(), imb_tiff_DummyMapProc(), imb_tiff_DummyUnmapProc(), imb_tiff_ReadProc(), imb_tiff_SeekProc(), imb_tiff_SizeProc(), imb_tiff_WriteProc(), ImbTIFFMemFile::mem, ImbTIFFMemFile::offset, size(), and ImbTIFFMemFile::size.
Referenced by imb_loadtiff(), and imb_loadtiletiff().
static int imb_tiff_CloseProc | ( | thandle_t | handle | ) | [static] |
Closes (virtually) an in-memory TIFF file.
NOTE: All this function actually does is sets the data pointer within the TIFF file to NULL. That should trigger assertion errors if attempts are made to access the file after that point. However, no such attempts should ever be made (in theory).
handle,: | Handle of the TIFF file (pointer to ImbTIFFMemFile). |
Definition at line 238 of file tiff.c.
References IMB_TIFF_GET_MEMFILE, ImbTIFFMemFile::mem, NULL, ImbTIFFMemFile::offset, and ImbTIFFMemFile::size.
Referenced by imb_tiff_client_open().
static int imb_tiff_DummyMapProc | ( | thandle_t | fd, |
tdata_t * | pbase, | ||
toff_t * | psize | ||
) | [static] |
Definition at line 104 of file tiff.c.
Referenced by imb_tiff_client_open().
static void imb_tiff_DummyUnmapProc | ( | thandle_t | fd, |
tdata_t | base, | ||
toff_t | size | ||
) | [static] |
Definition at line 97 of file tiff.c.
Referenced by imb_tiff_client_open().
static tsize_t imb_tiff_ReadProc | ( | thandle_t | handle, |
tdata_t | data, | ||
tsize_t | n | ||
) | [static] |
Provides TIFF file loading and saving for Blender, via libtiff.
The task of loading is complicated somewhat by the fact that Blender has already loaded the file into a memory buffer. libtiff is not well configured to handle files in memory, so a client wrapper is written to surround the memory and turn it into a virtual file. Currently, reading of TIFF files is done using libtiff's RGBAImage support. This is a high-level routine that loads all images as 32-bit RGBA, handling all the required conversions between many different TIFF types internally.
Saving supports RGB, RGBA and BW (greyscale) images correctly, with 8 bits per channel in all cases. The "deflate" compression algorithm is used to compress images.
Reads data from an in-memory TIFF file.
handle,: | Handle of the TIFF file (pointer to ImbTIFFMemFile). |
data,: | Buffer to contain data (treat as void*). |
n,: | Number of bytes to read. |
Definition at line 123 of file tiff.c.
References IMB_TIFF_GET_MEMFILE, ImbTIFFMemFile::mem, ImbTIFFMemFile::offset, and ImbTIFFMemFile::size.
Referenced by imb_tiff_client_open().
static toff_t imb_tiff_SeekProc | ( | thandle_t | handle, |
toff_t | ofs, | ||
int | whence | ||
) | [static] |
Seeks to a new location in an in-memory TIFF file.
handle,: | Handle of the TIFF file (pointer to ImbTIFFMemFile). |
ofs,: | Offset value (interpreted according to whence below). |
whence,: | This can be one of three values: SEEK_SET - The offset is set to ofs bytes. SEEK_CUR - The offset is set to its current location plus ofs bytes. SEEK_END - (This is unsupported and will return -1, indicating an error). |
Definition at line 191 of file tiff.c.
References IMB_TIFF_GET_MEMFILE, ImbTIFFMemFile::mem, and ImbTIFFMemFile::offset.
Referenced by imb_tiff_client_open().
static toff_t imb_tiff_SizeProc | ( | thandle_t | handle | ) | [static] |
Returns the size of an in-memory TIFF file in bytes.
Definition at line 264 of file tiff.c.
References IMB_TIFF_GET_MEMFILE, ImbTIFFMemFile::mem, and ImbTIFFMemFile::size.
Referenced by imb_tiff_client_open().
static tsize_t imb_tiff_WriteProc | ( | thandle_t | handle, |
tdata_t | data, | ||
tsize_t | n | ||
) | [static] |
Writes data to an in-memory TIFF file.
NOTE: The current Blender implementation should not need this function. It is simply a stub.
Definition at line 165 of file tiff.c.
Referenced by imb_tiff_client_open().
static void scanline_contig_16bit | ( | float * | rectf, |
unsigned short * | sbuf, | ||
int | scanline_w, | ||
int | spp | ||
) | [static] |
static void scanline_contig_32bit | ( | float * | rectf, |
float * | fbuf, | ||
int | scanline_w, | ||
int | spp | ||
) | [static] |
static void scanline_separate_16bit | ( | float * | rectf, |
unsigned short * | sbuf, | ||
int | scanline_w, | ||
int | chan | ||
) | [static] |
static void scanline_separate_32bit | ( | float * | rectf, |
float * | fbuf, | ||
int | scanline_w, | ||
int | chan | ||
) | [static] |