bitmapfactory を使用してビットマップ クラスを作成しようとしています。カメラのプレビュー画像を YUV 形式で取得し、手動でグレースケール画像にデコードします。BitmapFactory を介してビットマップ オブジェクトを作成しようとすると、null が返されます。
try {
for (int y = 0; y < frameHeight; y++){
for (int x = 0; x < frameWidth; x++){
byte grey = YUVData[y * frameWidth + x];
convertedData[y * stride + 3 * x] = grey;
convertedData[y * stride + 3 * x + 1] = grey;
convertedData[y * stride + 3 * x + 2] = grey;
}
}
Bitmap bitmap =(Bitmap) BitmapFactory.decodeByteArray(convertedData, 0, convertedData.length);