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
4
votes
1 answer

What is the difference between an opencv BGR image and its reverse version RGB image[:,:,::-1]?

I'm trying to show an opencv image with a QLabel. I got two different versions of the image, first one is the opencv BGR image, the second one is the RGB image using image[:,:,::-1], the BGR version works fine but the RGB version doesn't work. The…
Yifeng_Li
  • 133
  • 2
  • 6
4
votes
2 answers

QImage: convert from grayscale to RGB with a color table

With Qt, I am trying to convert a Format_Indexed8 image to Format_RGB30 by using a custom conversion rule defined by a color table. I thought this would be simple, since QImage::convertToFormat can take a color table as an argument, but I can't make…
mimo
  • 2,469
  • 2
  • 28
  • 49
4
votes
1 answer

Using FreeImage with Qt

I have a piece of C++/Qt code where I want to load images using the FreeImage library (http://freeimage.sourceforge.net/) and store the final result in a QImage. I know that Qt can load a bunch of image formats directly, but I want to be able to…
Irigum
  • 175
  • 6
4
votes
1 answer

Watching a QImage during single-stepping

I'm debugging a huge Qt app with hundreds of classes, messy code, etc. While tracking down a bug, I want to single-step in gdb (kdbg, ddd, whatever) while watching what gets drawn into a QImage using a QPainter that's carried about from method to…
DarenW
  • 16,549
  • 7
  • 63
  • 102
4
votes
2 answers

Constructing QImage from unsigned char* data

I encountered a problem with passing Image object (captured with Point Grej FlyCapture2 SDK) to QImage object. I am getting a pointer associated with Image data by function: virtual unsigned char* FlyCapture2::GetData ( ) and then loading the…
Marcin
  • 1,104
  • 4
  • 17
  • 27
4
votes
0 answers

Qt: What is the most scalable way to iterate over a QImage?

I'm aware of two methods in order to access to all the pixels in a QImage called img. Method 1 for (int y = 0; y < img.height(); y++) { QRgb *line = (QRgb *) img.scanline(y); for (int x = 0; x < img.width(); x++) { // line[x] has an…
logo_writer
  • 283
  • 2
  • 10
4
votes
2 answers

QImage::fill(Qt::red) always black?

I am trying to figure out, how QImage works. For start i just want to create a 400x400 pixel QImage and try to fill it red. Well the QImage is filled but black... Also i want to create a monochromatic QImage. One color should be transparent and the…
honiahaka10
  • 772
  • 4
  • 9
  • 29
4
votes
2 answers

QImage with QThreads

The following scenario: I got a multiple video stream which I get from OpenCV and display in my QML GUI through a realization of a QQuickImageProvider. A signal is emitted if the images change which causes my images in the GUI to call the providers…
bluewater2
  • 160
  • 7
4
votes
1 answer

How do I detect if a QImage is animated?

I'm using Qt 5.2 and I have a QImage. If it detects an image url (such as an imgur link) it downloads that image and displays it. I want to also animate it if the image is animated (such as a gif). I tried going by extension, but some links will end…
Ben
  • 764
  • 4
  • 19
4
votes
0 answers

using QImage to display dpx or exr through QPixmap

How do I display a exr or dpx file format image using QImage through QPixmap ? Somebody told me QImage does the I/O operation for which plugins need to be installed !! this is really confusing me now.
Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197
4
votes
1 answer

Pass a QImage object between class methods

I have two functions. In one function, i have a QImage and then i want to pass that QImage to another function. Both the function have different Arguments. Please tell me how can i do it? CMakeLists.txt cmake_minimum_required(VERSION…
skm
  • 5,015
  • 8
  • 43
  • 104
4
votes
1 answer

Convert 16-bit grayscale to QImage

I am working on a sensor-based Python application built on a PyQt4 GUI. The sensor is generating 16-bit measurements... 256 16-bit "pixels" per "line". A square "image" is acquired by obtaining 256 lines, resulting in a (256,256) Numpy array of…
ph0t0n
  • 735
  • 1
  • 10
  • 24
4
votes
3 answers

Painting Issue on QWidget outsite GUI thread

I am developing an appliation in which I want to continuously receive images from remote host and display them on my screen. for this I am following the given strategy 1) I have a main QWidget object which contains the QImage on it (works fine) 2)…
Muhammad Ummar
  • 3,541
  • 6
  • 40
  • 71
4
votes
1 answer

Am I responsible for calling delete on the pointer provided by the QImage::bits() function?

The Qt class QImage has two versions of its bits() function that returns a pointer to the underlying image data. One is const, the other is not. Here is the documentation for the non-const version: Returns a pointer to the first pixel data. This is…
Tim MB
  • 4,413
  • 4
  • 38
  • 48
4
votes
2 answers

How to crop a QImage to its opaque area?

If I have a QImage with an alpha channel, how can I create a new QImage which is cropped to the bounding box of the opaque area?
Daniel
  • 2,032
  • 5
  • 21
  • 27