当前位置: 动力学知识库 > 问答 > 编程问答 >

image - Android Mat to JPEG converting to inverted Colors

问题描述:

I have an app. You can take pictures with it.

If a picture gets captured, onPictureTaken() gets called. In this Method it gets converted to a Bitmap and afterwards i save it on the local Storage.

@Override

public void onPictureTaken(byte[] data, Camera camera) {

MatOfByte raw=new MatOfByte(data);

Mat mat = Imgcodecs.imdecode(raw,Imgcodecs.CV_LOAD_IMAGE_UNCHANGED);

Mat tmp = new Mat();

Imgproc.cvtColor(mat, tmp, Imgproc.COLOR_BGRA2BGR);

Bitmap bmp = Bitmap.createBitmap(mat.cols(), mat.rows(), Bitmap.Config.ARGB_8888);

Utils.matToBitmap(mat, bmp);

storeBitMap(bmp);

}

I dont know why, but when i open the picture on my fileManager it has inverted colors. What am I doing wrong?

网友答案:

i accidentally put the wrong params

in Utils.matToBitmap(mat, bmp). Should be: Utils.matToBitmap(tmp, bmp)

now everything works fine.

分享给朋友:
您可能感兴趣的文章:
随机阅读: