qimage

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

萝らか妹 提交于 2019-12-06 17:36:35
问题 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 . 回答1: Yes, use a QPainter to paint into a QPaintDevice, QImage is a QPaintDevice, so it works. 回答2: QImage srcImage = QImage(100, 100); QImage destImage = QImage(200, 200); QPoint destPos = QPoint(25, 25); // The location to draw the source image within the dest srcImage.fill(Qt::red); destImage.fill(Qt::white); QPainter painter(&destImage); painter

PyQt5 - Add image in background of MainWindow layout

Deadly 提交于 2019-12-06 14:27:36
问题 New to PyQt5... Here is a very basic question. I would like to add an image inside the layout of a widget. This widget is the Main Window / root widget of my application. I use the following code, but I get an error message. import sys from PyQt5.QtGui import QImage from PyQt5.QtWidgets import * class MainWindow(QWidget): def __init__(self): super().__init__() self.setGeometry(300,300,300,220) self.setWindowTitle("Hello !") oImage = QImage("backgound.png") oLayout = QVBoxLayout() oLayout

High performance QImage output to display

a 夏天 提交于 2019-12-06 06:37:58
问题 I'm trying to make video output (sequence of frames) to any qt visible widget. At beginning i thought that QLabel will be enough for this point... but i was wrong. Converting to pixmap is too overloading for processor at large images: 1080p for example. Any other solution? (not QLabel?) Example of code for one frame: QImage m_outputFrameImage(width, height, QImage::Format_RGB888); memcpy(m_outputFrameImage.bits(), m_frameRGB->data[0], height * width * 3); QPixmap pixmap = QPixmap::fromImage(m

Why is there bit shifting when converting to an image from an array?

匆匆过客 提交于 2019-12-06 04:20:11
I'm trying to create a QPixmap from a numpy array. The numpy array image is going to be 2D (ie no color info just grayscale). I'm trying to adapt this answer to my needs however I don't quite understand this line: b = (255 << 24 | a[:,:,0] << 16 | a[:,:,1] << 8 | a[:,:,2]).flatten() # pack RGB values There is some bitshifting going on and some bitwise or ' ing but I don't quite get it to be honest. So my dumbed down example is as follows: x, y = np.meshgrid(np.arange(1920), np.arange(1080), indexing='ij'); z = np.sin(0.03*x)*np.cos(0.005*y) imgPNFN = z if imgPNFN.ndim == 2: imgPNFN = imgPNFN[:

Shifting the hue of a QImage / QPixmap

浪子不回头ぞ 提交于 2019-12-06 04:01:17
问题 I suppose this is more of a graphics manipulation question in general, but I'd like to accomplish this in Qt (c++). If I have an image - let's just say a circle on a transparent background - of a light gray color, is there any built-in functionality in Qt to shift the hue / saturation to color it? I suppose I could go pixel by pixel, and modifying the rgb mathematically - add x to r, g, and b, to get a desired color, but there must be a better way than modifying every single pixel. Nothing in

QGraphicsView scrolling and image scaling/cropping

萝らか妹 提交于 2019-12-06 03:06:21
问题 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 scale and crop an image in the viewport, but I am using random values for the cropping that are pulled out of the aether. I would like a logical solution? MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui-

Constructing QImage from unsigned char* data

倾然丶 夕夏残阳落幕 提交于 2019-12-05 13:23:01
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 data by: QImage::QImage ( uchar * data, int width, int height, int bytesPerLine, Format format ) Formats of data of both Image objects are 8-bit monocolor. BytesPerLine parameter should be equal to width of the Image (I've already checked it by saving FlyCapture2::Image to .bmp and then loading it to QImage). Do you thing the problem is casting from

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

↘锁芯ラ 提交于 2019-12-05 06:55:37
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, but it seems like there is no such function. The closest thing to it is QPixmap::setAlphaChannel(const QPixmap & alphaChannel), which, however, is marked as obsolete since Qt-4.6. Instead the manual refers to the CompositionModes of QPainter, but I don't succeed to add transparency to an opaque image like I want. Could anyone point me to a working

Pass QImage to QML

…衆ロ難τιáo~ 提交于 2019-12-05 02:34:34
问题 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 provider always returns a null image when I try to access it to return. How can I make the QImage available for the provider? QML Camera { id: camera captureMode: Camera.CaptureStillImage imageCapture { onImageCaptured: { manipulaImagem.imagem =

Qt / C++ - Converting raw binary data and display it as an image (i.e. QImage)

扶醉桌前 提交于 2019-12-04 14:08:19
问题 I have a C++ Open GL application that renders an animation display, and captures the frame-buffer contents using glReadPixels(), which is then stored as a 1D char array. I can get the buffer contents and save it to a char array, as follow: char * values = (char *) malloc(width * height * 4 * sizeof(char)); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, values); I then send these raw data over the network using socket, which is not an issue for me. I have a Qt Desktop Client