Image Zoom

All your problems with Audio, Video and Images.

Image Zoom

Postby khaled450 » Sun Jun 20, 2010 7:33 am

Hello guys, I wonder if someone can help me with zooming images. I want to apply the "pinch" zoom functionality to an ImageView but not sure how to do that! any help is appreciated
khaled450
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed May 19, 2010 8:11 am

Top

Re: Image Zoom

Postby befast » Sun Jun 20, 2010 6:36 pm

Hi, khaled!
If i right understand you, you need some "Multitouch pinch" exapmles? Sorry for my english =)
befast
Freshman
Freshman
 
Posts: 7
Joined: Sat Apr 03, 2010 11:12 am
Location: Saturn

Re: Image Zoom

Postby khaled450 » Sun Jun 20, 2010 6:47 pm

if by "Multitouch Pinch" you mean zoom in and out by using two fingers then YES PLEASE
khaled450
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed May 19, 2010 8:11 am

Re: Image Zoom

Postby befast » Sun Jun 20, 2010 7:03 pm

Ok, than read this article http://www.zdnet.com/blog/burnette/how- ... oid-2/1747. If you after reading you also need my help, just write here, and i will help you as soon as possible.
befast
Freshman
Freshman
 
Posts: 7
Joined: Sat Apr 03, 2010 11:12 am
Location: Saturn

Re: Image Zoom

Postby befast » Sun Jun 20, 2010 7:07 pm

Ok, than read this article http://www.zdnet.com/blog/burnette/how- ... oid-2/1747. If you after reading you also need my help, just write here, and i will help you as soon as possible.
befast
Freshman
Freshman
 
Posts: 7
Joined: Sat Apr 03, 2010 11:12 am
Location: Saturn

Re: Image Zoom

Postby khaled450 » Sun Jun 20, 2010 8:57 pm

Thanks befast, I read and practiced that tutorial but trying to copy and past the code there gives me many errors
====
case MotionEvent.ACTION_POINTER_DOWN:
oldDist = spacing(event);
Log.d(TAG, "oldDist=" + oldDist);
if (oldDist > 10f) {
savedMatrix.set(matrix);
midPoint(mid, event);
mode = ZOOM;
Log.d(TAG, "mode=ZOOM" );
}
break;
====
what does mid do here?


====
if (mode == DRAG) {
// ...
}
else if (mode == ZOOM) {
float newDist = spacing(event);
Log.d(TAG, "newDist=" + newDist);
if (newDist > 10f) {
matrix.set(savedMatrix);
float scale = newDist / oldDist;
matrix.postScale(scale, scale, mid.x, mid.y);
}
}
====
what does oldDist point to?
khaled450
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed May 19, 2010 8:11 am

Top

Re: Image Zoom

Postby befast » Mon Jun 21, 2010 7:53 am

oldDist is old distance between two points (multitouch points, or between two fingers). midPoint is a half distance between two points. In this examples autor (i think) forget to declare some variables. But the point
of this tutorial is to understand how multitouch pinching working.
befast
Freshman
Freshman
 
Posts: 7
Joined: Sat Apr 03, 2010 11:12 am
Location: Saturn

Re: Image Zoom

Postby befast » Mon Jun 21, 2010 8:01 am

All you need is just 3 events:
case MotionEvent.ACTION_DOWN: - when first finger was touched the screen
case MotionEvent.ACTION_POINTER_DOWN: - when second finger was touched the screen
case MotionEvent.ACTION_MOVE: - when one or two fingers moved (after touching the screen)

All you need to do, is calculate and save previous distance between two fingers in case MotionEvent.ACTION_DOWN and than in case MotionEvent.ACTION_MOVE. Than if distance growing up for example you make zoom in. If you need i can write some code example
befast
Freshman
Freshman
 
Posts: 7
Joined: Sat Apr 03, 2010 11:12 am
Location: Saturn

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 12 guests