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
10
votes
12 answers

Enabling JPEG support for QImage in py2exe-compiled Python scripts?

I'm trying to use a JPEG image in a QImage object from a Python script, with PyQt4. The script itself works perfectly, the image loads and can be manipulated and rendered and all. However, when I try to "compile" this script with py2exe,…
Etienne Perot
  • 4,764
  • 7
  • 40
  • 50
10
votes
1 answer

How to resize a QImage or QML Image to fit parent container without breaking the Image's aspect ratio

Scenario: I have an Image component in QML which contains a QImage of varied aspect ratios. Code: Window { id: app_window visible: true Rectangle { id: my_image_view_container width: app_window.width height: app_window.height …
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
10
votes
1 answer

Draw text on image using Qt

I want to draw text on an image. I use this code, but I do not see any text on the image. void ImageSaver::save(const QString &path) const { QImage image(img_); QPainter p(&image); p.setPen(QPen(Qt::red)); p.setFont(QFont("Times",…
neda
  • 329
  • 1
  • 4
  • 15
9
votes
1 answer

How to effectively scroll 1024x90000 image in a window?

I have the following UI, where the sonogram (freq+time sound representation) is shown. So the image is not loaded from somewhere, it is drawn by QPainter while reading WAV file. My current implementation is a single huge QImage object, where the…
pavelkolodin
  • 2,859
  • 3
  • 31
  • 74
9
votes
3 answers

Using QImage with OpenGL

I've very recently picked up Qt and am using it with OpenGL The thing though is that when moving my SDL code to Qt and changing the texture code to use QImage it stops working. The image does load correctly, as shown through the error checking…
Prime
  • 4,081
  • 9
  • 47
  • 64
8
votes
2 answers

Pass QImage to QML

I am trying to pass a QImage to QML. Could someone help me? The code is below. The problem is that all my attempts to make the image available for the image provider fail. I have tried using a Q_PROPERTY and a QImage member inside the class, but my…
GuiDupas
  • 1,681
  • 2
  • 22
  • 44
7
votes
3 answers

How to make a QImage or QPixmap semi-transparent - or why is setAlphaChannel obsolete?

4.7 and like to overlay two images on a qgraphicsview. The image on top shall be semi-transparent to allow to see through it. Initially both images are fully opaque. I expected some function for setting a global alpha-value for each pixel to exist,…
FFox
  • 1,550
  • 2
  • 17
  • 26
7
votes
2 answers

QImage skews some images but not others

I'm working with tif stacks and QImage appears to be skewing some images to a 45 degree angle. Matplotlib is able to display the images without a problem in both test cases (links to two tif stacks are provided below) so I don't think I've screwed…
onjre
  • 403
  • 1
  • 3
  • 13
7
votes
4 answers

convert QVideoFrame to QImage

I want to get every frames from a QMediaPlayer and convert it to QImage (or cv::Mat) so I used videoFrameProbed signal from QVideoProbe: connect(&video_probe_, &QVideoProbe::videoFrameProbed, [this](const QVideoFrame& currentFrame){ …
uchar
  • 2,552
  • 4
  • 29
  • 50
7
votes
2 answers

Render QImage with OpenGL

Related to my other question, I think the more central question would be, how you render a QImage with OpenGL? I think the code has to look something like this, but I'm not sure what else I need, besides maybe…
Dreiven
  • 687
  • 3
  • 9
  • 22
7
votes
3 answers

Qt: QImage always saves transparent color as black

How do I save a file with transparency to a JPEG file without Qt making the transparent color black? I know JPEG doesn't support alpha, and the black is probably just a default "0" value for alpha, but black is a horrible default color. It seems…
Charles Burns
  • 10,310
  • 7
  • 64
  • 81
7
votes
3 answers

QImage from HBITMAP

In my windows-only program, I use a third-party library, which returns a HBITMAP. Is there a way to initialize a QImage from its contents, i.e. to convert it to a QImage?
sashoalm
  • 75,001
  • 122
  • 434
  • 781
7
votes
3 answers

Raw data to QImage

I'm new to graphics programming (pixels, images, etc..) I'm trying to convert Raw data to QImage and display it on QLabel. The problem is that, the raw data can be any data (it's not actually image raw data, it's binary file.) The reason if this is…
Nika
  • 1,864
  • 3
  • 23
  • 44
7
votes
3 answers

Dividing QImage to smaller pieces

I have an image, and I want to divide this image to n pieces. So what I'm wondering is that how can I do this with QImage? Or is there a better(performance wise) Qt class for this task? For example imagine I have an image consist of 1920x1080…
Malkavian
  • 372
  • 1
  • 5
  • 16
6
votes
3 answers

QGraphicsView scrolling and image scaling/cropping

I would like to have a background image in my QGraphicsView that is always scaled (and cropped if necessary) to the size of the viewport, without scrollbars and without scrolling with the keyboard and mouse. The example below is what I am doing to…
user298725
  • 63
  • 1
  • 1
  • 4
1
2
3
36 37