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?
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.
Have a look at QImageIOHandler::ImageOption, in specific QImageIOHandler::ScaledSize and QImageIOHandler::supportsOption().
Qt Code:
{ ... bool supportsOption ( ImageOption option ) { if(option==ScaledSize) return true; ... } { ... } };To copy to clipboard, switch view to plain text modeQt Code:
if (reader.read(&icon)) { // Display icon }To copy to clipboard, switch view to plain text mode
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?
Create a QImage and then convert it.
But, converting from QImage to Qpixmap is expensive, interms of performance.
So, isn't there any other approach? which is good in performance.
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.
talk2amulya (6th March 2009)
Yes,
Thanks a lot for that info.
It really helped me.
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..
QPixmap contains a QImage.
Bookmarks