当前位置:网站首页>Class differences of QT processing image data (qpixmap, qimage, qpicture)
Class differences of QT processing image data (qpixmap, qimage, qpicture)
2022-06-29 06:56:00 【Mr.codeee】
1. brief introduction
Qt Provides classes for processing image data :QImage, QPixmap and QPicture.
- QImage Is for I/O And direct pixel access and operation
- QPixmap It is designed and optimized for displaying images on the screen .
- QPicture Class is a record and playback QPainter Command's drawing device .
2.QImage
QImage Class provides a hardware independent image representation , It allows direct access to pixel data , And can be used as a drawing device ; Suitable for loading large pictures ; You can draw in a thread , Can be optimized UI response time . The effect of drawing pictures has nothing to do with the platform ,QImage Drawing on is fast , But showing it is slower .
Drawing pictures :
QImage image;
image.load("./test.png");
QPainter painter(this);
painter.drawImage(0,0,image);Draw a big picture : It can be used QImage Load the picture first , Change size , Turn into QPixmap.
QImage image;
image.load("./big.png");
QPixmap pixmap = QPixmap::fromImage(image.scaled(size(),Qt::KeepAspectRatio));
QPainter painter(this);
painter.drawPixmap(0,0,pixmap);;2.QPixmap
QPixmap Drawing depends on hardware ,QPixmap Is designed to Speed up the display , use paint For drawing QPixmap It will be much better than other classes . Generally, small pictures are used QPixmap load , Platform related ( The effect may be different on different platforms ).QPixmap Drawing on is slow , But showing it is faster .
QLabel Loading pictures :
ui->lbImg->setPixmap(QPixmap("test.jpg"));QPixmap And QImage Interconversion
QImage image = pixmap.toImage();
QPixmap pixmap = QPixmap::fromImage(image);3.QPicture
Record and playback QPainter Drawing instructions for
- begin() Start in QPicture Draw on
- end() It ends in QPicture Draw on
- save() Save as .pic file
- load() load .pic file
Example : A circle , Save the picture
QPicture picture;
QPainter painter;
painter.begin(&picture); // paint in picture
painter.drawEllipse(10,20, 80,70); // draw an ellipse
painter.end(); // painting done
picture.save("drawing.pic"); // save pictureExample : Loading pictures
QPicture picture;
QPainter painter;
picture.load("drawing.pic");
painter.begin(this);
painter.drawPicture(0,0,picture);
painter.end();边栏推荐
- VerilogA - dynamic comparator
- 大型化工企业数字化转型建议
- Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- multi axis mirroring function
- 转:侯宏:企业数字化转型的关键不是技术,而是战略
- About: deleting unwanted event log lists
- 'only_ full_ group_ The influence of by'sql mode on group by and its treatment
- UVM验证平台
- Mongodb sort function
- Li Kou today's question -324 Swing sort II
- Client and server working modes of JVM
猜你喜欢

把多个ROC曲线画在一张图上

Differences between JSON objects and JSON strings

RedisTemplate处理hash整数类型的问题解析

UVM authentication platform

The annual technology inventory of cloud primitives was released, and it was the right time to ride the wind and waves

Servlet version conflict causes page 404

Introduction to Ceres Quartet

2022.02.14 - 239. A single element in an ordered array

Hyperledger Fabric 2. X custom smart contract

How to do the performance pressure test of "Health Code"
随机推荐
Qt QFileInfo简介
关于DDNS
2022.02.15 - 240. Lucky number in matrix
Draw smooth curves - methods needed - drawing smooth curves - methods needed
Qt 串口编程
Configuring the flutter development environment
It is the only one in China that Alibaba cloud container service has entered the Forrester leader quadrant
try anbox (by quqi99)
QT (x): control operation
多模态 —— Learnable pooling with Context Gating for video classification
Delete tag
Annual inventory review of Alibaba cloud's observable practices in 2021
Qt QLineEdit详解
idea使用
json tobean
Some thoughts on port forwarding program
百度小程序自动提交搜索
Teach you how to develop your own NPM package (publish to the NPM official website)
String and variable are spliced into variable name
Error: GPG check FAILED Once install MySQL