描述:使用基于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, 这里导致颜色丢失而引发水印现象。需要做如下修改:
- 在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;