欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android實(shí)現(xiàn)為圖片添加水印

 更新時間:2020年04月18日 10:32:29   作者:葉應(yīng)是葉  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)為圖片添加水印的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android實(shí)現(xiàn)為圖片添加水印的具體代碼,供大家參考,具體內(nèi)容如下

添加水印的方法挺簡單的,具體內(nèi)容如下

public class MainActivity extends AppCompatActivity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  ImageView iv = (ImageView) findViewById(R.id.imageView);
  Drawable drawable = ContextCompat.getDrawable(this, R.drawable.image);
  BitmapDrawable bd = (BitmapDrawable) drawable;
  Bitmap bmp = bd.getBitmap();
  Bitmap bitmap = createWatermark(bmp, "葉應(yīng)是葉" + "http://blog.csdn.net/new_one_object");
  iv.setImageBitmap(bitmap);
 }

 private Bitmap createWatermark(Bitmap bitmap, String mark) {
  int w = bitmap.getWidth();
  int h = bitmap.getHeight();
  Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bmp);
  Paint p = new Paint();
  // 水印顏色
  p.setColor(Color.parseColor("#c5576370"));
  // 水印字體大小
  p.setTextSize(150);
  //抗鋸齒
  p.setAntiAlias(true);
  //繪制圖像
  canvas.drawBitmap(bitmap, 0, 0, p);
  //繪制文字
  canvas.drawText(mark, 0, h / 2, p);
  canvas.save(Canvas.ALL_SAVE_FLAG);
  canvas.restore();
  return bmp;
 }

}

效果圖

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android實(shí)現(xiàn)環(huán)信修改頭像和昵稱

    Android實(shí)現(xiàn)環(huán)信修改頭像和昵稱

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)環(huán)信修改頭像和昵稱,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • Android應(yīng)用程序更新并下載實(shí)例

    Android應(yīng)用程序更新并下載實(shí)例

    本篇文章主要介紹了Android應(yīng)用程序更新并下載實(shí)例,非常具有實(shí)用價值,需要的朋友可以參考下。
    2017-03-03
  • Android 中RecyclerView頂部刷新實(shí)現(xiàn)詳解

    Android 中RecyclerView頂部刷新實(shí)現(xiàn)詳解

    這篇文章主要介紹了Android 中RecyclerView頂部刷新實(shí)現(xiàn)詳解的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下
    2017-10-10
  • Android啟動優(yōu)化之延時加載的步驟詳解

    Android啟動優(yōu)化之延時加載的步驟詳解

    這篇文章主要給大家介紹了關(guān)于Android啟動優(yōu)化之延時加載的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-02-02
  • Flutter時間軸Timeline的實(shí)現(xiàn)

    Flutter時間軸Timeline的實(shí)現(xiàn)

    時間軸在很多地方都可以用的到,本文介紹了Flutter時間軸Timeline的實(shí)現(xiàn),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-05-05
  • Android?Room數(shù)據(jù)庫加密詳解

    Android?Room數(shù)據(jù)庫加密詳解

    這篇文章主要為大家詳細(xì)介紹了Android?Room數(shù)據(jù)庫加密,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • 詳解Matisse與Glide--java.lang.NoSuchMethodError:com.bumptech.glide.RequestManager.load

    詳解Matisse與Glide--java.lang.NoSuchMethodError:com.bumptech.gl

    這篇文章主要介紹了在使用Matisse與glide4.0.0以及4.0.0之后的版本過程中,碰到該問題java.lang.NoSuchMethodError:com.bumptech.glide.RequestManager.load的解決方法
    2021-08-08
  • Android自定義彈出框dialog效果

    Android自定義彈出框dialog效果

    這篇文章主要為大家詳細(xì)介紹了Android自定義彈出框dialog效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • android的編譯和運(yùn)行過程深入分析

    android的編譯和運(yùn)行過程深入分析

    首先來看一下使用Java語言編寫的Android應(yīng)用程序從源碼到安裝包的整個過程,此過程對了解android的編譯和運(yùn)行過程有很大的幫助
    2012-12-12
  • android實(shí)現(xiàn)彈出提示框

    android實(shí)現(xiàn)彈出提示框

    這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)彈出提示框,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-01-01

最新評論