tags:

views:

57

answers:

1

Hello, I'm new to Android and Java programming and I've manage to create a simple paint program, but how do I add a zoom feature? Right now I'm just extending the View class and using the "onDraw()" method.

Do I have to use a Drawable to be able to add zooming functionality? I'm not really understanding the differences between the two.

If I am way off base then please point me to a good tutorial on paint/zooming.

A: 

I think your question is beyond the scope that stackoverflow Q/A format can provide. I know you're asking for 'simple' but imho that's probably due to your lack of perception about the scope of the question that you're asking.

In order to support zooming you need to know what kind of image processing engine you want. Are you creating a vector or raster based drawing program? If you do not understand the difference between the two then you'll going to have a difficult time figuring out what to do.

You should probably at least gain a basic understanding about these various topics (links to books pulled more or less from the top of amazon's search results):

Wikipedia links:

Open source image processing apps (not android but source code never hurts to see how others have done something)

I'm sorry there isn't an easy and direct answer to your question. I'm also not saying that you need to become an expert in these topics to do what you want. You just need to familiarize yourself with them and then you'll probably be able to implement what you want without much difficulty.

Qberticus
Thanks for the info Qberticus. I will read it and try to understand more :PBeen doing some more reading before you answered and found out about the Canvas.scale() function. It did scale my drawing up, but now the point where you press down is offset by a bit after scaling. (the dot is not where you touch the screen anymore) Still trying to see if it's even possible work it out correctly this way.source: http://developer.android.com/guide/topics/graphics/index.html
Justin O
The scale function has to be applied to the coordinates you get from your input. The formula for x is as following: realx = (inputx - scalecenterx) / scalingx + scalecenterx. The same goes for the y ;)
Toad
thanks Toad! that fixed the offset problem :D
Justin O