想要在android

问题描述

这是我的问题:

  1. 从相机捕获图像
  2. 在上面写一些文字
  3. 将其保存到应用程序文件夹中

我涵盖的第一点。 帮我争取剩下的两分

预先感谢

解决方法

尝试

1-将文本写入位图的代码

Bitmap bitmap = ... // your bitmap here
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(); 
paint.setColor(Color.BLACK); 
paint.setTextSize(10); 
canvas.drawText("Some Text here",x,y,paint);

2-将位图保存到存储的代码

// Assume block needs to be inside a Try/Catch block.
String path = Environment.getExternalStorageDirectory().toString();
OutputStream fOut = null;

File file = new File(path,"File.jpg"); 
fOut = new FileOutputStream(file);

pictureBitmap.compress(Bitmap.CompressFormat.JPEG,85,fOut); // saving the Bitmap to a file compressed as a JPEG with 85% compression rate
fOut.flush(); // Not really required
fOut.close(); // do not forget to close the stream

MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());

源:Save bitmap to location

How to write text on an image

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...