-1

I am trying to develop a camera app. In which I need to capture an image and just after that before saving I need to add some text over the captured image. Is it possible to edit the captured image at a run time in android please suggest me?

demo output

activity_camera.xml

<ImageView
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:id="@+id/imageView"
    android:layout_weight="9"
    />
<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/btnCamera"
    android:layout_weight="1"
    android:background="@android:color/holo_blue_dark"
    android:textColor="@android:color/white"
    android:text="Open Camera"
    />

CameraActivity.java

public class CameraActivity extends Activity {
    private ImageView imageView;
    private Camera camera;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_camera);
        Button btnCamera = (Button)findViewById(R.id.btnCamera);
        imageView = (ImageView)findViewById(R.id.imageView);
        btnCamera.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(CameraActivity.this, "Camera Text", Toast.LENGTH_SHORT).show();
                File file = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), "Test.jpg");
                Uri iImageOutputUri = Uri.fromFile(file);
                AppPermission appPermission = new AppPermission(CameraActivity.this);
                if (!appPermission.checkPermissionForCamera()) {
                appPermission.requestPermissionForCamera();
                }else {
                    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    startActivityForResult(intent,0);
                }
            }
        });
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Toast.makeText(CameraActivity.this, "Camera Text 2", Toast.LENGTH_SHORT).show();
        // Process result for camera activity.
        // If camera take picture success.
        if (resultCode == RESULT_OK) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String currentDateandTime = sdf.format(new Date());
            Toast.makeText(this, currentDateandTime, Toast.LENGTH_SHORT).show();
            Bitmap bitmap = (Bitmap) data.getExtras().get("data");
            imageView.setImageBitmap(bitmap);
        }
    }
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

If you want to show time stamp on the clicked image, you can follow these steps:

  1. After image clicked so it in the image view.

  2. Upon that image view there is already been a textview set textview with time stamp and take the screenshot programatically of relative layout which contains both image view and textview.

If you need help anywhere, just let me know.

Suraj Vaishnav
  • 7,777
  • 4
  • 43
  • 46