0
我有使用照相机意图的应用程序并将拍摄的照片保存到特定文件夹中。现在我错过了一个更多的功能,那就是在拍摄照片后,我应该添加纯文本(时间戳,图片下/上边框上的更多信息)并保存。将纯文本添加到从相机意图拍摄的照片
如何实现这一目标?我的代码如下
public void takePicture(View view)
{
Intent intentCamera = new Intent();
intentCamera.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
File photofile = null;
try{
photofile=createImageFile();
intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photofile));
startActivityForResult(intentCamera, ActivityStartamera);
//Toast.makeText(this,Uri.fromFile(photofile).toString(), Toast.LENGTH_LONG).show();
}
catch (IOException e)
{
e.printStackTrace();
Toast.makeText(this, "Error happened", Toast.LENGTH_LONG).show();
imageFileName="";
}
}
protected void onActivityResult (int requestCode, int resultCode, Intent data)
{
if(requestCode == ActivityStartamera && resultCode == RESULT_OK)
{
//
//here i should add plain text to taken picture
//
Toast.makeText(this, "Picture taken", Toast.LENGTH_LONG).show();
}
else{
image.delete();
}
}
File createImageFile() throws IOException{
String timeStamp = new SimpleDateFormat("MMyyyydd_HHmmss").format(new Date());
imageFileName = "picture_"+timeStamp;
storage = Environment.getExternalStoragePublicDirectory("PicturesForApp");
if (!storage.exists())
{
Toast.makeText(this, "Folder made for pictures", Toast.LENGTH_LONG).show();
storage.mkdirs();
}
image = new File(storage + "/" +imageFileName +".jpg");
return image;
}
我已经试过类似this但unsucesfull。
你可以加我调用此方法,应该把“一些文字”进入我的画面的一个例子。使用过你的代码,但仍然图片没有改变 – KuKeC
@KuKeC请检查更新的答案 –
感谢它帮助了我。你能告诉我如何在图片上的文字上添加背景颜色吗?例如,我想在黑色背景中有白色文字。 – KuKeC