Skip to content

ScatterPlotItem: use Format_ARGB32_Premultiplied#2317

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
pijyoi:scatter_qimage_fmt
May 29, 2022
Merged

ScatterPlotItem: use Format_ARGB32_Premultiplied#2317
j9ac9k merged 1 commit intopyqtgraph:masterfrom
pijyoi:scatter_qimage_fmt

Conversation

@pijyoi
Copy link
Copy Markdown
Contributor

@pijyoi pijyoi commented May 29, 2022

From https://doc.qt.io/qt-5/qimage.html: "Rendering is best optimized to the Format_RGB32 and Format_ARGB32_Premultiplied formats"

RGB32 and ARGB32_Premultiplied are the preferred formats to use for
rendering with QPainter.
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented May 29, 2022

@danielhrisca @ibrewster you two seem to have some extreme scatter plot performance needs, curious if this change will make a noticeable impact for you.

@pijyoi
Copy link
Copy Markdown
Contributor Author

pijyoi commented May 29, 2022

Oh, there should be no measurable impact because the QImage(s) being rendered to are very small.
This is more to do with code correctness (as far as Qt docs are concerned).

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented May 29, 2022

LGTM @pijyoi nice catch in the docs! Merging.

@j9ac9k j9ac9k merged commit ab09092 into pyqtgraph:master May 29, 2022
@pijyoi pijyoi deleted the scatter_qimage_fmt branch May 29, 2022 03:32
@danielhrisca
Copy link
Copy Markdown
Contributor

@danielhrisca @ibrewster you two seem to have some extreme scatter plot performance needs, curious if this change will make a noticeable impact for you.

I've had to step away from the default plotting functionality provided by pyqtgraph.

Essentially the following goes on:

  • there is only one viewbox instead of individual viewbox/curve
  • I use the curve objects as storage, but I don't add them to the plotitem
  • in the reimplemented paintEvent the curves are scaled and drawn on the viewport. In case of scatter plots I use QPainter.drawPoints and set the pen width and cap style to get de desired pixel size and shape
  • there is also the functionality to have different curve colors depending on certain conditions (eq. y > 300 => red color). This is done by drawing the segments on top of the default curve polygon
  • the painted curves are stored to a qpixmap that only gets updated if the user changes the x or y ranges or if curves are disabled or enabled. With this approach the pixmap gets painted and then I can have an infinte line acting as a cursor that can be moved around with minimal performance impact (in the older implementation moving the cursor would trigger the repaint of all the curves)

If anybody is interested the code is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants