简体   繁体   English

Android相机SurfaceView替代

[英]Android camera SurfaceView alternative

I develop simple camera app for android devices 2.1 and later. 我为Android设备2.1及更高版本开发了简单的相机应用。 I use standard way to show preview layer from camera using SurfaceView and SurfaceHolder. 我使用标准方法通过SurfaceView和SurfaceHolder从相机显示预览图层。 But I know about camera issue on 2.1 that camera preview displays properly only in landscape mode. 但是我知道2.1上的相机问题,即相机预览只能在横向模式下正确显示。 But I need portrait mode only in my app. 但是我只需要在我的应用中使用人像模式。 Is there another ways/libs to show user preview from camera on 2.1 and later. 还有其他方法/库可以显示2.1及更高版本上的相机预览。 Thanks. 谢谢。

You can add a listener to the Camera.onPreviewDisplay callback, thus intercepting the generated frames. 您可以将侦听器添加到Camera.onPreviewDisplay回调中,从而拦截生成的帧。 At this point with the given byte[] of data containing your pixels, you can do pretty much whatever you want. 此时,使用包含像素的给定数据byte [],您可以执行几乎所有所需的操作。 For example you can apply your own processing algorithm to the pixels and then draw the image to whatever ImageView or TextureView (since API 11) that you want. 例如,您可以将自己的处理算法应用于像素,然后将图像绘制到所需的任何ImageView或TextureView(自API 11起)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM