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;

相关推荐
海天鹰1 小时前
PHP上传文件
android·开发语言·php
2501_915918412 小时前
详解iOS App上架至App Store的全流程步骤与注意事项
android·macos·ios·小程序·uni-app·cocoa·iphone
码农coding4 小时前
android12 SystemUI之StatusBar(二)
android
Lesile5 小时前
Interview#1 历史演进:MVC · MVP · MVVM · MVI架构详解
android·android jetpack
杉氧6 小时前
Flutter 像素级还原实战:用 CustomPaint 与 Bezier 曲线手绘精致图针
android·前端·flutter
我命由我123458 小时前
Android 在构建过程中,发现有两个依赖库都包含了相同路径的资源文件
android·java·开发语言·java-ee·kotlin·android-studio·android runtime
Coffeeee9 小时前
谷歌的一个优化建议,让我重新学了一遍Android里面如何正确处理位图
android·google·kotlin
冰暮流星9 小时前
mysql之新建表及对表的查询
android·数据库·mysql
用户2018792831679 小时前
彻底搞懂LayoutInflater、ViewInflater与textViewStyle优先级:XML属性为何能覆盖全局样式?
android
达达尼昂9 小时前
AI Native 工程实践:如何为 Claude 5 设计更有效的上下文
android·人工智能·后端