If you are trying to change the size of the rectangle the ".left" and
".top" should use the opposite operation from the ".right" and
".bottom".  So if you want to increase the size of a rectangle, you
should use "-=" for top and left, and "+=" for right and bottom.

/Danny Zubiate
Developer Support Engineer
Sony Ericsson Mobile Communications

On Jun 21, 2:00 am, Enrique López Mañas <[email protected]>
wrote:
> Hello,
>
> I'm developing a small image editor. Basically, the user can insert
> some images in a canvas, and through interaction with the fingers
> moving them around. I'm having some trouble with the Zooming. I have
> followed the idea of this tutorial (http://blogs.sonyericsson.com/wp/
> 2010/05/18/android-one-finger-zoom-tutorial-part-1) to use a bitmap,
> and to apply transformations to two rectangles. Afterwards, if we draw
> the bitmap over the canvas with
> `android.graphics.Canvas.drawBitmap(Bitmap bitmap, Rect src, Rect dst,
> Paint paint)`, the transformation is applied. So far, is not working
> for me.
>
> I store all the images in an array of images, `ColorBall`. When I
> detect there is a zoom gesture, and only if it was over a certain
> image (this works so far), I apply over that image the transformations
> (the values are dummy, just wanted to check if it works):
>
>     colorballs.get(balID-1).getmRectDst().left   = getLeft();
>     colorballs.get(balID-1).getmRectDst().top    = getTop();
>     colorballs.get(balID-1).getmRectDst().right  = getRight();
>     colorballs.get(balID-1).getmRectDst().bottom = getBottom();
>
>     colorballs.get(balID-1).getmRectSrc().left   += 10;
>     colorballs.get(balID-1).getmRectSrc().top    += 10;
>     colorballs.get(balID-1).getmRectSrc().right  += 10;
>     colorballs.get(balID-1).getmRectSrc().bottom += 10;
>
> On the OnDraw event, for all the pictures in the array I locate them,
> and then I scale them using the rectangles. So far, the part of
> scaling is not working:
>
>     //draw the balls on the canvas
>     for (ColorBall ball : colorballs) {
>         canvas.drawBitmap(ball.getBitmap(), ball.getX(), ball.getY(),
> null);
>         canvas.drawBitmap(ball.getBitmap(), ball.getmRectSrc(),
> ball.getmRectDst(), mPaintBalls);
>     }
>
> Any suggestion of what can I be missing here? Thanks in advance!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to