qimage

How can access to pixel data with PYQt' QImage scanline()

空扰寡人 提交于 2019-12-04 14:05:34
I need to access the pixel data in a qimage object with PyQt4. The .pixel() is too slow so the docs say to use the scanline() method. In c++ I can get the pointer returned by the scanline() method and read/write the pixel RGB value from the buffer. With Python I get the SIP voidptr object that points to the pixels buffer so I can only read the pixel RGB value using bytearray but I cannot change the value in the original pointer. Any suggestions? Luke Here are some examples: from PyQt4 import QtGui, QtCore img = QtGui.QImage(100, 100, QtGui.QImage.Format_ARGB32) img.fill(0xdeadbeef) ptr = img

High performance QImage output to display

廉价感情. 提交于 2019-12-04 12:57:37
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_outputFrameImage); // BAD, slow and high load /* Bad too (Same code?) QPainter painter; painter.begin(

Render QImage with OpenGL

拥有回忆 提交于 2019-12-04 09:37:44
问题 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 convertToGLFormat(img) . glEnable(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glGenTextures(1, &offscreenBufferTexture); glBindTexture(GL_TEXTURE_2D, offscreenBufferTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imgGL.width(), imgGL.height(), 0, GL_RGBA, GL

Shifting the hue of a QImage / QPixmap

亡梦爱人 提交于 2019-12-04 08:30:54
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 the Qt Docs goes this far into image manipulation, just altering alpha and colors. Should I look into

Pass QImage to QML

痴心易碎 提交于 2019-12-03 17:14:18
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 = preview; previewImage.source = manipulaImagem.recortarFotoPerfil(preview, viewfinder.mapRectToSource(Qt

Fastest method to convert IplImage IPL_DEPTH_32S to QImage Format_RGB32

我只是一个虾纸丫 提交于 2019-12-02 11:39:39
What is the fastest method to convert IplImage IPL_DEPTH_32S to QImage Format_RGB32? I need to catch pictures from cam and show it on form with frequency 30 frames in second. I tried to use QImage constructor: QImage qImage((uchar *) image->imageData, image->width, image->height, QImage::Format_RGB32); but image was corrupted after this. So, how can I do this fast (I think putting pixel by pixel into QImage is not a good decision)? karlphillip Before I start, OpenCV uses the BGR format by default . Not RGB! So before creating the QImage you need to convert your IplImage to RGB with: cvtColor

Image copied to clipboard doesn't persist on Linux

可紊 提交于 2019-12-02 04:53:06
I'm trying to save an image to the system clipboard, so I wrote some code like this: #!/usr/bin/python3 from PyQt5.Qt import QApplication from PyQt5.QtWidgets import QWidget, QPushButton from PyQt5.Qt import QImage import sys class MyWidget(QWidget): def __init__(self): super(MyWidget, self).__init__() self.button = QPushButton(self) self.button.clicked.connect(self.copyPicToClip) def copyPicToClip(self): image = QImage('./test.jpg') QApplication.clipboard().setImage(image) self.close() if __name__ == '__main__': a = QApplication(sys.argv) myW = MyWidget() myW.show() a.exec() Sadly, I found it

Is QImage able to open and render pure 16-bit images?

青春壹個敷衍的年華 提交于 2019-12-02 03:33:14
I think the headline already explains what I want to know. Is there a possible way to open and save images with 16-bit with Qt? And I don't mean the 3*8=24bit or 4*8=32bit, what is quite the same as a pure 8-bit image, I mean pure 16-bit for R, G and B. Contrary to what Patrice says, there is no 16 bits per component format in QImage . The most you can get is QImage::Format_ARGB32 at 8 bits per component. Even if you used 8 bits indexed mode, the color tables do not support more than 8 bits per component. Moreover, the QImageIOHandler class works in terms of QImage , so you cannot create a

Qt does not load JPG , just PNG

最后都变了- 提交于 2019-12-01 19:20:56
I work with my colleagues on the same project on Windows 7 64 bit version, Visual Studio 2008. They load JPG and they work. Through QPixmap and Stylesheets. And works. But for me, i can only work with PNG, the rest don´t work at all. I also tried to change paths on the environment variables, but i only see one Qt path (the bin) on it. Nothing about plugins, i guess... as i read on the documentation: "By default, Qt can read the following formats: Format Description BMP Windows Bitmap GIF Graphic Interchange Format (optional) JPG Joint Photographic Experts Group JPEG Joint Photographic Experts

Qt Image from resource file

我怕爱的太早我们不能终老 提交于 2019-12-01 17:24:12
问题 I'm trying to insert an image to my program via resource file, which is like: <RCC> <qresource prefix="/"> <file>green.png</file> <file>other files</file> </qresource> </RCC> and when I'm trying to load it using QImage or QPixmap, like: QImage *green = new QImage(":/green.png"); if(green->isNull()) qDebug("null"); I always see that null message, indicating that I'm doing something wrong. One solution may be using absolute path like "C:\\Users\\user\\Documents\\project\\green.png", which works