Results 1 to 5 of 5

Thread: Saving image fails on other machines

  1. #1
    Join Date
    Apr 2009
    Posts
    11
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Saving image fails on other machines

    Hello,

    I already added the plugins qgif4.dll, qjpeg4.dll and qtiff4.dll and called in the main method QApplication::addLibraryPath. The application now successfully loads images and tells me that the following formats are supported.
    bmp, jpeg, jpg, png, ppm, tif, tiff, xbm, xpm
    But saving works only on my development machine. This is what I am doing in order to save an image:

    Qt Code:
    1. QPainter *painter = new QPainter();
    2. QRectF rect = scene->itemsBoundingRect();
    3.  
    4. QImage *image = new QImage(rect.size().toSize(), QImage::Format_ARGB32_Premultiplied);
    5.  
    6. painter->begin(image);
    7. scene->render(painter);
    8. painter->end();
    9.  
    10. image->save("test.jpg", "JPG");
    11.  
    12. delete painter;
    13. delete image;
    To copy to clipboard, switch view to plain text mode 

    What am I doing wrong?

    Thanks for your support.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Saving image fails on other machines

    Have you tried to save it with PNG or any other format? If that works, you have done something wrong with the plugins. Normally you don't need to call addLibrary.

  3. The following user says thank you to Lykurg for this useful post:

    27Loco (28th July 2010)

  4. #3
    Join Date
    Apr 2009
    Posts
    11
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Saving image fails on other machines

    I already tried png, bmp and jpg, but none of them works on other machines, only on my development pc.

    Loading images worked after using the plugins so I guess the plugins work well.

  5. #4
    Join Date
    May 2010
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Saving image fails on other machines

    Try removing the format from the save call, and letting Qt figure it out on its own:

    Qt Code:
    1. image->save("test.jpg");
    To copy to clipboard, switch view to plain text mode 

  6. The following user says thank you to grabalon for this useful post:

    27Loco (28th July 2010)

  7. #5
    Join Date
    Apr 2009
    Posts
    11
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Saving image fails on other machines

    Doesnt work either.

    I activated the console and now I got some more information about the problem. This is what I get when I am trying to save the image.
    Qt Code:
    1. QPainter::begin: Paint device returned engine == 0, type: 3;
    2. QPainter::save: Painter not active
    3. QPainter::setClipRect: Painter not active
    4. QPainter::restore: Unbelanced save/restore
    5. .
    6. .
    7. .
    8. .
    9. QPainter::end: Painter not active, aborted
    To copy to clipboard, switch view to plain text mode 

    SOLVED
    rect.size().toSize() was the problem. The size was not valid and therefore the image was invalid. So many hours

    Thanks for your help
    Last edited by 27Loco; 28th July 2010 at 19:12.

Similar Threads

  1. Problem saving JPG image
    By avis_phoenix in forum Newbie
    Replies: 1
    Last Post: 31st July 2009, 15:38
  2. Saving qwt plot as image
    By giusepped in forum Qwt
    Replies: 13
    Last Post: 14th July 2009, 07:39
  3. Regarding saving of image in QTOPIA sdk
    By prajna in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 22nd April 2009, 06:45
  4. Saving QGraphicsScene with OpenGL to image
    By elbaschid in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2009, 20:32
  5. Saving already opened image ...
    By Godlike in forum Newbie
    Replies: 14
    Last Post: 28th March 2006, 21:17

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.