11 #include <tdelibs_export.h>
17 static tsize_t tiff_read( thandle_t handle, tdata_t buf, tsize_t size )
19 TQIODevice *dev =
reinterpret_cast<TQIODevice *
>( handle );
20 return dev->readBlock( reinterpret_cast<char *>( buf ), size );
23 static tsize_t tiff_write( thandle_t, tdata_t, tsize_t )
28 static toff_t tiff_seek( thandle_t handle, toff_t off,
int whence )
30 TQIODevice *dev =
reinterpret_cast<TQIODevice *
>( handle );
32 if ( whence == SEEK_CUR )
34 else if ( whence == SEEK_END )
37 if ( !dev->at( off ) )
43 static toff_t tiff_size( thandle_t handle )
45 TQIODevice *dev =
reinterpret_cast<TQIODevice *
>( handle );
49 static int tiff_close( thandle_t )
54 static int tiff_map( thandle_t, tdata_t *, toff_t * )
59 static void tiff_unmap( thandle_t, tdata_t, toff_t )
63 KDE_EXPORT
void kimgio_tiff_read( TQImageIO *io )
72 tiff = TIFFClientOpen( TQFile::encodeName( io->fileName() ),
"r",
73 ( thandle_t )io->ioDevice(),
74 tiff_read, tiff_write, tiff_seek, tiff_close,
75 tiff_size, tiff_map, tiff_unmap );
82 if( TIFFGetField( tiff, TIFFTAG_IMAGEWIDTH, &width ) != 1
83 || TIFFGetField( tiff, TIFFTAG_IMAGELENGTH, &height ) != 1 )
86 TQImage image( width, height, 32 );
91 data = (uint32 *)image.bits();
98 bool stat =TIFFReadRGBAImage( tiff, width, height, data );
106 for(
unsigned i = 0; i < width * height; ++i )
108 uint32 red = ( 0x00FF0000 & data[i] ) >> 16;
109 uint32 blue = ( 0x000000FF & data[i] ) << 16;
110 data[i] &= 0xFF00FF00;
111 data[i] += red + blue;
115 for(
unsigned ctr = 0; ctr < (height>>1); ) {
116 unsigned *line1 = (
unsigned *)image.scanLine( ctr );
117 unsigned *line2 = (
unsigned *)image.scanLine( height
120 for(
unsigned x = 0; x < width; x++ ) {
142 io->setImage( image );
146 KDE_EXPORT
void kimgio_tiff_write( TQImageIO * )