简体   繁体   English

Android Studio处理图像

[英]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 我正在使用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 首先,您可以将EditText写入其中,然后在写入之后,首先将其转换为Bitmap,如下所示

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. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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