Dear All,
Is there any way for maintaining the aspect ratio for the Image being taken from the db.
What exactly I am doing is I am populating db with the image (the datatype for the image is BLOB in DB) & later on I am displaying that image on the reports.
The code I have used for displaying the Image on the reports is below,
p.loadFromData(myImage); //myImage = Acquired from the db
p.scaled(120,60,Qt::KeepAspectRatio); //This is not required as x & y co-ordinates are fix
reportPainter
->drawImage
(QRect(60,
0,
120,
60),p.
toImage());
//Adding image in QPainter with rectangle size kept fixed.
QPainter *reportPainter;
QPixmap p;
QByteArray myImage;
p.loadFromData(myImage); //myImage = Acquired from the db
p.scaled(120,60,Qt::KeepAspectRatio); //This is not required as x & y co-ordinates are fix
reportPainter->drawImage(QRect(60,0,120,60),p.toImage()); //Adding image in QPainter with rectangle size kept fixed.
To copy to clipboard, switch view to plain text mode
In Line of Code no. 4 : Image is scaled to fix width & height (viz. not the requirement, as it should be calculated based on the acquired image height & width)
In Line of Code no. 5 : Similarly, the Image is drawn in the fix rectangle.
How to get the image's height & width present in the db? or Is there any other way to do so?
And yes I want to maintain the aspect ratio of the image in the report acquired from the database.
Thanks in Advance.
Regards,
Rohit K
Bookmarks