qpixmap

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

ぃ、小莉子 提交于 2019-12-22 11:27:47
问题 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),

threading: It is not safe to use pixmaps outside the GUI thread

会有一股神秘感。 提交于 2019-12-21 16:59:24
问题 I'm building a music player, that checks the status with SqueezePlay, which is a SqueezeBox controller app. To cut a long story short, I'm checking the status of Squeezeplay ever 5 seconds by using threading. If the song title changes, I let it update the labels (Qlabel, album artwork (QPixmap), etc. However, when I ask it to update it via threading, I'm getting It is not safe to use pixmaps outside the GUI thread . How can I do threading but still set the QPixmap? Sample code: #self.sq

What is the best way to get the hash of a QPixmap?

痴心易碎 提交于 2019-12-21 05:17:30
问题 I am developing a graphics application using Qt 4.5 and am putting images in the QPixmapCache, I wanted to optimise this so that if a user inserts an image which is already in the cache it will use that. Right now each image has a unique id which helps optimises itself on paint events. However I realise that if I could calculate a hash of the image I could lookup the cache to see if it already exists and use that (it would help more for duplicate objects of course). My problem is that if its

QPainter::drawPixmap() doesn't look good and has low quality?

妖精的绣舞 提交于 2019-12-21 02:30:28
问题 I'm trying to draw an icon(.png) inside a QWidget with QPainter::drawPixmap() : QPixmap _source = "/.../.png"; painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.drawPixmap(rect(), _source); but in comparing to QLabel (for example) and in lower size (19*19 in my case) the result isn't perfect. What can I do? ****Edit**** QLabel with pixmap @ size 19*19: My painting @ size 19*19 via SmoothPixmapTransform render type: 回答1: You are setting the wrong render hint, you need QPainter:

How to create screenshot of QWidget?

别说谁变了你拦得住时间么 提交于 2019-12-20 19:41:35
问题 I work at my homework in Qt Creator, where I paint to QWidget and I need to save some part of this QWdiget. I tried to solve this problem: QPixmap pixmap; pixmap.copy(rectangle); // rectangle is part of QWidget, which I need to save pixmap.save("example.png"); Thank you for help. 回答1: You can use QWidget::render for this. Assuming rectangle is a QRect: QPixmap pixmap(rectangle->size()); widget->render(&pixmap, QPoint(), QRegion(rectangle)); 回答2: From QWidget::Grab: QPixmap QWidget::grab(const

Image Viewer GUI fails to properly map coordinates for mouse press event

不想你离开。 提交于 2019-12-19 04:52:11
问题 I am trying to piece together PyQt5 based image viewer Python code from various sources and extend capability to crop regions of interest (ROI) within loaded images. The issue is that the mapped coordinates and mouse clicks consider scroll bar and menu bar when determining pixel locations. Following is the code that loads image and provide bounding box capability, but I cannot seem to draw/crop boxes accurately due to the offset. from PyQt5.QtCore import QDir, Qt from PyQt5.QtGui import

is there any way to insert QPixmap object in html?

旧城冷巷雨未停 提交于 2019-12-19 03:13:44
问题 Simple situation: I have an object, which has a QPixmap member. Object first created (pixmap is null now), then pixmap readed from data base and inserted in object. I need to insert that pixmap in html code () and display that html code in a QLabel but I have no idea how to make it, because pixmap's path is unknown. I know how to insert images from resource files and from files on my hard-disk, but it isn't that case. I was using QMimeSourceFactory class on qt 3.3.4, but on 4.6.2 it is

How to use QPainter on QPixmap

寵の児 提交于 2019-12-18 14:52:18
问题 I'm a newbie to Qt/Embedded. I want to use QPainter to draw stuff on a QPixmap , which will be added to QGraphicsScene . Here is my code. But it does not show the drawings on the pixmap. It shows only the black pixmap. int main(int argc, char **argv) { QApplication a(argc, argv); QMainWindow *win1 = new QMainWindow(); win1->resize(500,500); win1->show(); QGraphicsScene *scene = new QGraphicsScene(win1); QGraphicsView view(scene, win1); view.show(); view.resize(500,500); QPixmap *pix = new

How to use QPainter on QPixmap

余生颓废 提交于 2019-12-18 14:52:02
问题 I'm a newbie to Qt/Embedded. I want to use QPainter to draw stuff on a QPixmap , which will be added to QGraphicsScene . Here is my code. But it does not show the drawings on the pixmap. It shows only the black pixmap. int main(int argc, char **argv) { QApplication a(argc, argv); QMainWindow *win1 = new QMainWindow(); win1->resize(500,500); win1->show(); QGraphicsScene *scene = new QGraphicsScene(win1); QGraphicsView view(scene, win1); view.show(); view.resize(500,500); QPixmap *pix = new

Convert 16-bit grayscale to QImage

£可爱£侵袭症+ 提交于 2019-12-18 06:50:23
问题 I am working on a sensor-based Python application built on a PyQt4 GUI. The sensor is generating 16-bit measurements... 256 16-bit "pixels" per "line". A square "image" is acquired by obtaining 256 lines, resulting in a (256,256) Numpy array of 16-bit numbers. I simply want to display this as a grayscale image. The sensor loop is running in a QThread and emits a QImage signal. The signal connects to a slot that renders the data in the main GUI by packing it into a 32-bit RGB image. Of course,