Reputation: 1459
In my android application I use camera to capture photo. I want to print date and time on captured photo. As in normal camera there is an option that, if you set date and time on camera then it will printed on right lower side of the photo.
To capture the photo I use cameraIntent:
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
and in onActivityResult I save in photo.
Now how I print date and time on this photo.
Upvotes: 0
Views: 3469
Reputation: 3937
This code adding a image on top of another image u can use this...
Bitmap bottomImage = BitmapFactory.decodeResource(ctx.getResources(),
R.drawable.first);
Bitmap topImage = BitmapFactory.decodeResource(ctx.getResources(),
R.drawable.second);
Canvas comboImage = new Canvas(bottomImage);
// Then draw the second on top of that
float f=(float) 0.1;
comboImage.drawBitmap(topImage, 38f, 35f, null);
Upvotes: 3
Reputation: 14038
open the bitmap as a canvas and write the date/time as text wherever you like. The changes would would saved on the bitmap. Some sample code is as follows. Google Paint and Canvas classes for more options
Canvas canvas = new Canvas(bmp); //bmp is the bitmap to dwaw into
Paint paint== new Paint();
paint.setColor(Color.YELLOW);
paint.setTextSize(28);
paint.setTextAlign(Paint.Align.CENTER);
Finally, we can draw text with this font via the following Canvas method:
canvas.drawText("This is a test!", 100, 100, paint);
The first parameter is the text to draw. The next two parameters are the coordinates where the text should be drawn to ( play with them to get the position right). Then is Paint instance. No need to use drawBimtap. Whatever you will do on the canvas will be saved on the original bitmap directly without over-writing.
Upvotes: 1