qimage

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

╄→尐↘猪︶ㄣ 提交于 2020-01-14 14:08:13
问题 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* testFunc(); } #endif // TEST_H test.cpp: #include "test.h" #include <QtGui> QImage image; uchar* testFunc(){ image.load("c:\\1.png","PNG"); return (uchar*)image.constBits(); } and in the Delphi Side I use this code for using Qt dll: function testFunc(): PByteArray; external

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

拜拜、爱过 提交于 2019-12-28 01:00:33
问题 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, everything works but the JPEG image. Replacing it with a PNG equivalent works, but since my program downloads images from the web, they won't always be in PNG format and I can't afford converting them all with another library. I've discovered that JPEG image

`QImage` constructor has unknown keyword `data`

百般思念 提交于 2019-12-25 01:11:29
问题 Suppose I am taking an image from the webcam using opencv. _, img = self.cap.read() # numpy.ndarray (480, 640, 3) Then I create a QImage qimg using img : qimg = QImage( data=img, width=img.shape[1], height=img.shape[0], bytesPerLine=img.strides[0], format=QImage.Format_Indexed8) But it gives an error saying that: TypeError: 'data' is an unknown keyword argument But said in this documentation, the constructor should have an argument named data . I am using anaconda environment to run this

How to use QImage repeatedly?

霸气de小男生 提交于 2019-12-24 21:23:19
问题 I have a horizontal sprite of images. This one for example: All the images have the same width and height. I have stored it in my resources file, and declared it in my application by a define : #define SPRITE QImage(":/sprite.png") So there are 4 images that I will need several times in my application. In order to do this, I implemented this function which retrieves the image at the position n in the sprite. QImage getNthImageFromSprite(int n, QImage sprite) { int size = sprite.height();

How to render custom video data in Qt ?

梦想与她 提交于 2019-12-24 09:21:03
问题 I have never done a Qt video application - newbie in this area. I have a custom video file format to render using Qt. The video file format is 256-byte header, then pixel data, then 256-byte header, then pixel data and so on. The header consist info like width, height in pixels, bytes per pixels, frame rate etc and the pixel data is in Bayer (GBRG). I may have to process data before display - like convert to RGB (not sure yet). I see there are lot of video related classes like QGL*, QMovie,

Qt QImage to QPixmap Conversion loses Color Information for UI

好久不见. 提交于 2019-12-24 05:11:56
问题 I am trying to update a QPixmap on a QLabel in my main Qt UI. The following slot is called to do this with the "newImage" variable QImage ( because it's from a different thread ). The QImage is converted to someImage with convertFromImage ( I've also tried ::fromImage ). If I just save the QImage "newImage" to file, I get a green rectangle and red text that I draw with OpenCV earlier on, however, if I save the converted pixmap OR show the converted pixmap I lose the color for the rectangle

How to convert a cv::Mat to QImage or QPixmap?

匆匆过客 提交于 2019-12-24 04:11:00
问题 I've tried to look around and tried everything I've found, but haven't found a solution for this problem. I'm trying to update an image in a QT application by button click. In the constructor I've managed to show a image: cv::Mat temp = cv::Mat(*this->cv_size,CV_8UC3); temp = cv::Scalar(0,255,155); ui->image->setPixmap(QPixmap::fromImage( Mat2QImage(temp))); And then I've created a button and linked this function to it void UIQT::refreshImage(){ cv::Mat temp = cv::Mat(*this->cv_size,CV_8UC3);

CImg library creates distorted images on rotation

你说的曾经没有我的故事 提交于 2019-12-24 03:34:11
问题 I want to use the CImg library (http://cimg.sourceforge.net/) to rotate an image with an arbitrary angle (the image is read by Qt which should not perform the rotation): QImage img("sample_with_alpha.png"); img = img.convertToFormat(QImage::Format_ARGB32); float angle = 45; cimg_library::CImg<uint8_t> src(img.bits(), img.width(), img.height(), 1, 4); cimg_library::CImg<uint8_t> out = src.get_rotate(angle); // Further processing: // Data: out.data(), out.width(), out.height(), Stride: out

Better way to load QPixmap data

情到浓时终转凉″ 提交于 2019-12-23 19:41:07
问题 Better way to do it (without QImage )?: QImage image(width, height, QImage::Format_RGB888); memcpy(image.bits(), m_frameRGB->data[0], height * width * 3); QPixmap pixmap = QPixmap::fromImage(image); I don't see any reason to use QImage as intermediate buffer, but QPixmap::loadFromData don't load data with this context: pixmap.loadFromData(m_frameRGB->data[0], height * width * 3); // Need pixmap resize? 回答1: The documentation says: "If the format is not specified (which is the default), the

How can I decrease the amount of time it takes to save a png using QImage?

蹲街弑〆低调 提交于 2019-12-23 12:28:52
问题 Using Qt 4.8rc1, I have a QImage that I want to convert to a png file. It seems like it is taking longer than it should to convert to png format: ~70ms for an 800x800 empty png. Is there a way I can make this more efficient, or am I just inherently limited by png/zlib? Here is the benchmark I am running: #include <QtGui> #include <QTimer> int main(int argc, char *argv[]) { int times = 1000; QString format("png"); QByteArray ba; QBuffer* buffer = new QBuffer(&ba); buffer->open(QIODevice: