I would point you to  
http://developer.android.com/reference/android/graphics/Canvas.html#scale(float,
 
float) 

public final void scale (float sx, float sy, float px, float py)
Since: API Level 
1<http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels>

Preconcat the current matrix with the specified scale.
ParameterssxThe amount to scale in XsyThe amount to scale in YpxThe x-coord 
for the pivot point (unchanged by the scale)pyThe y-coord for the pivot 
point (unchanged by the scale)

I'm confused by what you mean by better way, what can't you do with this?

Regards
Jack.

On Thursday, September 13, 2012 7:41:15 AM UTC+1, Kunal Shah wrote:
>
> I know this a stupid question to ask, but I was going through a tutorial 
> and I just dont seem to understand the below lines of code...Have pulled my 
> hair understanding the geometrical algorithm behind this, but.....Oh!!! 
> This is very simple but I just dont seem to get it. Please help....I am a 
> beginner...
>
>
>
>
>       private void drawPict(Canvas canvas, int x, int y, int w, int h,
>                                   float sx, float sy) {
>                 canvas.save();
>                 canvas.translate(x, y);
>                 canvas.clipRect(0, 0, w, h);
>                 canvas.scale(0.5f, 0.5f);
>                 canvas.scale(sx, sy, w, h);
>                 canvas.drawPicture(mPicture);
>                 canvas.restore();
>             }
>             @SuppressWarnings("unused")
>                 @Override
>             protected void dispatchDraw(Canvas canvas) {
>                 super.dispatchDraw(mPicture.beginRecording(getWidth(), 
> getHeight()));
>                 mPicture.endRecording();
>                 int x = getWidth()/2;
>                 int y = getHeight()/2;
>                 if (false) {
>                     canvas.drawPicture(mPicture);
>                 } else {
>                     drawPict(canvas, 0, 0, x, y,  1,  1);
>                     drawPict(canvas, x, 0, x, y, -1,  1);
>                     drawPict(canvas, 0, y, x, y,  1, -1);
>                     drawPict(canvas, x, y, x, y, -1, -1);
>                 }
>             }
>
>   I have looked into this again...and understand that canvas.scale has 4 
> parameters, being the co-ordinates of the points I assume...but I cannot 
> still understand the float sx, float sy...
>
> sx=-1 and sy=1...it will scale, agreed...but is not there a better way?
>

-- 
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