⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmidc_preview.c

📁 手机Camera部分上层软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:
//	Note:	这个函数用于Stop了Preview以后,再次Start
/*****************************************************************************/
PUBLIC BOOLEAN DCAdap_StartPreview(void)
{
	SCI_TRACE_LOW("DCAdap_StartPreview_★★★★★★★");
	if ( 0 == DC_StartPreview())
	//if ( 0 == OCR_StartPreview())
	{
		return TRUE;
	}
	
	else
	{
		return FALSE;
	}

}

/*****************************************************************************/
// 	Description : use DC Driver interface to stop preview
//	Global resource dependence : 
//  Author: bruce.chi
//	Note:
/*****************************************************************************/
PUBLIC BOOLEAN DCAdap_StopPreview(void)
{
	BOOLEAN ret=FALSE;
#ifndef _MMI_OCR
	ret=DC_StopPreview();
#else
	if (MMIOCR_Is_From_OCR())
	{
		ret=OCR_StopPreview();
	}
	else
		ret=DC_StopPreview();	
	
#endif
	if (0==ret)
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

/*****************************************************************************/
// 	Description : use DC Driver interface to close dc
//	Global resource dependence : 
//  Author: bruce.chi
//	Note:
/*****************************************************************************/
PUBLIC BOOLEAN DCAdap_DCClose(void)
{
	SCI_TRACE_LOW("mmidc_preview.c DCAdap_DCClose");
    if (s_dc_context_ptr != PNULL)
    {
        BL_Free(BLOCK_MEM_POOL_1);
        s_dc_context_ptr = PNULL;
    }
#ifdef MMI_NOR_VERSION
	FreeYUVExtBuffer();
#endif
    if (s_is_dc_open)
    {
        if (0 == DC_Close())
        {
            s_is_dc_open = FALSE;
            return TRUE;
        }
        else
        {
            return FALSE;
        }
    }
    else
    {
        return TRUE;
    }
}

/*****************************************************************************/
// 	Description : increase contrast
//	Global resource dependence : 
//  Author: bruce.chi
//	Note:	do not need to stop preview
/*****************************************************************************/
PUBLIC BOOLEAN DC_IncreaseContrast(void)
{
	if (s_mmidc_setting_info.i_contrast < MMIDC_CONTRAST_MAX - 1)
	{
		s_mmidc_setting_info.i_contrast ++;
//		DC_SetImageEffect(s_mmidc_setting_info.i_contrast + SENSOR_EFFECT_CONTRAST_BEGIN + 1);
		if (!DCAdap_StopPreview())
		{
			SCI_TRACE_LOW("mmidc_preview.c:DC_IncreaseContrast, DCAdap_StopPreview error");
			return FALSE;
		}
		if (!DCAdap_SetAllPreviewParam())
		{
			SCI_TRACE_LOW("mmidc_preview.c:DC_IncreaseContrast, DCAdap_SetAllPreviewParam error");
			return FALSE;
		}
		if (!DCAdap_StartPreview())
		{
			SCI_TRACE_LOW("mmidc_preview.c:DC_IncreaseContrast, DCAdap_StartPreview error");
			return FALSE;
		}
		return TRUE;
	}
	else
	{
		return FALSE;
	}

}

/*****************************************************************************/
// 	Description : decrease contrast
//	Global resource dependence : 
//  Author: bruce.chi
//	Note:	do not need to stop preview
/*****************************************************************************/
PUBLIC BOOLEAN DC_DecreaseContrast(void)
{
	if (s_mmidc_setting_info.i_contrast > 0)
	{
		s_mmidc_setting_info.i_contrast --;
//		DC_SetImageEffect(s_mmidc_setting_info.i_contrast + SENSOR_EFFECT_CONTRAST_BEGIN + 1);
		if (!DCAdap_StopPreview())
		{
			SCI_TRACE_LOW("mmidc_preview.c:DC_DecreaseContrast, DCAdap_StopPreview error");
			return FALSE;
		}
		if (!DCAdap_SetAllPreviewParam())
		{
			SCI_TRACE_LOW("mmidc_preview.c:DC_DecreaseContrast, DCAdap_SetAllPreviewParam error");
			return FALSE;
		}
		if (!DCAdap_StartPreview())
		{
			SCI_TRACE_LOW("mmidc_preview.c:DC_DecreaseContrast, DCAdap_StartPreview error");
			return FALSE;
		}
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

/*****************************************************************************/
// 	Description : increase Brightness
//	Global resource dependence : 
//  Author: bruce.chi
//	Note:	do not need to stop preview
/*****************************************************************************/
PUBLIC BOOLEAN DC_IncreaseBrightness(void)
{
	if (s_mmidc_setting_info.i_brightness < MMIDC_BRIGHTNESS_MAX - 1)
	{
		s_mmidc_setting_info.i_brightness ++;
		DC_SetImageEffect(s_mmidc_setting_info.i_brightness + SENSOR_EFFECT_BRIGHTNESS_BEGIN + 1);
		return TRUE;
	}
	else
	{
		return FALSE;
	}

}

/*****************************************************************************/
// 	Description : decrease Brightness
//	Global resource dependence : 
//  Author: bruce.chi
//	Note:	do not need to stop preview
/*****************************************************************************/
PUBLIC BOOLEAN DC_DecreaseBrightness(void)
{
	if (s_mmidc_setting_info.i_brightness > 0)
	{
		s_mmidc_setting_info.i_brightness --;
		DC_SetImageEffect(s_mmidc_setting_info.i_brightness + SENSOR_EFFECT_BRIGHTNESS_BEGIN + 1);
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

/*****************************************************************************/
// 	Description : use DC Driver interface to get sensor mode sequence
//	Global resource dependence : 
//  Author: bruce.chi
//	Note:
/*****************************************************************************/
DC_SENSOR_MODE_E DCAdap_GetSensorModeSequence(const MMIDC_SETTING_INFO_T *setting_ptr, MMIDC_TRIMRECT_TYPE_E e_trimrect_type)
{
	DC_SENSOR_MODE_E	e_sensor_mode = 0;
	MMIDC_PHOTO_SIZE_E	e_photo_size = 0;
	MMIVC_VIDEO_SIZE_E	e_video_size = 0;

	DC_ASSERT_LOW(setting_ptr != PNULL);

	if (setting_ptr->is_from_dc)
	{
		e_photo_size = setting_ptr->e_photo_size;
		SCI_ASSERT(e_photo_size < MMIDC_PHOTO_SIZE_MAX);

		switch(e_trimrect_type)
		{
#ifndef MMI_ENABLE_AUTO_FOCUS
		case MMIDC_PREVIEW_NO_AF:			//没有AF情况下的preview
			e_sensor_mode = s_dc_sensor_mode_and_size[e_photo_size].e_preview_nomal_sensor_mode;
			break;
#endif
		case MMIDC_CAPTURE_NO_AF:			//capture
			e_sensor_mode = s_dc_sensor_mode_and_size[e_photo_size].e_capture_sensor_mode;
			break;
			
		case MMIDV_PREVIEW_NO_AF:
			e_sensor_mode = s_dc_sensor_mode_and_size[e_photo_size].e_preview_nomal_sensor_mode;
			break;

#ifdef MMI_ENABLE_AUTO_FOCUS
		case MMIDC_PREVIEW_NO_AF:			//没有AF情况下的preview
#endif
		case MMIDC_PREVIEW_AF_CONTINUOUS:	//连续AF的preview
		case MMIDC_PREVIEW_AF_SINGLE:		//单次AF的preview
			e_sensor_mode = s_dc_sensor_mode_and_size[e_photo_size].e_preview_af_sensor_mode;
			break;

		default:
			DC_ASSERT_LOW(0);
			break;
		}
	}
	else
	{
		e_video_size = setting_ptr->e_video_size;
		SCI_ASSERT(e_video_size < MMIVC_VIDEO_SIZE_MAX);

		e_sensor_mode = s_dv_sensor_mode_and_size[e_video_size].e_preview_nomal_sensor_mode;
	}

	if (setting_ptr->e_mode == MMIDC_MODE_OUTDOOR)
	{
		//calculated upper, do nothing now
	}
	else
	{
		e_sensor_mode++;
	}

	return e_sensor_mode;
}


/*****************************************************************************/
// 	Description : draw circle in every font
//	Global resource dependence : 
//  Author: bruce.chi
//	Note:
/*****************************************************************************/
LOCAL void OSD_DrawFontCircle(uint8 *p_cr_table, uint16 font_width, uint16 font_height, uint32 cr_black, uint32 cr_white)
{
	int x = 0;
	int y = 0;
	
	int cur_index = 0;

	int left_index = 0;
	int right_index = 0;
	int up_index = 0;
	int down_index = 0;

	for (y = 0; y < font_height; y++)
	{
		for (x = 0; x < font_width; x++)
		{
			//if current pixel color is COLOR_BLACK
			cur_index = y * font_height + x;
			if (p_cr_table[cur_index] == cr_black)
			{
				//if left pixel color is not COLOR_BLACK
				if (x >= 1)
				{
					left_index = cur_index - 1;
					if (p_cr_table[left_index] != cr_black)
					{
						p_cr_table[left_index] = cr_white;
					}
				}

				//if right pixel color is not COLOR_BLACK
				if (x < font_width)
				{
					right_index = cur_index + 1;
					if (p_cr_table[right_index] != cr_black)
					{
						p_cr_table[right_index] = cr_white;
					}

				}

				//if up pixel color is not COLOR_BLACK
				if (y >= 1)
				{	
					up_index = (y - 1)* font_height + x;
					if (p_cr_table[up_index] != cr_black)
					{
						p_cr_table[up_index] = cr_white;
					}
					
				}

				//if down pixel color is not COLOR_BLACK
				if (y < font_height)
				{
					down_index = (y + 1)* font_height + x;
					if (p_cr_table[down_index] != cr_black)	
					{
						p_cr_table[down_index] = cr_white;
					}
				}
			}
		}
	}

}

/*****************************************************************************/
// 	Description : Get OSD Image By String
//	Global resource dependence : 
//  Author: bruce.chi
//	Note:
/*****************************************************************************/
PUBLIC BOOLEAN OSD_GetCharacterOSD(	
							uint8*      text_ptr, 
							uint16		text_len,
                            BOOLEAN     is_ucs2,
							uint8		*cr_table_ptr
								)
{ 
	int			i = 0;
	int			j = 0;
	int			k = 0;

	GUI_FONT_T	font = SONG_FONT_14;//must be lower than 16
	uint8		*font_data_ptr = PNULL;
	uint8		fontwidth = 0;
	uint8		fontheight = 0;
	int			cr_index = 0;
	uint8		code = 0;
	uint8		mask = 0;

	uint8		*p_cr_table = cr_table_ptr;
	BOOLEAN		is_char_ucs2 = FALSE;
	GUIFONT_CODELIB_E font_lib = FONT_CODELIB_ASCII;  //for dc preview display big5 osd

	if (is_ucs2)
	{
		font = SONG_FONT_14;
	}
	else
	{
		font = SONG_FONT_12;
	}


	for (i = 0; i < text_len;)
	{
		
		//get font array
		font_data_ptr = GUI_GetFontArray(
					text_ptr,
					is_ucs2,
					font,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -