0

I am working on Android application development. My intention is to capture an image using device camera and add the current date and time as text on the captured image. and make the entire thing as single image to upload on server.

halfer
  • 19,824
  • 17
  • 99
  • 186
Ganesh
  • 924
  • 2
  • 12
  • 34

2 Answers2

1

read here

Edit:

Bitmap photo = (Bitmap) data.getExtras().get("data"); 
//create bitmap with a canvas
Bitmap newPhoto = Bitmap.createBitmap(photo.getWidth(),photo.getHeight());
Canvas canvas = new Canvas(newPhoto);
canvas.drawBitmap(photo,0,0,null);
//draw the text
Paint paint = new Paint();
//paint.setColor(Color.BLACK);
canvas.drawText("write bla bla bla",x,y,paint);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
newPhoto.compress(Bitmap.CompressFormat.PNG, 100, stream);
//get bytes from stream and send to your server
Community
  • 1
  • 1
Trần Sĩ Long
  • 457
  • 3
  • 15
0

Extend a View, for example ImageView:

public class MyImageView extends ImageView{}

Override the onDraw()

@Override
public void onDraw(Canvas canvas){

    // draw the image you got from the camera
    canvas.drawBitmap(cameraImage, 0, 0, paint);

    // draw the date
    canvas.drawText("Date string", x, y, paint);

}

When you want to send the image:

myImageView.buildDrawingCache();
Bitmap bmp = myImageView.getDrawingCache();

For sending to the server, that's another question and many examples here on SO. Good luck.

Simon
  • 14,407
  • 8
  • 46
  • 61