qimage

Creating ARGB QImage from uint32 or uchar array

*爱你&永不变心* 提交于 2019-12-13 08:49:11
问题 When I try to create a ARGB32 QImage from a reinterpret_cast<uchar*>(quint32*) using the QImage constructor the Image looses its color and alpha channel and the resulting QImage is grayscale! The grayscale image is displayed as expected, if I was trying to display it in grayscale. So I know the scaling and indexing of ushort data to the quint32 array went well, but what is going wrong? A Qt forum post suggested to do it the way I am doing it (as far as I can see), but maybe behavior has

How to show a QImage without copying in QGraphicsScene

两盒软妹~` 提交于 2019-12-13 05:58:26
问题 I have my own image class containing an unsigned char array with RGB values. I would like to show images stored in this class, without copying them, in a QGraphicsScene. I can make an QImage with QImage image(data, width, height, width * 3, QImage::Format_RGB888); without copying my image. How can I show image in a QGraphicsScene without a deep copy of data? 回答1: With the default, raster paint engine/backend, the top-level widget's contents are stored as a QImage . Drawing a QImage (and a

How to display a QImage in QWebKit?

风格不统一 提交于 2019-12-13 03:30:54
问题 Is there any way to display a QImage (in memory, not on filesystem) in a QWebFrame without writing the image out to a temporary file? 回答1: One option might be using the data URI scheme. You basically base64 encode your picture and write the complete data into the URL. For example: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC WebKit should support

How can I convert pixel data in QImage to another format?

跟風遠走 提交于 2019-12-13 00:19:07
问题 I receive an instance of QImage with arbitrary QImage::Format . How can I create another instance of QImage with a particular QImage::Format of my choosing so that the actual image data is converted from the arbitrary format to my format? Example: QImage convertFormat(const QImage &inputImage, QImage::format outputFormat) { // What comes here? } //Usage QImage converted = convertFormat(mySourceImage, QImage::Format_Grayscale8); I am looking for a way to do this with existing code in Qt if

How to use QComboBox to choose how to save the format of a QImage

眉间皱痕 提交于 2019-12-13 00:07:30
问题 Sorry if this question is trivial but I have the following problem: I have N.1 QGraphicsView N.1 QComboBox I am trying to save the images uploaded on the QGraphicsView into a folder on my Desktop choosing the format of the image through a QComboBox . The loop I wrote it works for a .png file but I am stuck with other different formats as I am not sure how to correctly handle the QComboBox choice. See below the snipped of code I am using: mainwindow.h public: explicit MainWindow(QWidget

Qimage: out of memory, returning null image

随声附和 提交于 2019-12-12 02:06:54
问题 I am writing a code to show a video in a graphicsView QObject. It goes like this: void MainWindow::UpdateVideo() { cap >> frame; cvtColor(frame, frame,CV_BGR2RGB); QImage Qframe = QImage((uchar*) frame.data, frame.cols, frame.rows, frame.step, QImage::Format_RGB888); QPointer<QGraphicsScene> VideoScene = new QGraphicsScene; VideoScene->addPixmap(QPixmap::fromImage(Qframe)); ui->VideoView->setScene(VideoScene); ui->VideoView->show(); } void MainWindow::on_pushButton_2_clicked() { cap.open(

Qimage setPixel with openmp parallel for doesn't work

為{幸葍}努か 提交于 2019-12-11 18:27:45
问题 The code works without parallelism, but when I add pragma omp parallel, it doesn't work. Furthermore, the code works perfectly with pragma omp parallel if I don't add setPixel. So, I would like to know why the parallelism doesn't work properly and exits the program with code 255 when I try to set pixel in the new image. This code wants to change an image doing two loops to change every pixel using a Gauss vector. If something can't be understood I'll solve it inmediately. for (h = 0; h <

saving and loading vector<Mat> Qt & OpenCV

假装没事ソ 提交于 2019-12-11 14:04:07
问题 I'm working on face recognition in Qt & openCV using the FisherFaces recognizer which doesn't support updating so i have to save the faces database to retrain the recognizer after any changes. Here is my code for saving : save(const std::vector* MatVect){ QFile file("students_dataset.dat"); file.open(QIODevice::WriteOnly); QDataStream out(&file); QVector qimgvect; for (size_t i = 0; i < MatVect->size(); ++i) { cv::Mat matt = MatVect->at(i); QImage img((uchar*)matt.data, matt.cols, matt.rows,

QGraphicsPixmapItem::setPixmap() Performance?

痴心易碎 提交于 2019-12-11 10:18:54
问题 Since it seems I need to improve the performance of my code, I wanted to ask, how good is the performance of QGraphicsPixmapItem::setPixmap(*Qimage) ? My Image is 1024x1024 px and is updated about every 2.5seconds. But I need it to be updated much faster (4096x every 2.5 seconds at best). Is it possible with QGraphicsPixmapItem::setPixmap(*Qimage) ? I am filling every single pixel of QImage directly with an array: array[y*SCENEWIDTH+x] = color . But with that speed QGraphicsPixmapItem:

How to paint / deform a QImage in 2D?

雨燕双飞 提交于 2019-12-11 10:04:41
问题 I have a code that manipulates and renders a QImage onto a QWidget . Manipulation includes typical homogeneous transformations as well as clipping, applying a color-transfer function, etc. Now I have to deform the image onto a four-vertices polygon (a quad), not necessarily a rectangle. To be clear, I'm not talking about clipping the image, but deforming it. I know how to do it using OpenGL (a textured quad), but I wonder if it is possible to do it without switching to OpenGL. Does Qt have