Recently, the TIFF format was only available in the project. I checked on the document: "tiff is an image file format. This image format is complex, stores a large amount of content, occupies a large storage space, and is three times the size of GIF images, it is 10 times the corresponding JPEG image ". See its definition: The label Image File Format (Tagged Image File Format, abbreviated as TIFF) is a file format mainly used to store images including photos and art maps.
Label Image File Format
File Extension:. tif,. Tiff developer: Aldus
Format type: Image File Format
The project is based on QT 4.8 and may need to operate images in TIFF format. Therefore, I tested its basic operations-read/write and display.
Read/writeThere are multiple methods for reading and writing images in QT. Some code is as follows:
char *filename = "F:/0.tif"; /*read + write*/ QImage image; QImageReader qReader(filename); image = qReader.read(); QImageWriter writer("F:/A.tiff", "tiff"); writer.write(image); /*load + write*/ QImage image1; image1.load(filename); QImageWriter writer1("F:/B.tiff", "tiff"); writer1.write(image1); /*load + save*/ QImage image2; image2.load(filename); image2.save("F:/C.tiff","tiff"); /*write*/ QImage image3 = QImage(filename); QImageWriter writer3("F:/D.tiff", "tiff"); writer3.write(image3);
Images and truth
The above is the read/write operation of TIFF. Let's take a look at the display of TIFF on qlabel. The display code of TIFF is also very simple.Display
QString filename = "F:/4.tiff";QPixmap qimage(filename);qimage = qimage.scaled(800,800);ui->labelPic->setPixmap(qimage);ui->labelPic->show();
Images and truth
Qt 4.84 supports the following image formats:
bmpgificojpegjpgmngpbmpgmpngppmsvgsvgztgatiftiffxbmxpm
You can use the following code to view
QList<QByteArray> aa = QImageReader::supportedImageFormats(); foreach (QByteArray a , aa) { qDebug(a.data()); }