[QT] Reading, writing, and displaying tiff in QT

Source: Internet
Author: User
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());    }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.