切位图的该部分 [英] cut the portion of bitmap

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

问题描述

可能重复:
  如何裁剪在Android上的解析图像?

我选择从位图的部分和我在同一个位图复制选定的部分。现在我想复制后删除选定的部分。如何做到这一点?请帮我..

I have selected a portion from the bitmap and i am copying the selected portion in the same bitmap.. Now i want to remove the selected portion after copying.. How to do it?? please help me out..

推荐答案

最简单的方法,我知道的是使用XFER模式处理的图形软件包。下面的函数从削减(30,30)区出发到(100,100),从资源加载320x480的图像。适应坐标dinamically改变:

Easiest way I am aware of is to use XFer mode processing from the Graphics package. Function below cuts region starting from (30,30) till (100,100) to the 320x480 image loaded from resources. Adapt coordinates to change dinamically:

private Bitmap cropBitmap1()
{
    Bitmap bmp2 = BitmapFactory.decodeResource(this.getResources(), R.drawable.image1); 
    Bitmap bmOverlay = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);

    Paint p = new Paint();
    p.setXfermode(new PorterDuffXfermode(Mode.CLEAR));              
    Canvas c = new Canvas(bmOverlay); 
    c.drawBitmap(bmp2, 0, 0, null); 
    c.drawRect(30, 30, 100, 100, p);

    return bmOverlay;
}

这篇关于切位图的该部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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