翻转在Android说明一个位图? [英] Flipping a bitmap in android help?

查看:102
本文介绍了翻转在Android说明一个位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要救了内存我的比赛,我想问问你,因为我无法找到任何东西,最后一次,我问了一些东西在这里我得到了一个很好的答案。我可翻转位在Eclipse中,所以我可以在内存中保存精灵?所有我发现教程是关于旋转和翻转不。对于翻转位图教程只针对Open GL的或者类似的东西。请帮帮我。
我一直在寻找为在谷歌教程,但我放弃了在第5页。谁能帮助我?
有没有人有一个很好的教程?
顺便说一句,我使用的画布。
谢谢!

I want to save up memory for my game and I wanted to ask you because I couldn't find anything and last time that I asked something here I got a good answer. Can i flip the bitmap inside eclipse so i could save on memory for sprites? All the tutorials that i found were about rotating and not flipping. The tutorials for flipping a bitmap were only for open Gl or something like that. Please help me. I've been looking up for tutorials in google but i gave up at page 5. Can anyone help me? Does anyone have a good tutorial? By the way I am using a canvas. Thanks!

我得到一个强制关闭每次我尝试运行它... u能弄清楚?这里是我的code:

I get a force close everytime I try to run it... can u figure it out? here is my code:

       Matrix flipHorizontalMatrix = new Matrix();
       flipHorizontalMatrix.setScale(-1,1);
       flipHorizontalMatrix.postTranslate(0, canvas.getHeight()-arrowL.getHeight());
       canvas.drawBitmap(arrowL, flipHorizontalMatrix, null);

我想的箭头是在右下角。

I want the arrow to be at the bottom right corner.

推荐答案

由于您使用画布,为什么不尝试 drawBitmap(位图位图,矩阵的矩阵,涂料粉刷)方法。使用矩阵的翻转x坐标。

Since you're using Canvas, why not try the drawBitmap (Bitmap bitmap, Matrix matrix, Paint paint) method. Use a Matrix that flips the x coordinates.

您可以做这样的事情:

Matrix flipHorizontalMatrix = new Matrix();
flipHorizontalMatrix.setScale(-1,1);
flipHorizontalMatrix.postTranslate(myBitmap.getWidth(),0);

canvas.drawBitmap(myBitmap, flipHorizontalMatrix, myPaint);

这篇关于翻转在Android说明一个位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆