KImgIO
g3r.cpp
Go to the documentation of this file.
00001 00008 #include "g3r.h" 00009 00010 #include <config.h> 00011 00012 #include <tiffio.h> 00013 00014 #include <qimage.h> 00015 #include <qfile.h> 00016 00017 KDE_EXPORT void kimgio_g3_read( QImageIO *io ) 00018 { 00019 // This won't work if io is not a QFile ! 00020 TIFF *tiff = TIFFOpen(QFile::encodeName(io->fileName()), "r"); 00021 if (!tiff) 00022 return; 00023 00024 uint32 width, height; 00025 tsize_t scanlength; 00026 00027 if( TIFFGetField( tiff, TIFFTAG_IMAGEWIDTH, &width ) != 1 00028 || TIFFGetField( tiff, TIFFTAG_IMAGELENGTH, &height ) != 1 ) 00029 return; 00030 scanlength = TIFFScanlineSize(tiff); 00031 00032 QImage image(width, height, 1, 0, QImage::BigEndian); 00033 00034 if (image.isNull() || scanlength != image.bytesPerLine()) 00035 { 00036 TIFFClose(tiff); 00037 return; 00038 } 00039 00040 for (uint32 y=0; y < height; y++) 00041 TIFFReadScanline(tiff, image.scanLine(y), y); 00042 00043 TIFFClose(tiff); 00044 00045 io->setImage(image); 00046 io->setStatus(0); 00047 } 00048 00049 00050 KDE_EXPORT void kimgio_g3_write(QImageIO *) 00051 { 00052 // TODO: stub 00053 } 00054
KDE 4.6 API Reference