qt - While rotation of Images, Size of image decreases -
hello all, trying rotate images in qt. while rotating again , again, size of image decreases. how can stop size decrement ? please me out. using code.
void mywidget::rotatelabel() { qpixmap pixmap(*my_label->pixmap()); qmatrix rm; rm.rotate(90); pixmap = pixmap.transformed(rm); my_label->setpixmap(pixmap); }
in qt files qpixmap::transformed, states: -
the transformation transform internally adjusted compensate unwanted translation; i.e. pixmap produced smallest pixmap contains transformed points of original pixmap. use truematrix() function retrieve actual matrix used transforming pixmap.
i assume width , height of image not equal. therefore, you've observed, each rotation reduce size, ensure full image maintained.
change original image have equal width , height adding border, or scale image before or after rotation, image quality suffer.
alternatively, if you're rotating 90 degrees, rotate images in external art program, load 4 images , set 1 want, rather rotating them via qt.
============== edited ======================
in response comments of having varying rotations, need ensure have source image never rotated, each iteration, create image source image need prevent both reduction in image size , image quality.
in pseudo code this: -
image srcimage(":/myimage"); void mywidget::rotatelabel() { image img(srcimage); img.rotate(rotation); label->setpixmap(img); }
Comments
Post a Comment