Questions tagged [qimage]

A QImage is a class from the Qt toolkit which provides a hardware-independent image representation that allows direct access to the pixel data, and can be used as a paint device.

Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPicture. QImage is designed and optimized for I/O, and for direct pixel access and manipulation.

Because QImage is a QPaintDevice subclass, QPainter can be used to draw directly onto images. When using QPainter on a QImage, the painting can be performed in another thread than the current GUI thread.

The QImage class supports several image formats, including monochrome, 8-bit, 32-bit and alpha-blended images.

QImage provides a collection of functions that can be used to obtain a variety of information about the image. There are also several functions that enable transformation of the image.

QImage objects can be passed around by value since the QImage class uses implicit data sharing. QImage objects can also be streamed and compared.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

549 questions
100
votes
5 answers

What is the difference between QImage and QPixmap?

I do not understand what is the difference between QImage and QPixmap, they seem to offer the same functionality. When should I use a QImage and when should I use a QPixmap?
Mr.Tu
  • 2,633
  • 8
  • 31
  • 47
52
votes
11 answers

How to convert an OpenCV cv::Mat to QImage

I am wondering how would I convert the OpenCV C++ standard cv::Mat type to QImage. I have been searching around, but have no luck. I have found some code that converts the IPlimage to QImage, but that is not what I want. Thanks.
Hien
  • 1,769
  • 3
  • 18
  • 17
52
votes
5 answers

Display QImage with QtGui

I am new to Qt, and I am trying to create a simple GUI Application that displays an image once a button has been clicked on. I can read the image in a QImage object, but is there any simple way to call a Qt function that takes the QImage as an…
Karim
  • 1,526
  • 4
  • 13
  • 16
27
votes
9 answers

Convert Python Opencv Image (numpy array) to PyQt QPixmap image

I am trying to convert python opencv image to QPixmap. I follow the instruction shows Page Link and my code is attached below img = cv2.imread('test.png')[:,:,::1]/255. imgDown = cv2.pyrDown(img) imgDown = np.float32(imgDown) cvRGBImg =…
SimaGuanxing
  • 673
  • 2
  • 10
  • 29
18
votes
2 answers

Qt - QImage is there a method to paste Qimage into another Qimage?

I am looking for a way to simply paste some Qimage into bigger one, starting with some given (x,y). Now, I am copying pixel by pixel all Qimage.
John X
  • 499
  • 2
  • 7
  • 15
18
votes
2 answers

cv::Mat to QImage and back

//Sorry for my english. Tell me please, what I am doing wrong? I have read a lot about this. And write some code, but I have a terrible result. As I understand in Opencv CV_8UC3 is the same as QImage::Format_RGB888 , except BRG and RGB…
user1113159
  • 645
  • 2
  • 7
  • 14
16
votes
5 answers

Image doesn't fit graphics view frame

I'm working on program which shows users some picture they select. I would like to fit this picture in QGraphicsView's frame, but the picture appears smaller than the frame. So here's my code: image = new QImage(data.absoluteFilePath()); // variable…
user1257255
  • 1,161
  • 8
  • 26
  • 55
15
votes
2 answers

QImage in a QGraphics scene

I am quite new to Qt. I am having troubles in inserting a QImage to a scene. Could somebody please tell me how to add a QImage to a QGraphicsScene?
Tharanga
  • 2,007
  • 4
  • 32
  • 50
14
votes
5 answers

QImage/QPixmap size limitations?

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…
grefab
  • 1,997
  • 2
  • 22
  • 32
14
votes
4 answers

Convert a QImage to grayscale

I have a QImage and I need to convert it to grayscale, then later paint over that with colors. I found an allGray() and isGrayScale() function to check if an image is already grayscale, but no toGrayScale() or similarly-named function. Right now I'm…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
13
votes
3 answers

How to convert QImage to QByteArray?

I am trying to create QByteArray from QImage, however although I tried lots of varient, I couldn't handle it. What I am doing is : QImage img_enrll; // <--- There is an image coming from another function. QByteArray…
goGud
  • 4,163
  • 11
  • 39
  • 63
13
votes
1 answer

Qt resize image with best quality

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 =…
James Seva
  • 139
  • 1
  • 2
  • 7
13
votes
2 answers

How to check if QImage is valid?

I wanted to know if there was a way to determine if a QImage is valid. I am displaying that image as a pixmap in QLabel and sometimes when the image is not valid. It is not displayed in the QLabel, then. The reason for not being valid sometimes is…
MistyD
  • 16,373
  • 40
  • 138
  • 240
13
votes
4 answers

QT QImage, how to extract RGB?

I want to extract RGB from each pixel in QImage. Ideally, I want to use the img.bits() function. QImage img; if( img.load("Red.jpg") ) { uchar *bits = img.bits(); for (int i = 0; i < 12; i++) { std::cout << (int) bits[i] <<…
ABCD
  • 7,914
  • 9
  • 54
  • 90
11
votes
3 answers

Image from resource file not loading in Qt

I'm trying to insert an image to my program via resource file, which is like: green.png other files and when I'm trying to load it using QImage or…
didgogns
  • 255
  • 1
  • 2
  • 7
1
2 3
36 37