qimage

Converting QImage to QByteArray using QDataStream

China☆狼群 提交于 2021-02-11 14:00:20
问题 Im trying to convert a QImage that maked from ScreenShot to a QByteArray for sending via QTCPSocket. when i convert QImage to QByteArray and before sending it i try to deserialize and show it on label it cant ! what's my mistake? thx for helping. QByteArray ImClientShooter::toQByteArray(QImage &img) { QByteArray temp; QDataStream data(&temp, QIODevice::ReadWrite); data « img; return temp; } QByteArray goOn{toQByteArray(sampleQImage)}; //sampleQImage is a QImage Object lbl->setPixmap(QPixmap:

QT QImage - Copy Subsection of an Image as a Polygon

三世轮回 提交于 2021-02-05 07:45:10
问题 Trying to copy part of an image as a polygon (specifically a pentagon) but im more interested in how to copy as anything but a rectangle. The following code only allows to copy as a rectangle. QImage copy(const QRect &rect = QRect()) const; inline QImage copy(int x, int y, int w, int h) const { return copy(QRect(x, y, w, h)); } void SelectionInstrument::copyImage(ImageArea &imageArea) { if (mIsSelectionExists) { imageArea.setImage(mImageCopy); QClipboard *globalClipboard = QApplication:

QT QImage - Copy Subsection of an Image as a Polygon

情到浓时终转凉″ 提交于 2021-02-05 07:44:17
问题 Trying to copy part of an image as a polygon (specifically a pentagon) but im more interested in how to copy as anything but a rectangle. The following code only allows to copy as a rectangle. QImage copy(const QRect &rect = QRect()) const; inline QImage copy(int x, int y, int w, int h) const { return copy(QRect(x, y, w, h)); } void SelectionInstrument::copyImage(ImageArea &imageArea) { if (mIsSelectionExists) { imageArea.setImage(mImageCopy); QClipboard *globalClipboard = QApplication:

show matplotlib imshow output in Qt

让人想犯罪 __ 提交于 2020-05-15 19:26:49
问题 I have a 2D numpy array of type np.float64, and I want to show it as an image in a QLabel (or any other valid way): self.img = np.rot90(get_my_data()) # this line returns a 2D numpy array of type np.float64 self.qimg = QtGui.QImage(self.img, self.img.shape[0], self.img.shape[1], QtGui.QImage.Format_Grayscale8) self.myLabel.setPixmap(QtGui.QPixmap(self.qimg)) My code above returning the following error: TypeError: arguments did not match any overloaded call: QImage(): too many arguments QImage

Qt resize image with best quality

泄露秘密 提交于 2020-05-12 21:34:38
问题 Can anyone help me resize an image in qt without making the image pixelated. Here's my code. the result is not as good as the original quality..thanks... QImage img(name); QPixmap pixmap; pixmap = pixmap.fromImage(img.scaled(width,height,Qt::IgnoreAspectRatio,Qt::FastTransformation)); QFile file(folder+"/"+name); file.open(QIODevice::WriteOnly); pixmap.save(&file, "jpeg",100); file.close(); 回答1: You have to pass Qt::SmoothTransformation transformation mode to the scaled function like: QImage

Qt resize image with best quality

烈酒焚心 提交于 2020-05-12 21:34:04
问题 Can anyone help me resize an image in qt without making the image pixelated. Here's my code. the result is not as good as the original quality..thanks... QImage img(name); QPixmap pixmap; pixmap = pixmap.fromImage(img.scaled(width,height,Qt::IgnoreAspectRatio,Qt::FastTransformation)); QFile file(folder+"/"+name); file.open(QIODevice::WriteOnly); pixmap.save(&file, "jpeg",100); file.close(); 回答1: You have to pass Qt::SmoothTransformation transformation mode to the scaled function like: QImage

Qt resize image with best quality

左心房为你撑大大i 提交于 2020-05-12 21:29:51
问题 Can anyone help me resize an image in qt without making the image pixelated. Here's my code. the result is not as good as the original quality..thanks... QImage img(name); QPixmap pixmap; pixmap = pixmap.fromImage(img.scaled(width,height,Qt::IgnoreAspectRatio,Qt::FastTransformation)); QFile file(folder+"/"+name); file.open(QIODevice::WriteOnly); pixmap.save(&file, "jpeg",100); file.close(); 回答1: You have to pass Qt::SmoothTransformation transformation mode to the scaled function like: QImage

QImage/QPixmap size limitations?

此生再无相见时 提交于 2020-01-28 01:50:49
问题 Are there any known size/space limitation of QPixmap and/or QImage objects documented? I did not find any useful information regarding this. I'm currently using Qt 4.7.3 on OSX and Windows. Particulary I'm interested in: Width/Height limits? Limits depending on color format? Difference between 32/64 bit machines? Difference regarding OS? I would naively suspect that memory is the only limitation, so one could calculate max size by width x height x byte_per_pixel I assume that there is a more

Reproduce Python 2 PyQt4 QImage constructor behavior in Python 3

时光总嘲笑我的痴心妄想 提交于 2020-01-23 17:49:08
问题 I have written a small GUI using PyQt4 that displays an image and gets point coordinates that the user clicks on. I need to display a 2D numpy array as a grayscale, so I am creating a QImage from the array, then from that creating a QPixmap. In Python 2 it works fine. When I moved to Python 3, however, it can't decide on a constructor for QImage - it gives me the following error: TypeError: arguments did not match any overloaded call: QImage(): too many arguments QImage(QSize, QImage.Format):

Passing binary data from Qt/C++ DLL into Delphi host application

橙三吉。 提交于 2020-01-14 14:08:26
问题 In a Program I want to uses QImage.bits() in Delphi. So, in Qt I was created a dll. the dll Source Code Listed in below: test.h: #ifndef TEST_H #define TEST_H #include "test_global.h" extern "C"{ TESTSHARED_EXPORT uchar* testFunc(); } #endif // TEST_H test.cpp: #include "test.h" #include <QtGui> QImage image; uchar* testFunc(){ image.load("c:\\1.png","PNG"); return (uchar*)image.constBits(); } and in the Delphi Side I use this code for using Qt dll: function testFunc(): PByteArray; external