FAQ09934:相机prevew时候出现水印问题

描述:使用基于mtk camera修改的app,发现preview时候出现水印,而在mtk自带的camera上没有该现象

解决:使用DDMS截图和layer dump工具均能发现有有水印图片出现。

比对有水印和没有水印的layer dump log,发现出问题的时候的SurfaceView:

  • Layer 0x42505008 (SurfaceView) activeBuffer=[ 720x1280: 736, 4], colorformat 是RGB565.

而正常时候的SurfaceView:

  • Layer 0x42505789 (SurfaceView) activeBuffer=[ 720x1280: 736, 5], colorformat 是RGB888.

review修改camera ap部分发现在preview时候设定的color format就是RGB565, 这里导致颜色丢失而引发水印现象。需要做如下修改:

  1. 在GLRootView.java中:

public GLRootView(Context context, AttributeSet attrs) { ......

if(USE_RGB888)

getHolder().setFormat(PixelFormat.RGB_888);

else

getHolder().setFormat(PixelFormat.RGB_565);

}

在GalleryEGLConfigChooser.java中:增加RGB888的配置:

private final int mConfigSpec565[] = new int[] {

EGL10.EGL_RED_SIZE, 5,

EGL10.EGL_GREEN_SIZE, 6,

EGL10.EGL_BLUE_SIZE, 5,

EGL10.EGL_ALPHA_SIZE, 0,

EGL10.EGL_NONE

};

private final int mConfigSpec888[] = new int[] {

EGL10.EGL_RED_SIZE, 8,

EGL10.EGL_GREEN_SIZE, 8,

EGL10.EGL_BLUE_SIZE, 8,

EGL10.EGL_ALPHA_SIZE, 0,

EGL10.EGL_NONE

};

private boolean USE_RGB888 = true;

public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {

int mConfigSpec[] = (USE_RGB888 == true)? mConfigSpec888 : mConfigSpec565;

相关推荐
火柴就是我43 分钟前
让我们实现一个更好看的内部阴影按钮
android·flutter
砖厂小工7 小时前
用 GLM + OpenClaw 打造你的 AI PR Review Agent — 让龙虾帮你审代码
android·github
张拭心8 小时前
春节后,有些公司明确要求 AI 经验了
android·前端·人工智能
张拭心8 小时前
Android 17 来了!新特性介绍与适配建议
android·前端
Kapaseker10 小时前
Compose 进阶—巧用 GraphicsLayer
android·kotlin
黄林晴11 小时前
Android17 为什么重写 MessageQueue
android
阿巴斯甜1 天前
Android 报错:Zip file '/Users/lyy/develop/repoAndroidLapp/l-app-android-ble/app/bu
android
Kapaseker1 天前
实战 Compose 中的 IntrinsicSize
android·kotlin
xq95271 天前
Andorid Google 登录接入文档
android
黄林晴1 天前
告别 Modifier 地狱,Compose 样式系统要变天了
android·android jetpack