当前位置:网站首页>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();边栏推荐
- Are there too many programmers in China at present?
- Illustrate plug-in -- AI plug-in development -- creative plug-in -- astute graphics -- multi axis mirroring function
- Unity AR Shadow 阴影
- 解析学习幼儿机器人教育的浪潮
- Delete tag
- Idea common plug-ins
- QT (x): control operation
- flutter配置国内镜像,连接真机
- Introduction to Ceres Quartet
- How to fix Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorli
猜你喜欢

Json tobean

Delete tag

Qt 串口编程

Json对象和Json字符串的区别

Chapter IV introduction to FPGA development platform

Single application and microservice application

Introduction to Ceres Quartet

Yyds dry goods inventory meituan's two-sided experience, and finally there was a surprise?

Redistemplate handles hash integer type problem resolution

Small program large screen adaptation Guide
随机推荐
RPC and RMI
Fault: KDC warning log for id29
Qt QLineEdit详解
Single application and microservice application
WDCP accesses all paths that do not exist and jumps to the home page without returning 404
How to change the password after forgetting the MySQL password (the latest version of 2022 detailed tutorial nanny level)
Vite快速上手
Character pointer as function parameter
Yyds dry goods inventory meituan's two-sided experience, and finally there was a surprise?
Qt 程序打包发布-windeployqt工具
How to do the performance pressure test of "Health Code"
try anbox (by quqi99)
QT (x): innosetup for software packaging
VerilogA——动态比较器
The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail
Where is the Gcov symbol- Where are the gcov symbols?
QT (x): packaging and deployment
centos下配置mysql 5.7 和 8
开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事
想请教一下,究竟有哪些劵商推荐?在线开户是安全么?