Results 1 to 13 of 13

Thread: QImageIOPlugin, support for new image format.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2008
    Location
    Bangalore, India
    Posts
    21
    Qt products
    Qt4 Qt5
    Platforms
    Windows Symbian S60
    Thanks
    1

    Thumbs up Re: QImageIOPlugin, support for new image format.

    Thank you,
    QImageReader worked for me.

    But, if I use image.scale() ,, then it'll scale the original image to the vale passed in scale().

    So, is there anything similar; to create a QIcon of specific size from a file?
    Last edited by suneel1310; 4th March 2009 at 10:25.

  2. #2
    Join Date
    Oct 2006
    Posts
    279
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 40 Times in 39 Posts

    Default Re: QImageIOPlugin, support for new image format.

    Have a look at QImageIOHandler::ImageOption, in specific QImageIOHandler::ScaledSize and QImageIOHandler::supportsOption().

    Qt Code:
    1. class MyImageHandler : public QImageIOHandler
    2. {
    3. ...
    4. bool supportsOption ( ImageOption option )
    5. {
    6. if(option==ScaledSize)
    7. return true;
    8. ...
    9. }
    10. bool read ( QImage * image )
    11. {
    12. QSize scaledSize = option(ScaledSize).toSize();
    13. ...
    14. }
    15. };
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. QImage icon(64, 64, QImage::Format_RGB32);
    2. QImageReader reader("XXX.abc");
    3. reader.setScaledSize(QSize(64,64);
    4. if (reader.read(&icon)) {
    5. // Display icon
    6. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Nov 2008
    Location
    Bangalore, India
    Posts
    21
    Qt products
    Qt4 Qt5
    Platforms
    Windows Symbian S60
    Thanks
    1

    Default Re: QImageIOPlugin, support for new image format.

    Thank you.
    QImage Reader solved my problem

    Now, Is there anything similar in QPixmap?? like QImageReader for QImage.
    Or, we should create QImage first and then converting it to QPixmap?

  4. #4
    Join Date
    Oct 2006
    Posts
    279
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 40 Times in 39 Posts

    Default Re: QImageIOPlugin, support for new image format.

    Create a QImage and then convert it.

  5. #5
    Join Date
    Nov 2008
    Location
    Bangalore, India
    Posts
    21
    Qt products
    Qt4 Qt5
    Platforms
    Windows Symbian S60
    Thanks
    1

    Default Re: QImageIOPlugin, support for new image format.

    But, converting from QImage to Qpixmap is expensive, interms of performance.
    So, isn't there any other approach? which is good in performance.

  6. #6
    Join Date
    Oct 2006
    Posts
    279
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 40 Times in 39 Posts

    Default Re: QImageIOPlugin, support for new image format.

    It might be expensive, but not necessarily. On windows each QPixmap internally holds a QImage, so it is virtually for free. Anyway it is unavoidable. You first need to load the image from the hard drive into RAM buffer. You do this by loading a Qimage. You then want to transfer the image to your screen buffer(be it an X-Server, or an OpenGL texture). You do this by converting the QImage to a QPixmap.

    It is only expensive in the sense that it is wasteful to convert back and forth within a paintEvent(). You still have to do the conversion once, so that subsequent manipulations of the QPixmap(rotations, scaling etc) make best use of the underlying rendering system.

    I hope that the answer makes sense to you.

  7. The following user says thank you to spud for this useful post:

    talk2amulya (6th March 2009)

  8. #7
    Join Date
    Nov 2008
    Location
    Bangalore, India
    Posts
    21
    Qt products
    Qt4 Qt5
    Platforms
    Windows Symbian S60
    Thanks
    1

    Default Re: QImageIOPlugin, support for new image format.

    Yes,
    Thanks a lot for that info.
    It really helped me.

  9. #8
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 66 Times in 62 Posts

    Default Re: QImageIOPlugin, support for new image format.

    spud: that was really helpful info. just one question. is it QImage that contains a QPixmap or a QPixmap that contains a QImage...in windows..

  10. #9
    Join Date
    Oct 2006
    Posts
    279
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 40 Times in 39 Posts

    Default Re: QImageIOPlugin, support for new image format.

    QPixmap contains a QImage.

Similar Threads

  1. get QImage object from buffer
    By Sheng in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2012, 02:03
  2. Qt 4.4.3 commercial on Kubuntu 8.10
    By Micawber in forum Installation and Deployment
    Replies: 5
    Last Post: 17th February 2010, 01:02
  3. Qt-4.4.0 installation error in linux
    By babu198649 in forum Installation and Deployment
    Replies: 4
    Last Post: 27th May 2008, 14:35
  4. Some very weird compilation warnings
    By MarkoSan in forum Qt Programming
    Replies: 21
    Last Post: 23rd January 2008, 16:48

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
  •  
Qt is a trademark of The Qt Company.