Reputation: 934
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.
Upvotes: 0
Views: 999
Reputation: 14472
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.
Upvotes: 0
Reputation: 477
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
Upvotes: 1