07-10-2012 07:55 AM
I'm trying to implement pinch zooming functionality in Blackberry Torch. I can get pinch details from touchevent and accordingly calculate scaling factors. I can then scale the image using EncodedImage.scaleImage32.
However, I also need to set the center of scaling, as during pinch zooming, I need to keep the point between two fingers fixed, instead of 0,0. I can't find a method to set the center of scaling.
Solved! Go to Solution.
07-10-2012 09:37 AM
I would look at this another way, rather than scaling about a centre, I think you have to scale and then re-center. In other words, scale it, then figure out where the new centre point would be based on the centre of the fingers after the scale. The paint the Bitmap centered at that location.
I suspect this is easier than trying to figure out how to scale and maintain the centre point.
07-10-2012 09:49 AM
07-10-2012 10:10 AM
It is just math....
Say your pinch point is curently at x = 1000 and y = 1100, and you are scrolling so the left hand edge you are displaying is 900 and the top of the screen you are displaying is 800. So your centre point is 100 in from the right hand side and 300 down.
Say you reduce the image by 20%, so the pinch point is now 800, 880. You need to position this 100 in and 300 down, so the horizontal scroll position will be 800 - 100, and the vertical scroll position will be 1100 - 300.
Or something like that.
I'm sure if you try to picture this and draw diagrams you will figure the math out.