📄 mmidc_preview.c
字号:
text_len,
&font_lib);
if (font_data_ptr == PNULL)
{
return FALSE;
}
//get font widht
if (is_ucs2)
{
#ifndef WIN32 //little endian
if (text_ptr[0] != 0)
#else //big endian
if (text_ptr[1] != 0)
#endif
{
is_char_ucs2 = TRUE;
}
else
{
is_char_ucs2 = FALSE;
}
}
else
{
is_char_ucs2 = FALSE;
}
fontwidth = GUI_GetFontWidth(font, is_char_ucs2);
fontheight = GUI_GetFontHeight(font, is_char_ucs2);
/* Get the array */
for (j = 0; j < fontheight; j++)
{
cr_index = (j + 1) * OSD_MENU_CHAR_CN_WIDTH + 1; // + 1, means move the font right and down for one pixel
for (k = 0; k < ((fontwidth +7) / 8) * 8; k++)
{
uint16 font_code = 0;
uint16 code_big5 = 0;
//繁体字显示时字符存储不同,须特殊处理
if ((g_ksp_Lang == 2) && (font_lib == FONT_CODELIB_BIG5))
{
font_code = *((uint16*)(font_data_ptr) + j);
if (k <= (fontwidth / 2))
{
font_code = font_code >> 8;
code_big5 = font_code & (0x0001 << k);
}
else if(k < fontwidth)
{
code_big5 = font_code & (0x0001 << (k - 8));
}
if (code_big5)
{
p_cr_table[cr_index] = CR_BLACK_INDEX;
}
cr_index++;
}
else
{
if (k % 8 == 0)
{
code = *font_data_ptr++;
mask = 0x80;
}
if ( code & mask )
{
p_cr_table[cr_index] = CR_BLACK_INDEX;//0xC1;//0xC1 means overwrite, refer to declearation of DC_SetOsdImage
}
cr_index++;
mask >>= 1;
}
}
/*Next line now.*/
}
//post handle
OSD_DrawFontCircle(p_cr_table, OSD_IMG_WIDTH, OSD_IMG_HEIGHT, CR_BLACK_INDEX, CR_WHITE_INDEX);
if (is_ucs2)
{
i += 2;
text_ptr += 2;
p_cr_table = cr_table_ptr + (i / 2) * DCHW_MAX_OSD_IMG_PIXEL;
}
else
{
i++;
text_ptr++;
p_cr_table = cr_table_ptr + (i / 2 * DCHW_MAX_OSD_IMG_PIXEL) + ((i % 2) * (OSD_IMG_WIDTH / 2));
}
}
return TRUE;
}
/*****************************************************************************/
// Description : display osd menu string in osd slot
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
LOCAL int Adap_DrawCharacterOSDMenu(int i_zone, int text_num, MMI_TEXT_ID_T text_label, RECT_T *valid_rect_ptr)
{
DC_OSD_MODE osd_mode = {0};
uint8* p_cr_table = PNULL;
int i = 0;
MMI_STRING_T osd_str = {0};
int i_osd_char_num = 0; //osd character number
int osd_interval = 0;
//calc osd postion
osd_interval = (valid_rect_ptr->w_width - 2 * OSD_MENU_CHAR_LEFT_MARGIN - OSD_IMG_WIDTH * 6) / 2;
//enable 6 osd slot to display the TEXT
osd_mode.b_enable = TRUE;
osd_mode.e_size_mode = DC_OSD_IMSIZE_16x16;
osd_mode.i_expand_factor = MMIDC_IMG_EXPAND_1;
osd_mode.st_zone.w_start_x = OSD_MENU_CHAR_LEFT_MARGIN + i_zone * OSD_IMG_WIDTH + i_zone * osd_interval / 2;
osd_mode.st_zone.w_start_y = valid_rect_ptr->w_height - OSD_MENU_CHAR_CN_WIDTH - 1;
osd_mode.st_zone.w_width = OSD_MENU_CHAR_CN_WIDTH;
osd_mode.st_zone.w_height = DCHW_MAX_OSD_IMG_PIXEL / OSD_MENU_CHAR_CN_WIDTH;
//get osd string image
MMI_GetLabelTextByLang(text_label, &osd_str);
//get character number in this osd string
if (osd_str.is_ucs2)
{
i_osd_char_num = MIN((osd_str.length / 2), text_num);
osd_str.length = i_osd_char_num * 2; //osd_num * 2 : ucs2 string use 2 byte
}
else
{
i_osd_char_num = MIN(osd_str.length, text_num);
//osd_str.length = i_osd_char_num * 2; //osd_num * 2 : 1 osd slot can cantain 2 ascii string
}
for (i = 0; i < i_osd_char_num; i++)
{
DC_SetOsdZoneMode(i_zone + i, &osd_mode);
osd_mode.st_zone.w_start_x += OSD_MENU_CHAR_CN_WIDTH;
}
SCI_ASSERT(i_zone + i <= DCHW_OSD_SLOT_MAX_NUM);
p_cr_table = SCI_ALLOC(i_osd_char_num * 2 * DCHW_MAX_OSD_IMG_PIXEL); //char_num * 2 : alloc enough memory to cantain the string osd
SCI_MEMSET(p_cr_table, 0, i_osd_char_num * 2 * DCHW_MAX_OSD_IMG_PIXEL);
OSD_GetCharacterOSD(osd_str.str_ptr, osd_str.length, osd_str.is_ucs2, p_cr_table);
//set osd menu string
for (i = 0; i < i_osd_char_num; i++)
{
DC_SetOsdImage(i_zone + i, p_cr_table + i * DCHW_MAX_OSD_IMG_PIXEL);
}
SCI_FREE(p_cr_table);
return i_osd_char_num;
}
/*****************************************************************************/
// Description : display osd menu string in osd slot
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
/*
PUBLIC int DrawCapWaitingString(uint8 i_lcd)
{
DC_OSD_MODE osd_mode = {0};
uint8* p_cr_table = PNULL;
int i = 0;
MMI_STRING_T prompt_str = {0};
int i_osd_char_num = 0; //osd character number
int osd_interval = 0;
int text_num = 3;
MMI_TEXT_ID_T text_label = TXTSYS_WAITING;
int j = 0;
int k = 0;
uint8 *cr_ptr = PNULL;
GUI_POINT_T st_start_point = {0};
uint16 str_width = 0;
uint16 str_height = 0;
GUI_FONT_T font = MMI_DEFAULT_TEXT_FONT;
//get osd string image
MMI_GetLabelTextByLang(text_label, &prompt_str);
//get character number in this osd string
if (prompt_str.is_ucs2)
{
i_osd_char_num = MIN((prompt_str.length / 2), text_num);
prompt_str.length = i_osd_char_num * 2; //osd_num * 2 : ucs2 string use 2 byte
}
else
{
i_osd_char_num = MIN(prompt_str.length, text_num);
prompt_str.length = i_osd_char_num * 2; //osd_num * 2 : 1 osd slot can cantain 2 ascii string
}
p_cr_table = SCI_ALLOC(i_osd_char_num * 2 * DCHW_MAX_OSD_IMG_PIXEL); //char_num * 2 : alloc enough memory to cantain the string osd
SCI_MEMSET(p_cr_table, 0, i_osd_char_num * 2 * DCHW_MAX_OSD_IMG_PIXEL);
OSD_GetCharacterOSD(prompt_str.str_ptr, prompt_str.length, prompt_str.is_ucs2, p_cr_table);
//set osd menu string
cr_ptr = p_cr_table;
str_width = GUI_CalculateStringPiexlNum(
prompt_str.str_ptr,
prompt_str.length,
prompt_str.is_ucs2,
font,
0
);
str_height = GUI_GetFontHeight(font, prompt_str.is_ucs2);
if (i_lcd == MAIN_LCD_ID)
{
st_start_point.x = (MMI_MAINSCREEN_WIDTH - str_width) / 2;
st_start_point.y = MMI_MAINSCREEN_HEIGHT / 2;
}
else
{
st_start_point.x = MMI_SUBSCREEN_WIDTH / 2;
st_start_point.y = MMI_SUBSCREEN_HEIGHT / 2;
}
for (i = 0; i < i_osd_char_num; i++)
{
for (j = 0; j < OSD_IMG_HEIGHT; j++)
{
for (k = 0; k < OSD_IMG_WIDTH; k++)
{
//CR_BLACK_INDEX, CR_WHITE_INDEX, 0
if (*cr_ptr == 0)
{
//skip this pixel
}
else if (*cr_ptr == CR_BLACK_INDEX)
{
LCD_InvalidateRect_image(
st_start_point.x + k * OSD_IMG_HEIGHT,
st_start_point.y + j,
st_start_point.x + k * OSD_IMG_HEIGHT + 1,
st_start_point.x + j + 1,
cr_ptr
)
}
cr_ptr++;
}
}
}
SCI_FREE(p_cr_table);
return i_osd_char_num;
}
*/
/*****************************************************************************/
// Description : get dc setting info
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC MMIDC_SETTING_INFO_T* MMIDC_GetSettingInfo(void)
{
return &s_mmidc_setting_info;
}
/*****************************************************************************/
// Description : get dc preview or capture window mode
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC PREV_WIN_MODE_E DCSetting_GetPreviewWinMode(void)
{
return s_mmidc_setting_info.e_prevwin_mode;
}
/*****************************************************************************/
// Description : set dc preview or capture window mode
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC void DCSetting_SetPreviewWinMode(PREV_WIN_MODE_E e_win_mode)
{
DC_ASSERT_LOW(e_win_mode < PREVIEW_WIN_MODE_MAX);
if (e_win_mode == PREVIEW_WIN_SUBLCD_NO_OSD)
{
s_mmidc_setting_info.e_lcd = SUB_LCD_ID;
}
else
{
s_mmidc_setting_info.e_lcd = MAIN_LCD_ID;
}
s_mmidc_setting_info.e_prevwin_mode = e_win_mode;
}
/*****************************************************************************/
// Description : get preview image osd menu info
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC void DCSetting_GetPreviewImgOSDMenuIndex(int *cur_index_ptr, int *left_index_ptr)
{
DC_ASSERT_LOW(cur_index_ptr != PNULL && left_index_ptr != PNULL);
*cur_index_ptr = s_mmidc_setting_info.st_preview_osd_info.cur_img_osd_menu_index;
*left_index_ptr = s_mmidc_setting_info.st_preview_osd_info.left_img_osd_menu_index;
}
/*****************************************************************************/
// Description : get preview image osd menu info
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC void DCSetting_SetPreviewImgOSDMenuIndex(int cur_index, int left_index)
{
s_mmidc_setting_info.st_preview_osd_info.cur_img_osd_menu_index = cur_index;
s_mmidc_setting_info.st_preview_osd_info.left_img_osd_menu_index = left_index;
}
/*****************************************************************************/
// Description : get preview photo effect setting
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC MMIDC_PHOTO_EFFECT_E DCSetting_GetPhotoEffect(void)
{
return s_mmidc_setting_info.e_effect;
}
/*****************************************************************************/
// Description : set preview photo effect setting
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC void DCSetting_SetPhotoEffect(MMIDC_PHOTO_EFFECT_E e_effect)
{
DC_ASSERT_LOW(e_effect < MMIDC_EFFECT_MAX);
s_mmidc_setting_info.e_effect = e_effect;
}
/*****************************************************************************/
// Description : set preview photo effect - sensor sequence
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC BOOLEAN DCAdap_SetPhotoEffect(MMIDC_PHOTO_EFFECT_E e_effect)
{
if (0 == DC_SetImageEffect(e_effect + SENSOR_EFFECT_SEPIA_BEGIN + 1))
{
return TRUE;
}
else
{
return FALSE;
}
}
/*****************************************************************************/
// Description : get preview mode effect settin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -