显示拍摄图像的时间和日期 [英] Display time and date on capture image
本文介绍了显示拍摄图像的时间和日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何显示下面的时间和日期图像。我有一个捕获图像的代码。但是如何在拍摄图像时显示时间和日期。以下是启动相机应用程序的代码
How to display a time and date like below image. I have a code for capturing image. But how can i display time and date in capturing image. Here is the code for launching camera application
我的代码:
public class MyCameraActivity extends Activity {
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.imageView = (ImageView)this.findViewById(R.id.imageView1);
Button photoButton = (Button) this.findViewById(R.id.button1);
photoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
}
}
}
推荐答案
这里您所拥有的图像被带到画布上。现在画布用于通过使用类似于
Here the image you are having is taken onto a canvas. Now the canvas is used to modify the image by writing something on it using something like
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setStyle(Style.FILL);
canvas.drawPaint(paint);
paint.setColor(Color.BLACK);
paint.setTextSize(20);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
String currentDateandTime = sdf.format(new Date());
canvas.drawText(currentDateandTime , 10, 25, paint);
这可能有助于您将图像绘制到图像上。
试试看。
This may help you to draw the text onto the image. Give it a try.
这篇关于显示拍摄图像的时间和日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文