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

Is the endian-ness of a QImage created from a uchar[] platform-dependent?

QImage has a constructor QImage (uchar *data, int width, int height, int bytesPerLine, Format format) that creates a QImage from an existing memory buffer. Is the order of bytes (uchars) platform-dependent? If I put the values for alpha, red, green,…
Jens Müller
  • 302
  • 4
  • 13
3
votes
2 answers

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

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*…
Shaahin Ashayeri
  • 918
  • 2
  • 13
  • 30
3
votes
2 answers

Connecting slider to Graphics View in PyQt

I'm trying to display image data read in from a binary file (I have the code written for retrieving this data from a file and storing it as an image for use with QImage() ). What I would like to do is connect a slider to a Graphics View widget so…
Victoria Price
  • 637
  • 3
  • 13
  • 26
3
votes
2 answers

QIcon/QImage memory leak?

I'm facing some memory leaks using QIcon (Qt 4.8.1 with MSVC 2008). This happens with simple QAction (like menu entries, even those generated automatically by Qt Designer) or container items (like QTreeWidgetItem). For example: QTreeWidgetItem…
XDnl
  • 470
  • 3
  • 14
3
votes
2 answers

drawText() on a QImage crashes program

I have an image in uint8_t buffer and I am trying to use QImage as a wrapper to write text on the image. I have used drawLine() with no issues, but drawText() crashes the program. The below code is part of a boost thread in which I want to write…
JonnyCplusplus
  • 881
  • 3
  • 12
  • 22
3
votes
1 answer

Qt combine two images using QTransform

I am facing a problem which is probably easy to solve but I do not get it right: I have two QImages, a fixed-size background image imgBg, and a second QImage imgFg which should be transformed using affine transformations and then painted (and…
Hyndrix
  • 4,282
  • 7
  • 41
  • 82
2
votes
2 answers

How to set QImage pixel colour for an RGB888 image in Qt

I have an RGB888 format qImage defined as follows: myQrgb = QImage(img_in, width, height, QImage::Format_RGB888); I wish to alter specific pixel values, so I followed the example here, like so: QRgb value = qRgb(0, 0, 0); myQrgb.setPixel(i, j,…
Bill Cheatham
  • 11,396
  • 17
  • 69
  • 104
2
votes
1 answer

Can overloaded new operator receive args to pass to the object's constructor?

I see a lot of C++ libraries dealing with dynamic memory allocation this way: Qimage* _image = new QImage(width, height, QImage::Format_RGB888); if (!_image) { // Failed! } I find it interesting that it is possible to check whether an object…
karlphillip
  • 92,053
  • 36
  • 243
  • 426
2
votes
1 answer

Qt : QImage load data from memory

I am new to StackOverFlow and wish there are experts to my problem, which consumed me a week time! I embedded my JPEG files into a single data file, and need to load them on demand to avoid memory problem in mobile phone. I wrote something…
xuxiang
  • 45
  • 1
  • 6
2
votes
2 answers

Qt breakout game

I'm new to Qt and have been trying to get this tutorial to work: http://zetcode.com/gui/qt4/breakoutgame/ Can someone help me out with what my main function would look like? And where should the images be stored so that they can be referenced with…
Dash
  • 17,188
  • 6
  • 48
  • 49
2
votes
1 answer

How to load an image from a buffer with Qt?

Thus type: QBuffer* buffer = new QBuffer(this->Conex); QImage* image = new QImage (); image->loadFromData (buffer->buffer()); This does not work for me.
user950489
  • 21
  • 1
  • 4
2
votes
1 answer

Can't save Images using QImage

I wish to use QImage in Qt to load and save images. While I can load an image, for whatever reason it wont let me save the image. So I started writing a simple code, made a simple png test file using paint, put it into the same folder as the project…
2
votes
1 answer

Why does this code make the QImage lose its alpha channel?

I'm trying to understand why the code below changes the QImage in Qt. It's not meant to do anything (yet), it's just for testing. When I run the code on an image with alpha, the alpha channel is lost and replaced by a black background. QImage…
laurent
  • 88,262
  • 77
  • 290
  • 428
2
votes
1 answer

Draw on a rects on a QImage without Showing it

I want to draw rectangles above an QImage and save the result as png. The minimal Example below should do this. from PyQt5.QtGui import QImage, QColor, QPainter, QBrush from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget import…
MaKaNu
  • 762
  • 8
  • 25
2
votes
1 answer

QImage: is there any lazy copying crop method

I was trying to use QImage for loading image and checking the equality with a template sub-image that moves all over the image. The code is as: for i in range(image.height() - backgroundMask.height() + 1): for j in range(image.width() -…
Xolve
  • 22,298
  • 21
  • 77
  • 125