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
2
votes
2 answers

QPixmap fromImage results in Segmentation fault

I'm at a complete loss here... I'm trying to convert a QImage to a QPixmap but my program keeps crashing with the following stack trace. What's weird is it works fine if the QRectF that I specify doesn't have an upper left point of (0, 0). I know…
LeviX
  • 3,096
  • 3
  • 28
  • 41
2
votes
4 answers

need to compress QImage to send it via IP

i'm programming an application (in C++/Qt Designer 4.6 and using some librairies like ffmpeg and v4l2) which capture from webcam and i want to send the captured QImage via IP, so i send it into a QTcpSocket and i succed in receiving it in my server…
amrouch
  • 35
  • 2
  • 6
2
votes
1 answer

QImage: how to convert a gray image to a RGB heatmap

I am trying to convert a Format_Grayscale8 image to Format_ARGB32 (or any other 8bpp RGB format). I tried to use QImage::convertToFormat and a color table but I can't make it work. The input is a small 8bit gray image (PGM format text…
ForeverLearning
  • 413
  • 5
  • 25
2
votes
1 answer

QQuickImageProvider::requestImage image scaling, how to handle it

I am trying to implement a simple PxImageProvider. The source image is static, and I am providing only one image. It seems to be that requestedSize is always empty. Even when I try to modify the image size on the QML side, the image gets re-scaled,…
Will59
  • 1,430
  • 1
  • 16
  • 37
2
votes
2 answers

Set pixel value of 16 bit grayscale QImage

I have an 16 bit image of width ("imagewidth") and height ("imageheight"). The data is currently stored in an unsigned short int array of length ("imagewidth"*"imageheight") I want to create an 16 bit grayscale QImage (using Qt 5.14) from my dataset…
jfrans1
  • 31
  • 1
  • 5
2
votes
2 answers

How to use a color LUT in Qt QImage

I have some legacy code that was writing to a NITF file to display some images. In the legacy code, it appears as if there was a LUT being used, and there was a section of code that wrote out a row at a time to the NITF file , and the values of that…
Derek
  • 11,715
  • 32
  • 127
  • 228
2
votes
1 answer

QLabel show images like a video

I try to let a QLabel show images like a video. I want this display my images from f0000.png to f0039.png slowly so I can see progress. For some reason my for loop starts with 50. When I see the program run it only show one image or it change too…
5407
  • 39
  • 9
2
votes
2 answers

`QImage` constructor has unknown keyword `data`

Suppose I am taking an image from the webcam using opencv. _, img = self.cap.read() # numpy.ndarray (480, 640, 3) Then I create a QImage qimg using img: qimg = QImage( data=img, width=img.shape[1], height=img.shape[0], …
Rahat Zaman
  • 1,322
  • 14
  • 32
2
votes
0 answers

Qt QTooltip with image always landscape

I have a Qt c++ App but when I tried to add tooltip with image it shows correctly if image is landscape but if image is portrait then it will be rotated event the original file is portrait any help ! Thanks in advance. QByteArray byteArray; QBuffer…
Amr Osman
  • 119
  • 2
  • 10
2
votes
1 answer

Get mouse position in a QImage

I need to get the coordinates of a QImage of where the mouse is currently hovering. Like in image editing programs, where we can see the coordinates of the pixel the mouse in currently hovering.
petermlm
  • 930
  • 4
  • 12
  • 27
2
votes
1 answer

How to compare 2 QImages

How can we compare two QImages ? I have 2 QImages as below with some actual data in it: QImage image_1; QImage image_2; If I do a if(image_1 == image_2) & this returns true then does it mean the that the 2 QImages are pixel to pixel same? Or…
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
2
votes
1 answer

How to ensure even pixel size when painting scaled QImage?

I have a 4 channel png image with 8x8 Pixels that is loaded by a QImage. The QImage is then scaled by a factor of 200, so the image will have a new resolution of 1600x1600, each original pixel having a size of 200x200. But when this image is added…
ifschleife
  • 1,055
  • 1
  • 10
  • 21
2
votes
1 answer

Qt: How to clean up a QImage from memory

How to clear or clean up a QIMage Following method of mine get a const reference to a QIMage. MyMethod(const QImage & img) { // save it to a file img.save("/path/to/save/the/qimage"); // now I want to clan up img from memory. How should I do…
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
2
votes
0 answers

Dividing image to tiles in qt

I have a very big image (31000X26000 pixels). I need to create tiles of a given size from this image and store them. I'm trying to use Qt's QImagereader but I've notice that after setClipRect for the second time, it can't read from the image. The…
JLev
  • 705
  • 1
  • 9
  • 30
2
votes
2 answers

Qt: How to merge 2 QQuickItems into one before saving it into a png

From this discussion on StackOverflow, I am well able to save an image out of a QML item into a file as png/jpeg. How can I overlay or merge two different qml layers & merge them into one, to save it into a png/jpeg ? Note: I am able to save a…
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159