Great! the answer is really helpful for me.
Thanks a lot.

BTW, it would be better if there are clear explain of  android api
document.


On Nov 4, 12:14 am, Mike Reed <[EMAIL PROTECTED]> wrote:
> canvas.drawBitmap(bitmap, matrix, ...)
>
> This is really just a more efficient way to do...
>
> canvas.save(Canvas.MATRIX_SAVE_FLAG);
> canvas.concat(matrix);
> drawBitmap(bitmap, 0, 0, ...);
> canvas.restore();
>
> In the original example, the matrix had a -1 scale in X. This means
> that all X coordinates will be negated. Thus the image will draw
> flipped in X, but it will also appear to the left of the Y axis, which
> defaults to the left edge of the view. Thus the fix was to post-
> translate everything to the right by at least the width of the bitmap,
> to make it appear on screen.
>
> Another fix could have been
>
> matrix.setScale(-1, 1);
> matrix.postTranslate(bitmap.getWidth(), 0);
> canvas.drawBitmap(bitmap, matrix, ...);
>
> mike
>
> On Nov 3, 2008, at 10:46 AM, Guolong wrote:
>
> thanks, it do work.
>
> On Nov 3, 1:44 pm, Romain Guy <[EMAIL PROTECTED]> wrote:
>
> >  sprite =
> > BitmapFactory
> > .decodeResource(appContext.getResources(),R.drawable.spritegfx);
> >  canvas.save();
> >  canvas.scale(-1.0f, 1.0f);
> >  canvas.drawBitmap(sprite, 0,0, null);
> >  canvas.restore();
>
> > This will work but you also need to translate the image too. You are
> > just drawing it outside of the canvas.
>
> > On Sun, Nov 2, 2008 at 8:42 AM, Guolong <[EMAIL PROTECTED]>
> > wrote:
>
> >> hello,
>
> >> I want to draw a fliped image and try following code:
>
> >>  sprite =
> >> BitmapFactory
> >> .decodeResource(appContext.getResources(),R.drawable.spritegfx);
> >>  Matrix temp1=new Matrix();
> >>  temp1.preScale(-1.0f,1.0f);
> >>  canvas.drawBitmap(sprite, temp1, null);
>
> >> But it does not work. neither work for the following code:
>
> >>  sprite =
> >> BitmapFactory
> >> .decodeResource(appContext.getResources(),R.drawable.spritegfx);
> >>  canvas.save();
> >>  canvas.scale(-1.0f, 1.0f);
> >>  canvas.drawBitmap(sprite, 0,0, null);
> >>  canvas.restore();
>
> >> Any idea for this problem please?
>
> >> Any way, following code do work.
> >>  sprite =
> >> BitmapFactory
> >> .decodeResource(appContext.getResources(),R.drawable.spritegfx);
> >>  Matrix temp1=new Matrix();
> >>  temp1.preScale(-1.0f,1.0f);
> >>  flipedSprite = Bitmap.createBitmap(sprite , 0, 0,
> >> sprite .getWidth(),
> >>                       sprite .getHeight(), temp1, false);
> >>  canvas.drawBitmap(flipedSprite , 0,0, null);
>
> >> But I just don't want to create a new bitmap for every fliped image
> >> because there're a lot of fliped or mirrored image in my program.
>
> > --
> > Romain Guywww.curious-creature.org
--~--~---------~--~----~------------~-------~--~----~
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