图片遮罩与另一可调整大小的机器人 [英] Image masking with another resizable android

查看:214
本文介绍了图片遮罩与另一可调整大小的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在那里我将有一个背景图像和一个掩模图像的要求。比方说,背景图片是摩托车和口罩将被用来隐藏注册号。所以面膜会活动,也调整 - 能。最后的组合图像将与背景图像和图像掩模产生。我们怎样才能做到这一点?


解决方案

 公共位图drawFacesOnBitmap(上下文gContext,位图位图){      android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
      //设置默认位图的配置,如果没有
      如果(bitmapConfig == NULL){
        bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
      }
      //资源位图imutable,
      //所以我们需要将其转换为可变的1
      位= bitmap.copy(bitmapConfig,真);      帆布帆布=新的Canvas(位图);
      //新antialised涂料
      涂料粉刷=新的油漆(Paint.ANTI_ALIAS_FLAG);
      //文本颜色 - #3D3D3D
      paint.setColor(Color.GREEN);      //绘制文本到画布中心
      Log.d(BITMAP梦诗****,bitmapWidth:+ bitmap.getWidth()+&放大器; bitmapHeight:+ bitmap.getHeight());
        android.graphics.Rect R =新android.graphics.Rect();
        r.left = 200;
        r.top = 200;
        r.right = 400;
        r.bottom = 400;
        canvas.drawRect(R,漆);
    返回位图;
}

您可以使用此code上绘制一个位图的矩形。编辑它以满足您的需求。

I have a requirement where I will be having a background Image and one mask Image. Lets say the background Image is of Motorcycle and the mask will be used to hide the registration number. So the mask will be movable and also resize-able. Finally the combined Image will be generated with background image and Image mask. How we can achieve this ?

解决方案

public Bitmap drawFacesOnBitmap(Context gContext, Bitmap bitmap) {

      android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
      // set default bitmap config if none
      if(bitmapConfig == null) {
        bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
      }
      // resource bitmaps are imutable, 
      // so we need to convert it to mutable one
      bitmap = bitmap.copy(bitmapConfig, true);

      Canvas canvas = new Canvas(bitmap);
      // new antialised Paint
      Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
      // text color - #3D3D3D
      paint.setColor(Color.GREEN);

      // draw text to the Canvas center
      Log.d("BITMAP DIMENS****", "bitmapWidth:"+bitmap.getWidth()+" & bitmapHeight:"+bitmap.getHeight());
        android.graphics.Rect r = new android.graphics.Rect();
        r.left = 200;
        r.top = 200;
        r.right = 400;
        r.bottom = 400;
        canvas.drawRect(r, paint);
    return bitmap;
}

You can use this code to draw a rectangle on a bitmap. Edit it to meet your needs.

这篇关于图片遮罩与另一可调整大小的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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