最近公司要上中星微的平台,老大由于中星微的平板电脑的方案才刚刚开始,平台也是在启蒙阶段,在camera上面的支持还不是特别的完善,记得打开camera拍照的时候有选着只是 拍照的质量 但是我们的客户要就的不仅仅是这点东西就可以满足的,下面就谈谈我是如何参考三星的平台与camera的android系统的架构,添加拍照的 曝光 图片的存储格式 白平衡 色彩效果,要做这些东东 ,我想就有必要要好好的研究一下android的架构了,从应用 应用架构 HAL 和kernel的整个流程都要做到,才可以完成以上的效果,下面就让我慢慢道来。。。。。
下面是我添加的功能:
曝光 的菜单有5个级别
+2
+1
0
-1
-2
主要是增加拍照的亮度
照片大小:下拉菜单
VGA
QVGA
p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, "640x480,320x240");
分辨率是 640 x 320 320 x 240
色彩效果:下拉菜单
正常
灰阶
棕褐色
棕褐色绿
棕褐色蓝
彩色反转
灰色反转
浮雕
素描
白平衡:下拉菜单
自动
白吇光
日光
荧光
阴天
以上的功能实现主要修改的文件有一些,呵呵,android的系统架构还是要好好的了解一下,对于我们改写camera的流程有很大的帮助的:有兴趣的朋友好好的了解一下,修改菜单:
1、framework.jar(out\target\product\smdkv210\system\framework)
frameworks\base\core\java\android\hardware\camera.java 该文件的路径 此处主要是修改的是android的应用层得代码
public static final String EFFECT_NORMAL = "normal";
public static final String EFFECT_GRAYSCALE = "grayscale";
public static final String EFFECT_SEPIA = "sepia";
public static final String EFFECT_SEPIA_GREEN = "sepia_green";
public static final String EFFECT_SEPIA_BLUE = "sepia_blue";
public static final String EFFECT_COLOR_INV = "color_inv";
public static final String EFFECT_GRAY_INV = "gray_inv";
public static final String EFFECT_EMBOSSMENT = "embossment";
public static final String EFFECT_SKETCH = "sketch";
这些是色彩效果的英文翻译:
2、camera.apk
packages\apps\camera
{
./packages/apps/Camera/res/values/arrays.xml: 要修改文件的路劲
!-- Camera Preferences White Balance dialog box entries -->
<string-array name="pref_camera_whitebalance_entries" translatable="false">
<item>@string/pref_camera_whitebalance_entry_auto</item>
<item>@string/pref_camera_whitebalance_entry_incandescent</item>
<item>@string/pref_camera_whitebalance_entry_daylight</item>
<item>@string/pref_camera_whitebalance_entry_fluorescent</item>
<item>@string/pref_camera_whitebalance_entry_cloudy</item>
</string-array>
<string-array name="pref_camera_whitebalance_entryvalues" translatable="false">
<item>auto</item>
<item>incandescent</item>
<item>daylight</item>
<item>fluorescent</item>
<item>cloudy-daylight</item>
</string-array>
<array name="pref_camera_whitebalance_icons">
<item>@drawable/ic_menuselect_wb_auto</item>
<item>@drawable/ic_menuselect_wb_incandescent</item>
<item>@drawable/ic_menuselect_wb_daylight</item>
<item>@drawable/ic_menuselect_wb_fluorescent</item>
<item>@drawable/ic_menuselect_wb_cloudy</item>
</array>
<!-- wan yuanlai up -->
<string-array name="pref_camera_coloreffect_entries" translatable="false">
<item>@string/pref_camera_coloreffect_entry_normal</item>
<item>@string/pref_camera_coloreffect_entry_grayscale</item>
<item>@string/pref_camera_coloreffect_entry_sepia</item>
<item>@string/pref_camera_coloreffect_entry_sepia_green</item>
<item>@string/pref_camera_coloreffect_entry_sepia_blue</item>
<item>@string/pref_camera_coloreffect_entry_color_inv</item>
<item>@string/pref_camera_coloreffect_entry_gray_inv</item>
<item>@string/pref_camera_coloreffect_entry_embossment</item>
<item>@string/pref_camera_coloreffect_entry_sketch</item>
</string-array>
<string-array name="pref_camera_coloreffect_entryvalues" translatable="false">
<item>normal</item>
<item>grayscale</item>
<item>sepia</item>
<item>sepia_green</item>
<item>sepia_blue</item>
<item>color_inv</item>
<item>gray_inv</item>
<item>embossment</item>
<item>sketch</item>
</string-array>
由于要改的还是比较多的就贴出一点点,了解一下流程
./packages/apps/Camera/res/values/strings.xml: <string name="pref_camera_coloreffect_entry_embossment">Embossment</string>
<string name="pref_camera_picturesize_entry_640x480">VGA</string>
<string name="pref_camera_picturesize_entry_320x240">QVGA</string>
<!-- wang add -->
<string name="pref_camera_coloreffect_entry_normal">Normal</string>
<string name="pref_camera_coloreffect_entry_grayscale">Gray scale</string>
<string name="pref_camera_coloreffect_entry_sepia_green">Sepia green</string>
<string name="pref_camera_coloreffect_entry_sepia_blue">Sepia blue</string>
<string name="pref_camera_coloreffect_entry_color_inv">Color invert</string>
<string name="pref_camera_coloreffect_entry_gray_inv">Gray invert</string>
<string name="pref_camera_coloreffect_entry_embossment">Embossment</string>
<string name="pref_camera_coloreffect_entry_sketch">Sketch</string>
<!-- wang add -->
}
3、libcamera_client.so
a:frameworks\base include\camera
{
./frameworks/base/include/camera/CameraParameters.h: static const char EFFECT_EMBOSSMENT[];
// Values for white balance settings.
static const char WHITE_BALANCE_AUTO[];
static const char WHITE_BALANCE_INCANDESCENT[];
static const char WHITE_BALANCE_FLUORESCENT[];
static const char WHITE_BALANCE_WARM_FLUORESCENT[];
static const char WHITE_BALANCE_DAYLIGHT[];
static const char WHITE_BALANCE_CLOUDY_DAYLIGHT[];
static const char WHITE_BALANCE_TWILIGHT[];
static const char WHITE_BALANCE_SHADE[];
}
b:frameworks\base\libs\camera
{
./frameworks/base/libs/camera/CameraParameters.cpp: const char CameraParameters::EFFECT_EMBOSSMENT[] = "embossment";
//wangyulu
// Values for effect settings.
const char CameraParameters::EFFECT_NORMAL[] = "normal";
const char CameraParameters::EFFECT_GRAYSCALE[] = "grayscale";
const char CameraParameters::EFFECT_SEPIA[] = "sepia";
const char CameraParameters::EFFECT_SEPIA_GREEN[] = "sepia_green";
const char CameraParameters::EFFECT_SEPIA_BLUE[] = "sepia_blue";
const char CameraParameters::EFFECT_COLOR_INV[] = "color_inv";
const char CameraParameters::EFFECT_GRAY_INV[] = "gray_inv";
const char CameraParameters::EFFECT_EMBOSSMENT[] = "embossment";
const char CameraParameters::EFFECT_SKETCH[] = "sketch";
}
4:libcameraservice.so
frameworks\base\services
{
frameworks\base\services\camera\libcameraservice\CameraService.cpp 修改该文
}
5、libcamera.so
注意:\vimicro\hardware\libcamera
这个文件改的比较多了,就不在这里贴出来了,这是Android的HAL层得代码,主要的功能就是检测客户的选择,然后实现说选是的功能,比如客户选择了"灰阶"的功能,该代码检测到以后,就调用ioctl函数,调用到kernel里面的代码
kernel要改的代码是:vc088kerneldriversmediavideovc088x\cif 里面
流程是VC088x_cif_drv.c->gc0308的代码
主要是调用iic的写函数,把"灰阶"的配置写到GC0308的寄存器里面,实现图片的"灰阶"功能:
unsigned char gc0308_effect_grayscale [][2] = {
{0x23,0x02},//grayscale
{0x2d,0x0a},
{0x20,0xff},
{0xd2,0x90},
{0x73,0x00},
{0xb3,0x40},
{0xb4,0x80},
{0xba,0x00},
{0xbb,0x00},
};
以上主要是我实现,camera的特效的基本流程,如果有不明白的地方,可以给我博客留言。谢谢