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

后端 未结 6 927
深忆病人
深忆病人 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条回答
  •  醉梦人生
    2020-11-30 23:55

    You can use androidWM to add a watermark into your image, even with invisible watermarks:

    add dependence:

    dependencies {
      ...
      implementation 'com.huangyz0918:androidwm:0.2.3'
      ...
    }
    

    and java code:

     WatermarkText watermarkText = new WatermarkText(“Hello World”)
                        .setPositionX(0.5) 
                        .setPositionY(0.5) 
                        .setTextAlpha(100) 
                        .setTextColor(Color.WHITE) 
                        .setTextFont(R.font.champagne) 
                        .setTextShadow(0.1f, 5, 5, Color.BLUE); 
    
     WatermarkBuilder.create(this, backgroundBitmap) 
                        .loadWatermarkText(watermarkText) 
                        .getWatermark() 
                        .setToImageView(backgroundView); 
    
    

    You can easily add an image type watermark or a text watermark like this, and the library size is smaller than 30Kb.

提交回复
热议问题