Quote Originally Posted by anda_skoa View Post
Line 4 loads them image, it does not scale it at all.
Yeah I know this.
Line 5 is a very expensive NOOP, you are creating a scaled version of the image and then ignore it (return value not used at all).
What is the right way to do it?
Does storing the returned value really helps?
In Line 6 is another unneeded operation, i.e. toImage(). If you want to work with QImage, use QImage instead of QPixmap. Right now you convert from image to pixmap (internally in line 4) and then back again in line 6.
I have used QByteArray to retrieve image from the database (present as BLOB in db) hence, i am not converting the image i am loading the data (present in QByteArray datatype) into the QPixMap.
I have used QPixMap instead of the QImage because i want to maintain the aspect ratio , as it cannot be done using the QImage (I have tried it before & Image was coming distorted using QImage) & hence, again converting the QPixMap to QImage to display it on the QPainter .