0

我正在使用下一个代码获取图片:

public void foto(View v) {
    nom_foto = Environment.getExternalStorageDirectory()+ aptr.ruta_temp + cuadrilla + "/" + medidor + "_"+ cont_foto + ".jpg";
    File arch = new File(Environment.getExternalStorageDirectory()+ aptr.ruta_temp+ cuadrilla);
    if (!arch.exists())
        arch.mkdirs();
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    int code = TAKE_PICTURE;
    Uri output = Uri.fromFile(new File(nom_foto));
    intent.putExtra(MediaStore.EXTRA_OUTPUT, output);
    startActivityForResult(intent, code);
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == TAKE_PICTURE) {
        ImageView iv = (ImageView) findViewById(R.id.minifoto);
        if (resultCode == RESULT_OK) {
            new MediaScannerConnectionClient() {
                private MediaScannerConnection msc = null;
                {
                    msc = new MediaScannerConnection(getApplicationContext(), this);
                    msc.connect();
                }
                public void onMediaScannerConnected() {msc.scanFile(nom_foto,null); 
                }
            public void onScanCompleted(String path, Uri uri) 
            { msc.disconnect();}};
        Toast.makeText(usuario_lectura.this,"Foto N° " + cont_foto + " agregada  correctamente",    Toast.LENGTH_LONG).show();
        cont_foto++;
        iv.setVisibility(View.VISIBLE);
        iv.setImageBitmap(BitmapFactory.decodeFile(nom_foto));
        }
    }
    if (resultCode == RESULT_CANCELED) {
        File file = new File(nom_foto);
        if (file.exists())
            file.delete();
        }
    }
}

一切正常,照片已正确拍摄并保存在 SD 卡上...但是,我必须添加水印,包括日期...如何添加?,相机活动没有给我这些选项...

4

1 回答 1

0

为了从相机向您的图像添加文本或图形水印,您必须打开图像,Canvas使用Paint/Graphics叠加层对其进行编辑,然后将其重新编码为 .jpg 图像,并将其重新保存为文件SD卡。您可以保存相机中的原始文件。所有这些步骤都相当简单。

然而,有一个严重的障碍。

大多数设备将无法在单个位图中打开来自相机的全尺寸图像。没有足够的可用堆内存。因此,您必须使用比例因子inSampleSize来打开图像。因此,带水印的图像将永远比相机的原始图像小一些。

我认为没有办法解决这个问题:(

于 2013-04-01T17:11:35.873 回答