【发布时间】:2016-01-25 11:52:46
【问题描述】:
目前我有代码:
onPreviewFrame(byte[] 数据)
int[] rgbs = new int[480*800];
decodeYUV(rgbs, data, 480, 800);
Bitmap bitmap = Bitmap.createBitmap(rgbs, 800, 480, Bitmap.Config.ARGB_8888);
Matrix matrix = new Matrix();
matrix.postRotate(90);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap,800,480,true);
Bitmap rotatedBitmap = Bitmap.createBitmap(scaledBitmap , 0, 0, scaledBitmap .getWidth(), scaledBitmap .getHeight(), matrix, true);
sbut.setImageBitmap(rotatedBitmap);
decodeYUV 函数所在的位置here
预览是这样设置的:
param.setPreviewSize(800, 480);
camera.setDisplayOrientation(90);
所以预览设置为纵向模式,Height = 800, Width = 480。
我最终不得不回到横向来执行转换。然后再次旋转回纵向。我可以想象这很慢。没有双重旋转有没有更有效的替代方案?
我想保持纵向模式的预览。我的最终结果应该是上面的rotatedBitmap,这只是肖像。 onPreviewFrame 方法中的任何行都可以更改。
【问题讨论】:
标签: android bitmap android-camera