Qimage Setpixel Format_indexed8
For a list of colors, I have a corresponding list of QImage, format mono. The mono images have been processed in such a way that a single pixel can be black from all images. Nov 19, 2015 Array of QImage other than QImage::FormatIndexed8. Ask Question 0. Until now I had a QImage with QImage::FormatIndexed8. I fill the array with the needed color datay.width+x = i and everything works fine. But now i need RGB instead of Indexed8 so I use QImage::FormatRGB32.
Im trying to initialise a blank QImage widget in a pyside gui but its throwing errors and I cant figure out what I'm supposed to do from the docs, does anyone know what steps i need to do to get this QImage Widget working
and here's the error i get:
2 Answers
EDIT: when giving this answer, the question was a different one than now..
Qimage Save Example
fill expects an int argument instead of a QColor element.
The advantage of using adaptive matrix metrics is twofold: it can be used to identify important molecular descriptors and at the same time it allows improving the classification accuracy.A recently proposed method making use of this concept is extended to multi-class data. Molecular descriptors for cheminformatics pdf creator.
Use
instead of
I hope this works exactly the same on pyside as in c++. Here is the documentation: http://doc.qt.nokia.com/4.7-snapshot/qcolor.html#qRgb
MischMischThe main issue is that a QImage is not a widget so it cannot be added to a layout. Below is the code for initialising the Qimage with a red background and placing it inside a QLabel widget. I also change the image format to ARGB32 so that the image is formatted with 4 x 8 bit values for Alpha, Red, Green and blue.
jonathan topfjonathan topfNot the answer you're looking for? Browse other questions tagged pythonqtpyside or ask your own question.
I have been able to display an image in a label in Qt using something like the following:
So fullCharArray is an array of unsigned chars that have been mapped from the 2D array imageData, in other words, it is imheight * imwidth bytes.
The problem is, it seems like only a portion of my image is showing in the label. The image is very large. I would like to display the full image, scaled down to fit in the label, with the aspect ratio preserved.
Also, that QImage format was the only one I could find that seemed to give me a close representation of the image I am wanting to display, is that what I should expect? I am only using one byte per pixel (unsigned char - values from 0 to 255), and it seems liek RGB32 doesnt make much sense for that data type, but none of the other ones displayed anything remotely correct
edit:Following dan gallaghers advice, I implemented this code:
But this causes my program to 'unexpectedly finish' with code 0
Qimage Python
DerekDerek3 Answers
QImage
has a scaled
member. So you want to change your setPixmap
call to something like:
Note that scaled
does not modify the original image qi
; it returns a new QImage
that is a scaled copy of the original.
Re-Edit:
To convert from 1-byte grayscale to 4-byte RGB grayscale:
Then scale qi
and use the scaled copy as the pixmap for viewLabel
.
Qt doesn't support grayscale image construction directly. You need to use 8-bit indexed color image:
Stephen ChuStephen ChuI've also faced similar problem - QImage::scaled returned black images. The quick work-around which worked in my case was to convert QImage to QPixmap, scale and convert back then. Like this:
where 'image' is the original image.I was not aware of format-problem, before reading this thread - but indeed, my images are 1-Bit black-white.
Regards,Valentin Heinitz
Valentin HeinitzValentin Heinitz