在画布上绘制图像的一部分 [英] Draw portion of image on Canvas

查看:138
本文介绍了在画布上绘制图像的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大小265x256的图像,我想在画布上任意位置画出大小为16x16的左上和右下部分
是否有人可以共享的概念或code做到这一点。

I have an image of size 265x256 and I want to draw the top-left and right-bottom portion of size 16x16 at random location on Canvas Can someone please share the concept or code to do this

推荐答案

我认为你可以使用<一个href=\"http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap%28android.graphics.Bitmap,%20android.graphics.Rect,%20android.graphics.Rect,%20android.graphics.Paint%29\"相对=nofollow>画布方法

public void drawBitmap (Bitmap bitmap, Rect src, RectF dst, Paint paint)

在哪里文件指出第二个参数作为SRC

where documentation states second argument src as

如果源矩形不为空,它指定的子集
  位图绘制。

If the source rectangle is not null, it specifies the subset of the bitmap to draw.

所以,你可以通过要在第二个参数绘制源位图的矩形。

So you can pass the rectangle of the source bitmap that you want to draw in the second argument.

这篇关于在画布上绘制图像的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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