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_())

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/3b8c8639-de86-418f-bc88-5a702b57bcaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to