Comparison of QT image display efficiency

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_5c70dfc80100r257.html

The qimage class is generally used to process images in QT, but the qimage object cannot be directly displayed. To see the image, there are two methods at first.

1. Convert qimage to qpixmap and use qlabel: setpixmap ()

Image = new qimage ("D:/temp/xx.jpg ");

pixmap=newQPixmap();
pixmap->convertFromImage(*image);
label=newQLabel(this);
label->setGeometry(100,0,1000,700);
label->setPixmap(*pixmap);
 
2. directly draw in paintevent ()
 
void MyWindow::paintEvent(QPaintEvent*)
{
QPainter paint(this);
paint.drawImage(0,0,*image);
}
 
There are two methods to compare. Experiment shows that the first method is more efficient. Although the code is too open, the optimized qpixmap for display can reflect its advantages. Similarly, a 1200*1600 image is displayed. The first method requires almost no time and is displayed as 0 in milliseconds. The second method requires 15 ms, where a large amount of computation is required, the difference between 15 ms is quite large.

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.