Yeah I know this.
What is the right way to do it?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).
Does storing the returned value really helps?
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.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 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 .
Bookmarks