开发者

How to Cut out RectF From a Bitmap?

I want to make a walking sprite anim开发者_StackOverflow中文版ation. I have a one bitmap with all 31 sprite frames. I draw one frame on canvas canvas.drawBitmap(bitmap, Rect src, RectF dst, paint). The problem is Rect src coordinates are int and when I divide bitmap.getWidth() by 31 to set a frame coordinates I get float. Is there a way to cut out RectF from a bitmap.

I can cut out Rect and scale it, but I would prefer the first option.


There is no way to cut out and store a piece of bitmap into memory with a float size. One can draw on float coordinates because it is possible to anti-alias the float edges on canvas.

So the solution I believe is to make your sprite sheet width = 31 x sprite_width, on the frist place, so that your cuts are a prefect match.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜