How might I add a watermark effect to an image in Android?

后端 未结 6 939
深忆病人
深忆病人 2020-11-30 23:09

I have an image with frames and I need to add a watermark effect. How might I do this?

6条回答
  •  猫巷女王i
    2020-12-01 00:07

    For others reference, if you want to add the logo of your application (which is in your drawable folder(s)) on top of image use following method:

    private Bitmap addWaterMark(Bitmap src) {
            int w = src.getWidth();
            int h = src.getHeight();
            Bitmap result = Bitmap.createBitmap(w, h, src.getConfig());
            Canvas canvas = new Canvas(result);
            canvas.drawBitmap(src, 0, 0, null);
    
            Bitmap waterMark = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.logo);
            canvas.drawBitmap(waterMark, 0, 0, null);
    
            return result;
        }
    

提交回复
热议问题