PDA

View Full Version : Saving plot as image, JPG not working



gib
3rd May 2010, 05:04
This is strange. The following code works fine for PNG, BMP and TIF formats, but if I choose the JPG format the image is all black, except for a hint of the frame.


int w = this->width();
int h = this->height();
QPixmap pixmap(w, h);
pixmap.fill(Qt::white);
QwtPlotPrintFilter filter;
int options = QwtPlotPrintFilter::PrintAll;
options &= ~QwtPlotPrintFilter::PrintBackground;
options |= QwtPlotPrintFilter::PrintFrameWithScales;
filter.setOptions(options);
this->print(pixmap, filter);
QString fileName = "zzz.jpg";
if (fileName.isEmpty()) {
return;
}
pixmap.save(fileName,0,-1);


I invoke this by detecting rightButtonClick on a QwtPlot.
Is there something special about a JPG?

gib
4th May 2010, 00:14
I should note that this is running on Windows XP.

manmohan
5th May 2010, 06:01
try Gif format available for XP jpeg or jpg is available in vista and + OS