mapToScene equivalent for a scaled QImage?
-
well, how do you
know the coordinates of the original rectangle ?Im not sure i 100% understand. you have an image, where inside
a rect is DRAWN ?
then you scale the whole image
and this drawn rect is also scaled with whole image?
and then you want to find the corrdinates?
inside the image? -
@mrjj exactly. There's a rectangle at position (x, y), whose size is (w, h) and I would like to know the new position (x', y') as well as its new size (w', h')
-
@mrjj Yes. I think I'm going to go with
x' = scale_x*x,y' = scale_y*y,w' = scale_x*wandh' = scale_y*hbut I'd rather Qt did it for me. This way I'd be sure there's no mistake. -
Hello,
I have a QImage that has a rectangle inside. After scaling it, I would like to know the coordinates of the scaled rectangle in the new, scaled QImage. Is there an easy way to achieve this?
Thanks a lot.
QTransform matrix = QTransform().scale(0.5, 0.5); QImage scaledImg = img.transformed( matrix, Qt::SmoothTransformation ); QRect scaledRect = matrix.mapRect( originRect );(untested)
-
QTransform matrix = QTransform().scale(0.5, 0.5); QImage scaledImg = img.transformed( matrix, Qt::SmoothTransformation ); QRect scaledRect = matrix.mapRect( originRect );(untested)
@raven-worx
oh, i read the question as having a smaller drawn rect inside image. :)