20 #ifndef OST_IMG_IO_TIFF_HH
21 #define OST_IMG_IO_TIFF_HH
26 #include <boost/filesystem.hpp>
31 namespace ost {
namespace io {
namespace detail {
39 struct tiff_warning_handler_wrapper {
52 class complexint32:
public std::complex<int32_t>{
55 operator std::complex<Real>()
57 return std::complex<Real>(real(),imag());
62 class complexint16:
public std::complex<int16_t>{
65 operator std::complex<Real>()
67 return std::complex<Real>(real(),imag());
72 class complexint8:
public std::complex<int8_t>{
75 operator std::complex<Real>()
77 return std::complex<Real>(real(),imag());
105 template<
typename IN_TYPE,
typename OUT_TYPE,
class IST>
106 void do_tiff_read(tdata_t buf,
unsigned int rps,
unsigned int width, IST* is,
unsigned int& current_row,
uint16_t spp)
108 IN_TYPE* dp =
static_cast<IN_TYPE*
>(buf);
109 for(
uint r=0;r<rps;r++) {
110 for(
uint c=0;c<width;c++) {
111 is->Value(
img::Point(c,current_row))=
static_cast<OUT_TYPE
>(dp[(r*width+c)*spp]);
118 template<
typename IN_TYPE,
typename OUT_TYPE,
class IST>
119 void do_tiff_write(TIFF *tif, IST* is,
unsigned int rowsperstrip,
unsigned int width,
unsigned int height,
unsigned int strip,
const img::NormalizerPtr& nptr)
121 uint datalength=rowsperstrip*width;
122 if((strip+1)*rowsperstrip>height){
123 datalength=(height-strip*rowsperstrip)*width;
125 OUT_TYPE* buf=
new OUT_TYPE[datalength];
126 img::Point start = is->GetExtent().GetStart();
129 for(
uint r=strip*rowsperstrip;r<(strip+1)*rowsperstrip && r<height;r++) {
130 for(
uint c=0;c<width;c++) {
131 buf[i] =
static_cast<OUT_TYPE
>(nptr->Convert(is->Value(img::Point(c,r)+start)));
135 TIFFWriteEncodedStrip(tif,strip,buf,
sizeof(OUT_TYPE)*datalength);
~tiff_warning_handler_wrapper()
boost::shared_ptr< NormalizerImpl > NormalizerPtr
TIFFWarningHandler handler_
void(* TIFFWarningHandler)(const char *, const char *, va_list)
void do_tiff_read(tdata_t buf, unsigned int rps, unsigned int width, IST *is, unsigned int ¤t_row, uint16_t spp)
tsize_t CustomTIFFWriteProcOStream(thandle_t thandle, tdata_t tdata, tsize_t tsize)
int CustomTIFFMapFileProc(thandle_t thandle, tdata_t *tdata, toff_t *toff)
tsize_t CustomTIFFReadProcOStream(thandle_t thandle, tdata_t tdata, tsize_t tsize)
tiff_warning_handler_wrapper()
toff_t CustomTIFFSizeProcIStream(thandle_t thandle)
tsize_t CustomTIFFReadProcIStream(thandle_t thandle, tdata_t tdata, tsize_t tsize)
toff_t CustomTIFFSeekProcOStream(thandle_t thandle, toff_t toff, int dir)
void tiff_warning_handler(const char *mod, const char *fmt, va_list ap)
toff_t CustomTIFFSeekProcIStream(thandle_t thandle, toff_t toff, int dir)
void do_tiff_write(TIFF *tif, IST *is, unsigned int rowsperstrip, unsigned int width, unsigned int height, unsigned int strip, const img::NormalizerPtr &nptr)
tsize_t CustomTIFFWriteProcIStream(thandle_t thandle, tdata_t tdata, tsize_t tsize)
class encapsulating 1D to 3D point
int CustomTIFFCloseProc(thandle_t thandle)
void CustomTIFFUnmapFileProc(thandle_t thandle, tdata_t tdata, toff_t toff)
toff_t CustomTIFFSizeProcOStream(thandle_t thandle)