Some additional information about paintCache().
If the instruction
QPixmap *pmGraf = grafCanvas.paintCache()
works, is easy to stream the plot. The following code could do it:
***********
<code>
QPixmap *pmGraf = grafCanvas.paintCache();
QImage image = pmGraf->toImage();
QFile outputFile;
if (!outputFile.open(stdout, QIODevice::WriteOnly))
{
cout << "outputFile did not open." <<endl;
}
QDataStream out(&outputFile);
out << image;
</code>
**************
If the output stream is redirected to a file,
my_application >> redirected_file.png
it can not be displayed. The reason is that
the file consists of the image with 4 extra bytes appended at the beginning.
If those 4 extra bytes are eliminated the image displays properly. I read a 16918 bytes
PNG image and streamed it out using a similar code as above . The redirected file was 16943 bytes long and it displayed properly with
tail -c 16939 redirectedfile.png | display
In the Qwt documentation I could not find any explanation why paintCache() returns a NULL pixmap. If some one knows please let me know.





Reply With Quote

Bookmarks