Results 1 to 3 of 3

Thread: Saving plot as image, JPG not working

  1. #1
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    121
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Saving plot as image, JPG not working

    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.
    Qt Code:
    1. int w = this->width();
    2. int h = this->height();
    3. QPixmap pixmap(w, h);
    4. pixmap.fill(Qt::white);
    5. int options = QwtPlotPrintFilter::PrintAll;
    6. options &= ~QwtPlotPrintFilter::PrintBackground;
    7. options |= QwtPlotPrintFilter::PrintFrameWithScales;
    8. filter.setOptions(options);
    9. this->print(pixmap, filter);
    10. QString fileName = "zzz.jpg";
    11. if (fileName.isEmpty()) {
    12. return;
    13. }
    14. pixmap.save(fileName,0,-1);
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    121
    Thanks
    9
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Saving plot as image, JPG not working

    I should note that this is running on Windows XP.

  3. #3
    Join Date
    Nov 2008
    Posts
    39
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Saving plot as image, JPG not working

    try Gif format available for XP jpeg or jpg is available in vista and + OS

Similar Threads

  1. Saving qwt plot as image
    By giusepped in forum Qwt
    Replies: 13
    Last Post: 14th July 2009, 07:39
  2. Replies: 3
    Last Post: 3rd June 2009, 18:25
  3. Saving pure plot data to image file
    By Debilski in forum Qwt
    Replies: 4
    Last Post: 7th April 2009, 17:02
  4. Sticks on plot not working
    By giusepped in forum Qwt
    Replies: 3
    Last Post: 11th February 2009, 09:55
  5. Problem saving a plot
    By kalos80 in forum Qwt
    Replies: 2
    Last Post: 10th July 2008, 08:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.