简体   繁体   中英

Android Studio Working With Images

I try to pick an image from gallery and add some text on it then save it. Can you tell me where should i look or what library shoul i use? I am using Android Studio 2.2

Firstly, you can put an EditText and write into it, and after writing, you first convert it to Bitmap like below

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

Now you can add created image bitmap to your original image like this

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;
}

I hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM