Android 像卡IO一样的相机自动裁剪?或显示曲面(虚线)并在捕获后自动裁剪

Android 像卡IO一样的相机自动裁剪?或显示曲面(虚线)并在捕获后自动裁剪,android,camera,crop,surfaceholder,cardio,Android,Camera,Crop,Surfaceholder,Cardio,我正在使用Camera Intent捕获和上载..作为默认相机 所以在这里,我跟随裁剪图像,就像卡IO一样 但上面的一个是单独的摄像头,不是它的意图 我想表面支架应该放在相机里面。。如果可以的话,有人能推荐我吗 我要在捕获之前进行表面裁剪。。。。仅用于照相机目的。。不适合画廊。。。就像卡迪奥。。。。但仅适用于作物…不适用于OCR 因此,我想在本文中使用上述功能 private File createImageFile() throws IOException { String timeS

我正在使用Camera Intent捕获和上载..作为默认相机

所以在这里,我跟随裁剪图像,就像卡IO一样

但上面的一个是单独的摄像头,不是它的意图

我想表面支架应该放在相机里面。。如果可以的话,有人能推荐我吗

我要在捕获之前进行表面裁剪。。。。仅用于照相机目的。。不适合画廊。。。就像卡迪奥。。。。但仅适用于作物…不适用于OCR

因此,我想在本文中使用上述功能

private File createImageFile() throws IOException {
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = "JPEG_" + timeStamp + "_";
    File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    File imageFile = File.createTempFile(imageFileName,".jpg",storageDir);
    return imageFile;
}
public class PQChromeClient extends WebChromeClient {

public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, WebChromeClient.FileChooserParams fileChooserParams) {
        if (mFilePathCallback != null) {
            mFilePathCallback.onReceiveValue(null);
        }
        mFilePathCallback = filePath;

        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
            File photoFile = null;
            try {
                photoFile = createImageFile();
                takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
            } catch (IOException ex) {
                Log.e(TAG, "Unable to create Image File", ex);
            }
            if (photoFile != null) {
                mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(photoFile));
            } else {
                takePictureIntent = null;
            }
        }
        Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
        contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
        contentSelectionIntent.setType("image*//*");
        Intent[] intentArray;
        if (takePictureIntent != null) {
            intentArray = new Intent[]{takePictureIntent};
        } else {
            intentArray = new Intent[0];
        }

        Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
        //chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
        chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
        chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
        //chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
        startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
        return true;
    }

    public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
        mUploadMessage = uploadMsg;
        File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "My_Camera");

        if (!imageStorageDir.exists()) {
            imageStorageDir.mkdirs();
        }
        File file = new File(imageStorageDir + File.separator + "IMG_"+ String.valueOf(System.currentTimeMillis())+ ".jpg");

        mCapturedImageURI = Uri.fromFile(file);
        final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

        captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);

        Intent i = new Intent(Intent.ACTION_GET_CONTENT);
        i.addCategory(Intent.CATEGORY_OPENABLE);
        i.setType("image*//*");

        Intent chooserIntent = Intent.createChooser(i,"Image Chooser");
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Parcelable[] { captureIntent });
        startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);
    }

    public void openFileChooser(ValueCallback<Uri> uploadMsg) {
        openFileChooser(uploadMsg, "");
    }

    public void openFileChooser(ValueCallback<Uri> uploadMsg,String acceptType,String capture) {
        openFileChooser(uploadMsg, acceptType);
    }
}
private File createImageFile()引发IOException{
字符串时间戳=新的SimpleDateFormat(“yyyyMMdd_HHmmss”)。格式(新日期();
字符串imageFileName=“JPEG_389;”+时间戳+“389;”;
文件storageDir=Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY\u图片);
File imageFile=File.createTempFile(imageFileName,.jpg,.storageDir);
返回图像文件;
}
公共类PQChromeClient扩展WebChromeClient{
公共布尔onShowFileChooser(WebView视图、ValueCallback文件路径、WebChromeClient.FileChooseParams文件选择器参数){
if(mFilePathCallback!=null){
mFilePathCallback.onReceiveValue(null);
}
mFilePathCallback=文件路径;
Intent takePictureIntent=新的意图(MediaStore.ACTION\u IMAGE\u CAPTURE);
if(takePictureContent.resolveActivity(getPackageManager())!=null){
文件photoFile=null;
试一试{
photoFile=createImageFile();
takePictureContent.putExtra(“光路”,mCameraPhotoPath);
}捕获(IOEX异常){
Log.e(标记“无法创建图像文件”,例如);
}
if(photoFile!=null){
mCameraPhotoPath=“文件:”+photoFile.getAbsolutePath();
takePictureContent.putExtra(MediaStore.EXTRA_输出,Uri.fromFile(photoFile));
}否则{
takePictureContent=null;
}
}
意图内容SelectionContent=新意图(Intent.ACTION\u GET\u CONTENT);
ContentSelectionContent.addCategory(Intent.CATEGORY\u可打开);
contentSelectionContent.setType(“image*/*”);
意图[]意图射线;
if(takePictureContent!=null){
intentArray=newintent[]{takePictureIntent};
}否则{
intentArray=新意图[0];
}
意图选择器content=新意图(Intent.ACTION\u选择器);
//选择content.putExtra(Intent.EXTRA\u Intent,content selection内容);
选择content.putExtra(Intent.EXTRA\u Intent,content selection内容);
选择content.putExtra(Intent.EXTRA_标题,“图像选择器”);
选择content.putExtra(Intent.EXTRA\u INITIAL\u INTENTS,intentArray);
//选择content.putExtra(Intent.EXTRA\u INITIAL\u INTENTS,intentArray);
startActivityForResult(选择内容、输入文件、请求代码);
返回true;
}
public void openFileChooser(ValueCallback uploadMsg,String acceptType){
mUploadMessage=上传消息;
File imageStorageDir=新文件(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY\u PICTURES),“我的相机”);
如果(!imageStorageDir.exists()){
imageStorageDir.mkdirs();
}
File File=new File(imageStorageDir+File.separator+“IMG_”+String.valueOf(System.currentTimeMillis())+“.jpg”);
mCapturedImageURI=Uri.fromFile(文件);
最终意图捕获意图=新意图(android.provider.MediaStore.ACTION\u IMAGE\u CAPTURE);
putExtra(MediaStore.EXTRA_输出,mCapturedImageURI);
意向i=新意向(意向.行动\u获取\u内容);
i、 addCategory(意图。类别可打开);
i、 setType(“图像*/*”);
Intent chooserint=Intent.createChooser(i,“图像选择器”);
选择content.putExtra(Intent.EXTRA_INITIAL_INTENTS,新包裹[]{captureentent});
startActivityForResult(选择内容、文件选择器\u结果代码);
}
public void openFileChooser(ValueCallback uploadMsg){
openFileChooser(uploadMsg,“”);
}
public void openFileChooser(ValueCallback uploadMsg、字符串接受类型、字符串捕获){
openFileChooser(uploadMsg,acceptType);
}
}
有人能推荐我吗。。关于这个

在这里,我已经尝试了自动裁剪通过放置作物的意图。。。但它显示了从裁剪位置到裁剪位置的类似预览的曲面。。。。对于通过意图的默认摄影机。。。。。不适用于自定义相机活动