|
output in raw format (no compression) |
Posted by Laurent Riesterer on Apr-02-2012 21:26 |
|
I am evaluating CharDirector to produce about ten graphs refreshed every seconds. Each graph is composed of 4 lines of data. The program will run under Linux/X11.
The graphing itself is fast (using the c.makeChart3() method), put generating an output is about the same time (BMP) or twice the time (PNG) as drawing the graph -- and I have to spend about the same amount of time to parse the data before to display it.
Is there a way to access to the raw data memory (array of pixels) in order to do a fast copy towards an X11 pixmap ? |
Re: output in raw format (no compression) |
Posted by Peter Kwan on Apr-03-2012 00:25 |
|
Hi Laurent,
Currently, there is no API to access the raw data memory (and the raw data memory in ChartDirector is not exactly an array of pixels).
I have not tried myself, but I suspect BMP should be quite fast (much faster than PNG), provided the output is in memory. Are you creating the BMP or PNG in memory (using makeChart2), or as a file on disk?
Also, I think if you force true color BMP (using DrawArea.setPaletteMode), the code may become faster. Without forcing true color BMP, ChartDirector will first analysis the bitmap to see if it has 256 or less colors. If it has 256 or less colors, it will generate a palette based BMP/PNG, which is significantly smaller in memory size. In your case, I think memory is not a concern (we are talking about a few MB only for the entire true color bitmap in memory), so forcing true color BMP may be faster, as ChartDirector does not need to count the colors and generate the palattes and map each pixel into a palette index.
Using full color BMP also make parsing the BMP trivial, and the BMP is essentially the bitmap (I think the actual bitmap starts at byte 55 of the BMP output - the first 54 bytes are the headers), except the rows are in reverse order as per BMP standard.
In our own GUI sample code (for Linux, it is based on QT), in the QT QChartViewer widget, we output the chart in BMP and pass them to the QT widget. We found the performance is acceptable.
Regards
Peter Kwan |
Re: output in raw format (no compression) |
Posted by Laurent Riesterer on Apr-03-2012 19:06 |
|
Thanks for your detailed answer.
I did turn on the NoPalette mode. It is a bit faster, nothing really huge, but I will keep it.
I also use Qt on my Linux and it looks like most of the load is due to the X Server redrawing
the stuff. I have coded a small QCharViewer using a QPixmap to hold the chart once
generated. Any suggestions about way to optimize the redrawing ? I am using simple code:
class ChartWidget(QtGui.QFrame):
def __init__(self, parent=None):
super(ChartWidget, self).__init__(parent)
self.img = QtGui.QPixmap()
def paintEvent(self, event):
painter = QtGui.QPainter(self)
painter.drawPixmap(0, 0, self.img)
This combined with a call to update() to force a refresh works. But maybe this is not
optimal.
Thansk. |
Re: output in raw format (no compression) |
Posted by Peter Kwan on Apr-04-2012 02:10 |
|
Hi Laurent,
ChartDirector only generates the chart image. The QT would need to eventually transfer it to the screen hardware for display. I am not sure how fast the QT and the downstream parts are. It is probably hardware dependent (eg. depends on hardware video driver, and whether QT can take advantage of video acceleration), and operating system dependent.
If the slow speed is due to the QT and other downstream parts, there is not much ChartDirector can do. May be you can consider the followings:
(a) I am not sure if combining the 10 charts into 1 big chart (eg. using the MultiChart object) can help. With this method, there is only one QT widget to updatel, but the 10 charts must be updated synchronously and are adjacent to each others.
(b) May be you can investigate if there is a faster way to display a bitmap. In most OS, there are very fast way to display an image to the screen (that is how most games and DVD player applications work). If this method is accessible to a QT application, it may be used to display the chart image.
Regards
Peter Kwan |
|