Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 相机图像中缺少位图_Android_Bitmap - Fatal编程技术网

Android 相机图像中缺少位图

Android 相机图像中缺少位图,android,bitmap,Android,Bitmap,实际上,从我的相机获取位图时遇到了一些问题 我的代码: 我在输出时得到透明位图 我的问题在哪里? 我的类实现了SurfaceHolder.Callback、Camera.PictureCallback哦,忘了这一点吧,今天我调用位图方法12-20 11:43:34.461:V/ERROR17621:java.io.FileNotFoundException:No content provider:/external/images/media/8732后出现了错误,这意味着我的公共无效的Pictu

实际上,从我的相机获取位图时遇到了一些问题 我的代码:

我在输出时得到透明位图 我的问题在哪里?
我的类实现了SurfaceHolder.Callback、Camera.PictureCallback

哦,忘了这一点吧,今天我调用位图方法12-20 11:43:34.461:V/ERROR17621:java.io.FileNotFoundException:No content provider:/external/images/media/8732后出现了错误,这意味着我的公共无效的PictureTakenByte[]数据,摄像头摄像头方法不捕捉图像进行位图转换我说的对吗?
private Bitmap loadBitmap(Uri imageUri) {

    float dw = 720;
    float dh = 600;

    Bitmap returnBmp = Bitmap.createBitmap((int) dw, (int) dh, Bitmap.Config.ARGB_4444);
    try {
        BitmapFactory.Options bmpFactorOptions = new BitmapFactory.Options();
        bmpFactorOptions.inJustDecodeBounds = true;
        returnBmp = BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri), null, bmpFactorOptions);
        int heightRatio = (int) Math.ceil(bmpFactorOptions.outHeight / dh);
        int widthRatio = (int) Math.ceil(bmpFactorOptions.outWidth / dw);
        if (heightRatio > widthRatio) {
            bmpFactorOptions.inSampleSize = heightRatio;
        } else {
            bmpFactorOptions.inSampleSize = widthRatio;
        }

        bmpFactorOptions.inJustDecodeBounds = false;
        returnBmp = BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri), null, bmpFactorOptions);

    } catch (FileNotFoundException e) {
        Log.v("ERROR", e.toString());
    }

    return returnBmp;
}

public void surfaceCreated(SurfaceHolder holder) {
    camera = Camera.open();
    Camera.Parameters parameters = camera.getParameters();
    List<String> colorEffects = parameters.getSupportedColorEffects();

    camera.setParameters(parameters);
    try {
        camera.setPreviewDisplay(holder);

    } catch (IOException exception) {
        camera.release();
    }
    camera.startPreview();
}

public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {

}

public void surfaceDestroyed(SurfaceHolder holder) {
    camera.stopPreview();
    camera.release();
}

public void BitMap(View v) {
    camera.takePicture(null, null, null, GetPhoto.this);
}

public void onPictureTaken(byte[] data, Camera camera) {
    Uri snap = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues());
    bmp3 = loadBitmap(Uri.parse(snap.getPath()));
    canvas = new Canvas(bmp3);
    paint = new Paint();
    canvas.drawBitmap(bmp3, 0, 0, paint);
    test.setImageBitmap(bmp3);
    photobit=bmp3;
    Toast t = Toast.makeText(this, bmp3.toString(), Toast.LENGTH_LONG);
    t.show();
    try {
        OutputStream imageFile = getContentResolver().openOutputStream(snap);
        imageFile.write(data);
        imageFile.flush();
        imageFile.close();
    } catch (FileNotFoundException e) {
        Toast td = Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG);
        td.show();
    } catch (IOException e) {
        Toast td = Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG);
        td.show();
    }
    camera.startPreview();
}
public void BitMap(View v) {
    camera.takePicture(null, null, null,  GetPhoto.this);
}