46 void tiff_error(
const char*,
const char*, va_list)
50 void tiff_warning(
const char *,
const char *, va_list)
53 tsize_t tiff_io_read_func(thandle_t fd, tdata_t buf, tsize_t size)
56 long long c = fin->
read(buf,size);
59 tsize_t tiff_io_write_func(thandle_t fd, tdata_t buf, tsize_t size)
62 long long c = fin->
write(buf,size);
65 toff_t tiff_io_seek_func(thandle_t fd, toff_t off,
int i)
87 int tiff_io_close_func(thandle_t fd)
93 toff_t tiff_io_size_func(thandle_t fd)
96 return (tsize_t)fin->
size();
98 int tiff_io_map_func(thandle_t, tdata_t*, toff_t*)
102 void tiff_io_unmap_func(thandle_t, tdata_t, toff_t)
126 TIFFSetErrorHandler(tiff_error);
127 TIFFSetWarningHandler(tiff_warning);
129 TIFF* tif = TIFFClientOpen(
"tiffread",
"r", reinterpret_cast<thandle_t>(file),
144 TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
145 TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
147 raster = (uint32*) _TIFFmalloc(npixels *
sizeof (uint32));
150 if (TIFFReadRGBAImage(tif, w, h, raster, 0))
157 uint16 orientation = ORIENTATION_TOPLEFT;
158 TIFFGetField(tif, TIFFTAG_ORIENTATION, &orientation);
159 if (orientation == ORIENTATION_LEFTBOT )
173 unsigned char byteorder[2];
174 file->
read(byteorder, 2);
175 bool little_endian = byteorder[0] ==
'I';
176 unsigned short version = file->
readUInt16(little_endian);
179 if (byteorder[0] != byteorder[1])
182 if (byteorder[0] !=
'M' && byteorder[0] !=
'I')
185 if (byteorder[1] !=
'M' && byteorder[1] !=
'I')
204 int w = src->
width();
206 int d = src->
depth();
220 Log::error(
Say(
"saveTIFF('%s'): could not convert src to IT_UNSIGNED_BYTE.\n") << fout->
path() );
230 Log::error(
Say(
"saveTIFF('%s'): could not convert src to IF_RGBA.\n") << fout->
path() );
237 const int RATIONAL = 5;
246 unsigned char little_endian[] = {
'I',
'I' };
247 fout->
write(little_endian, 2);
249 unsigned short version = 42;
252 unsigned long ifd_offset = 8;
255 unsigned short dir_count = 14;
258 unsigned short tag, type;
long long read(void *buffer, long long byte_count)
Reads byte_count bytes from a file. Returns the number of bytes actually read.
VLCORE_EXPORT FileSystem * defFileSystem()
Returns the default FileSystem used by VisualizationLibrary.
An abstract class representing a file.
long long writeUInt16(unsigned short data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
A simple String formatting class.
const unsigned char * pixels() const
Raw pointer to pixels.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
ref< Image > convertType(EImageType new_type) const
Converts the type() of an image.
bool seekCur(long long offset)
Changes the current read/write position of a file.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
virtual ref< VirtualFile > locateFile(const String &full_path, const String &alternate_path=String()) const
Looks for a VirtualFile on the disk and in the currently active FileSystem.
VLCORE_EXPORT bool saveTIFF(const Image *src, const String &path)
int requiredMemory() const
Returns the number of bytes requested to store the image.
virtual void close()=0
Closes the file.
long long writeUInt32(unsigned int data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
const String & path() const
Returns the path of the file.
VLCORE_EXPORT ref< Image > loadTIFF(VirtualFile *file)
Visualization Library main namespace.
long long write(const void *buffer, long long byte_count)
Writes byte_count bytes to a file. Returns the number of bytes actually written.
virtual bool open(EOpenMode mode)=0
Opens the file in the specified mode.
bool seekSet(long long offset)
Changes the current read/write position of a file.
virtual long long size() const =0
Returns the size of the file in bytes.
ref< Image > convertFormat(EImageFormat new_format) const
Converts the format() of an image.
unsigned short readUInt16(bool little_endian_data=true)
Reads single entry.
A VirtualFile that operates on regular disk files.
Implements a generic 1d, 2d, 3d and cubemap image that can have mipmaps.
The ref<> class is used to reference-count an Object.
void allocate2D(int x, int y, int bytealign, EImageFormat format, EImageType type)
bool seekEnd(long long offset)
Changes the current read/write position of a file.
long long position() const
Returns the current position in the file.
VLCORE_EXPORT bool isTIFF(VirtualFile *file)
static int bitsPerPixel(EImageType type, EImageFormat format)
Returns the number of bits used to represents one pixel.
EImageFormat format() const