ImageItem is extremely slow when dragging. Can we somehow cope with it?

38 views
Skip to first unread message

Buraddin

unread,
Sep 30, 2017, 4:58:03 PM9/30/17
to pyqtgraph
I want to set a ImageItem as background to my PlotWidget. Alas, when I add the ImageItem and then try to drag my plot viewport by mouse, it becomes extremely slow.

Can we somehow cope with it?

Here's a small sample:



# -*- coding: utf-8 -*-

import sys

from PyQt5 import QtCore
from PyQt5.QtWidgets import QApplication, QWidget

import pyqtgraph
import cv2

import numpy as np


if __name__ == '__main__':

app = QApplication(sys.argv)

app.setStyle("fusion")

plot_widget = pyqtgraph.PlotWidget()
plot_widget.show()

plot_item = plot_widget.getPlotItem()

in_image = cv2.imread("D:/Projects/radar_lab_models/radar_lab_models/gui/sample.png")

b_channel, g_channel, r_channel = cv2.split(in_image)
alpha_channel = np.ones(b_channel.shape, dtype=b_channel.dtype) * 128 # creating a dummy alpha channel image.
bgra_image = cv2.merge((b_channel, g_channel, r_channel, alpha_channel))

# background
background_item = pyqtgraph.ImageItem()
background_item.setImage(bgra_image, autoDownsample=True)
background_item.setRect(QtCore.QRectF(-100e3, -100e3, 200e3, 200e3))
plot_widget.addItem(background_item)


sys.exit(app.exec_())
Reply all
Reply to author
Forward
0 new messages