Android 相机预览会损坏 G2 上的图像输出吗?
我使用 Android 的 Camera
和 SurfaceView
在拍照之前向用户显示预览图像。这在屏幕上看起来很好,但当我拍照时,生成的 jpg 已损坏(水平线)。
作为起点,我使用了 Mark Murphy 的相机/图片示例,其中G2 上也出现同样的问题。
相机参数:
预览尺寸:800x480
图片格式:JPEG
根据 getSupportedPreviewSizes()
和 getSupportedPictureFormats()
均支持
这两个参数 Nexus One,其屏幕尺寸相同,使用相同的参数可以正常工作。
将预览尺寸设置为 640x480 时,G2 可以正常工作
我的问题:之前是否有人遇到过此问题(尽管使用支持的设置,但图像已损坏)?发生的频率如何?你是如何解决这个问题的?
I'm using Android's Camera
and SurfaceView
to show a the preview image to the user before taking a picture. This appears fine on the screen but when I take the picture the resulting jpg is corrupted (horizontal lines).
As a starting point I used Mark Murphy's Camera/Picture example which exhibits the same issue on the G2.
The camera paramaters:
preview size: 800x480
picture format: JPEG
Both parameters are supported according to the getSupportedPreviewSizes()
and getSupportedPictureFormats()
The Nexus One, which has the same size screen, works correctly with the same parameters.
The G2 works correctly when setting the preview size to 640x480
My question: Has anyone else run into this issue before (corrupted image despite using supported settings)? How frequent is it? How did you work around it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
到目前为止,我遇到了同样的问题,现在我设法使用
相机参数设置来修复我的问题。
最近刚刚发现相机默认的图片输出是YUV。这就是为什么它在预览时显示完美,但一旦拍摄照片,您就会得到绿色、粉红色或损坏的图像输出。
这些是相机可能支持的 ImageFormat 值。
因此,除了支持的大小之外,在某些情况下我们可能还需要检查 PictureFormat。
https://i.sstatic.net/PlHFH.png
这些只是使用 ImageFormat 拍摄的示例图像YUV,从而将其保存为 JPEG 压缩。
但在任何情况下,如果您不想更改 ImageFormat 并因此将设置保留为 YUV 格式,您可能需要在此解决方法中保存图像:
So far I had the same issue and now I manage to fix mine using
Camera parameter settings.
Just recently found out that the camera default picture output was YUV. That's is why it shows perfectly on preview but once the picture is taken you would get a green or pink or corrupted image output.
These are the ImageFormat values which camera might support.
So other than the supported size, on some cases we might need to check the PictureFormat as well.
https://i.sstatic.net/PlHFH.png
These are just sample images taken using ImageFormat YUV and thus saving it as JPEG compression.
But in any case that you don't want to change the ImageFormat and thus keep the settings in YUV format you may need to save the image in this workaround: