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