簡體   English   中英

Android Studio處理圖像

[英]Android Studio Working With Images

我嘗試從圖庫中挑選一張圖片,並在上面添加一些文字,然后保存。 您能告訴我應該在哪里看或者應該使用哪個圖書館? 我正在使用Android Studio 2.2

首先,您可以將EditText寫入其中,然后在寫入之后,首先將其轉換為Bitmap,如下所示

Bitmap bitmap = Bitmap.createBitmap(mEditText.getDrawingCache());

現在,您可以像這樣將創建的圖像位圖添加到原始圖像中

Bitmap combined = combineImages(bgBitmap,bitmap);

public Bitmap combineImages(Bitmap background, Bitmap foreground) { 

    int width = 0, height = 0;
    Bitmap cs;

    width = getWindowManager().getDefaultDisplay().getWidth();
    height = getWindowManager().getDefaultDisplay().getHeight();

    cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas comboImage = new Canvas(cs);
    background = Bitmap.createScaledBitmap(background, width, height, true);
    comboImage.drawBitmap(background, 0, 0, null);
    comboImage.drawBitmap(foreground, matrix, null);

    return cs;
}

希望對您有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM