📄 mmidc_review.c
字号:
/*****************************************************************************
** File Name: mmidc_review.c *
** Author: *
** Date: 2005-8 *
** Copyright: 2003 Spreadtrum, Incorporated. All Rights Reserved. *
** Description: This file is used to describe dc review *
*****************************************************************************
** Important Edit History *
** --------------------------------------------------------------------------*
** DATE NAME DESCRIPTION *
** 08/2005 Bruce.Chi Create *
*****************************************************************************/
#ifndef _MMIDC_REVIEW_C_
#define _MMIDC_REVIEW_C_
/**--------------------------------------------------------------------------*
** Include Files *
**--------------------------------------------------------------------------*/
#include "mmidc_internal.h"
#include "mmidisplay_data.h"
#ifdef _MMI_OCR
#ifdef WIN32
#include "mmiocr_win32_simu.h"
#else
#include "ocr_driver.h"
#endif
#endif
/**--------------------------------------------------------------------------*
** MACRO DEFINITION *
**--------------------------------------------------------------------------*/
/**--------------------------------------------------------------------------*
** STATIC DEFINITION *
**--------------------------------------------------------------------------*/
static MMIDC_PHOTO_INFO_AFTER_REVIEW_T s_dc_photo_info_after_review;
static MMIDC_REVIEW_PHOTO_INFO_T s_photo_review_info;
RECT_T s_osd_char_disp_rect;
/*---------------------------------------------------------------------------*/
/* TYPE AND CONSTANT */
/*---------------------------------------------------------------------------*/
/**--------------------------------------------------------------------------*
** EXTERNAL DECLARE *
**--------------------------------------------------------------------------*/
/**-------------------------------------------------------------------------*
** GLOBAL DEFINITION *
**--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* LOCAL FUNCTION DECLARE */
/*---------------------------------------------------------------------------*/
/*****************************************************************************/
// Description : right trunk a number with 16
// Global resource dependence :
// Author:bruce.chi
// Note:
/*****************************************************************************/
__inline LOCAL uint16 right_trunk_16(uint16 in_num);
/*****************************************************************************/
// Description : right trunk a number with 8
// Global resource dependence :
// Author:bruce.chi
// Note:
/*****************************************************************************/
__inline LOCAL uint16 right_trunk_8(uint16 in_num);
/*****************************************************************************/
// Description : left trunk a number with 2
// Global resource dependence :
// Author:bruce.chi
// Note:
/*****************************************************************************/
__inline LOCAL uint16 left_trunk_2(uint16 in_num);
/*****************************************************************************/
// Description : right trunk a number with 2
// Global resource dependence :
// Author:bruce.chi
// Note:
/*****************************************************************************/
__inline LOCAL uint16 right_trunk_2(uint16 in_num);
/*****************************************************************************/
// Description : display photo,
// Global resource dependence :
// Author:
// Note: standard interface copied form digitalcamera.h
// disp_rect的计算是根据原图的大小,取一个大的缩小scale系数,然后除出来的。
/*****************************************************************************/
LOCAL int DCAdap_ReviewPhotoCallBack(/*when DCAM encount SOF0, it will call this function*/
/* returns: 0 successful, others failed*/
int b_validate, /* indicate if the stream is validate*/
uint16 w_photo_width, /* if stream is validate, it refer to image width*/
uint16 w_photo_height /* if stream is validate, it refer to image height*/
)
{
DC_REVIEW_PARAM_T st_param = {0};
uint16 lcd_width = 0;
uint16 lcd_height = 0;
uint16 trim_width = 0;
uint16 trim_height = 0;
uint16 disp_width = 0;
uint16 disp_height = 0;
SCI_TRACE_LOW("DCAdap_ReviewPhotoCallBack");
if (b_validate)
{
//save the photo info
s_dc_photo_info_after_review.width = w_photo_width;
s_dc_photo_info_after_review.height = w_photo_height;
st_param.i_lcd = s_photo_review_info.i_lcd;
st_param.b_postfilter = MMIDC_REVIEW_POSTFILTER_STATE;
st_param.i_smooth = MMIDC_REVIEW_I_SMOOTH;
st_param.b_is_scale = 1;
if (s_photo_review_info.e_review_type == REVIEW_WHOLE_PHOTO)
{
// review时st_trim_rect的起点,建议设在16的整数倍上,st_trim_rect的长宽也建议设成16的整数倍
// st_trim_rect不能位于回放图像的原始尺寸之外
// st_trim_rect位于原图的中部
if (s_photo_review_info.i_lcd == MAIN_LCD_ID)
{
trim_width = MIN(w_photo_width, w_photo_height * MMIDC_MAINSCREEN_WIDTH / MMIDC_MAINSCREEN_HEIGHT);
trim_height= MIN(w_photo_height, w_photo_width * MMIDC_MAINSCREEN_HEIGHT / MMIDC_MAINSCREEN_WIDTH);
}
else
{
trim_width = MIN(w_photo_width, w_photo_height * MMI_SUBSCREEN_WIDTH / MMI_SUBSCREEN_HEIGHT);
trim_height= MIN(w_photo_height, w_photo_width * MMI_SUBSCREEN_HEIGHT / MMI_SUBSCREEN_WIDTH);
}
SCI_TRACE_LOW("w_photo_width =%d,trim_width =%d,w_photo_height=%d",w_photo_width,trim_width,w_photo_height);
trim_width = right_trunk_16(trim_width);
trim_height = right_trunk_8(trim_height);
st_param.st_trim_rect.w_width = trim_width;
st_param.st_trim_rect.w_height = trim_height;
st_param.st_trim_rect.w_start_x = right_trunk_16((w_photo_width - trim_width) / 2);
st_param.st_trim_rect.w_start_y = right_trunk_8((w_photo_height - trim_height) / 2);
SCI_TRACE_LOW("DCAdap_ReviewPhotoCallBack:trim_width=%d,trim_height=%d,start_x=%d,start_y=%d",
trim_width,trim_height,st_param.st_trim_rect.w_start_x,st_param.st_trim_rect.w_start_y);
// st_disp_rect 在x方向上必须是偶数,即2 pixel对齐;
// st_disp_rect不能大于st_trim_rect
// st_disp_rect不超过LCD边界
// st_disp_rect跟原图的x,y方向的scale down系数应该都一样
// st_disp_rect位于LCD的中部
if (s_photo_review_info.i_lcd == MAIN_LCD_ID)
{
lcd_width = left_trunk_2(MMIDC_MAINSCREEN_WIDTH);
lcd_height = left_trunk_2(MMIDC_MAINSCREEN_HEIGHT);
}
else
{
lcd_width = left_trunk_2(MMI_SUBSCREEN_WIDTH);
lcd_height = left_trunk_2(MMI_SUBSCREEN_HEIGHT);
}
if ((trim_width < lcd_width) && (trim_height < lcd_height))
{
disp_width = trim_width;
disp_height = trim_height;
}
else
{
//st_disp_rect跟原图的x,y方向的scale down系数应该都一样
disp_width = MIN(lcd_width, trim_width * lcd_height/ trim_height);
disp_width = right_trunk_2(disp_width);
disp_height = MIN(trim_height * lcd_width / trim_width, lcd_height);
disp_height = right_trunk_2(disp_height);
}
//middle
st_param.st_disp_rect.w_width = disp_width;
st_param.st_disp_rect.w_height = disp_height;
st_param.st_disp_rect.w_start_x = left_trunk_2((lcd_width - disp_width) / 2);
st_param.st_disp_rect.w_start_y = left_trunk_2((lcd_height - disp_height) / 2);
SCI_TRACE_LOW("DCAdap_ReviewPhotoCallBack:disp_width=%d,disp_height=%d,start_x=%d,start_y=%d",
disp_width,disp_height,st_param.st_disp_rect.w_start_x,st_param.st_disp_rect.w_start_y);
}
else if (s_photo_review_info.e_review_type == REVIEW_PART_PHOTO)
{
// review时st_trim_rect的起点,建议设在16的整数倍上,st_trim_rect的长宽也建议设成16的整数倍
// st_trim_rect不能位于回放图像的原始尺寸之外
// st_trim_rect位于原图的中部
trim_width = right_trunk_16(w_photo_width);
trim_height = right_trunk_16(w_photo_height);
if (s_photo_review_info.i_lcd == MAIN_LCD_ID)
{
lcd_width = left_trunk_2(MMIDC_MAINSCREEN_WIDTH);
lcd_height = left_trunk_2(MMIDC_MAINSCREEN_HEIGHT);
}
else
{
lcd_width = left_trunk_2(MMI_SUBSCREEN_WIDTH);
lcd_height = left_trunk_2(MMI_SUBSCREEN_HEIGHT);
}
st_param.st_trim_rect.w_start_x = right_trunk_16(s_photo_review_info.x_start);
st_param.st_trim_rect.w_start_y = right_trunk_16(s_photo_review_info.y_start);
st_param.st_trim_rect.w_width = MIN(lcd_width, trim_width - st_param.st_trim_rect.w_start_x);
st_param.st_trim_rect.w_width = right_trunk_16(st_param.st_trim_rect.w_width);
st_param.st_trim_rect.w_height = MIN(lcd_height, trim_height - st_param.st_trim_rect.w_start_y);
st_param.st_trim_rect.w_height = right_trunk_16(st_param.st_trim_rect.w_height);
// st_disp_rect 在x方向上必须是偶数,即2 pixel对齐;
// st_disp_rect不能大于st_trim_rect
// st_disp_rect不超过LCD边界
// st_disp_rect跟原图的x,y方向的scale down系数应该都一样
// st_disp_rect位于LCD的中部
if ((trim_width < lcd_width) && (trim_height < lcd_height))
{
disp_width = trim_width;
disp_height = trim_height;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -