📄 myapp.c
字号:
static void mmi_phoart_frame_edit_draw_frame2(void);
static void mmi_phoart_frame_edit_change_backward2(void);
static void mmi_phoart_frame_edit_change_forward2(void);
static void mmi_phoart_frame_edit_draw_osd2(BOOL is_draw_frame);
/* add text */
static void mmi_phoart_entry_text_str_editor_screen2(void);
static void mmi_phoart_hilight_add_text2(void);
static void mmi_phoart_entry_text_str_editor_option_screen2(void);
static void mmi_phoart_text_hilight_editor_done2(void);
static void mmi_phoart_text_hilight_editor_cancel2(void);
static void mmi_phoart_text_hilight_editor_input2(void);
static void mmi_phoart_text_cancel_edit2(void);
static void mmi_phoart_text_draw_style_text2(S32 offset_x, S32 offset_y, S32 width, S32 height, PS8 str_ptr);
static void mmi_phoart_text_select_draw_text2(void);
static void mmi_phoart_text_inline_select_highlight_hdlr2(S32 index);
static void mmi_phoart_text_select_highlight_hdlr2(S32 index);
static void mmi_phoart_text_select_text_color_hilight_callback2(U16 index);
static void mmi_phoart_text_select_border_color_hilight_callback2(U16 index);
static void mmi_phoart_text_select_shadow_color_hilight_callback2(U16 index);
static void mmi_phoart_text_select_draw_info_callback2(S32 index, S32 x1, S32 y1, S32 x2, S32 y2);
static void mmi_phoart_text_select_done_hdlr2(void);
static void mmi_phoart_entry_text_select_screen2(void);
static void mmi_phoart_exit_text_select_screen2(void);
static void mmi_phoart_entry_text_edit_screen2(void);
static void mmi_phoart_exit_text_edit_screen2(void);
static U8 mmi_phoart_text_del_screen_id_hdlr2(void *ptr);
static void mmi_phoart_text_edit_draw_text2(U16 border_style);
static void mmi_phoart_text_edit_move_down_press2(void);
static void mmi_phoart_text_edit_move_up_press2(void);
static void mmi_phoart_text_edit_move_left_press2(void);
static void mmi_phoart_text_edit_move_right_press2(void);
static void mmi_phoart_text_edit_move_down_release2(void);
static void mmi_phoart_text_edit_move_up_release2(void);
static void mmi_phoart_text_edit_move_left_release2(void);
static void mmi_phoart_text_edit_move_right_release2(void);
static void mmi_phoart_text_edit_move_text_cyclic2(void);
static void mmi_phoart_text_edit_stamp2(void);
static void mmi_phoart_text_edit_stamp_release2(void);
static void mmi_phoart_text_edit_stamp_when_done2(void);
static void mmi_phoart_text_edit_draw_osd2(void);
/* clip screen */
static void my_phoart_entry_clip_screen(void);
static void mmi_phoart_entry_clip_screen2(void);
static void mmi_phoart_exit_clip_screen2(void);
static void mmi_phoart_clip_draw_osd2(void);
static void mmi_phoart_clip_move_clip_rect_cyclic2(void);
static void mmi_phoart_clip_up_arrow_press2(void);
static void mmi_phoart_clip_down_arrow_press2(void);
static void mmi_phoart_clip_left_arrow_press2(void);
static void mmi_phoart_clip_right_arrow_press2(void);
static void mmi_phoart_clip_up_arrow_release2(void);
static void mmi_phoart_clip_down_arrow_release2(void);
static void mmi_phoart_clip_left_arrow_release2(void);
static void mmi_phoart_clip_right_arrow_release2(void);
static void mmi_phoart_clip_scale_up_press2(void);
static void mmi_phoart_clip_scale_up_release2(void);
static void mmi_phoart_clip_scale_down_press2(void);
static void mmi_phoart_clip_scale_down_release2(void);
static void mmi_phoart_clip_clip_image2(void);
#ifdef __MMI_TOUCH_SCREEN__
MMI_BOOL mmi_phoart_clip_pen_down_hdlr2(mmi_pen_point_struct pos);
MMI_BOOL mmi_phoart_clip_pen_up_hdlr2(mmi_pen_point_struct pos);
MMI_BOOL mmi_phoart_clip_pen_move_hdlr2(mmi_pen_point_struct pos);
MMI_BOOL mmi_phoart_clip_pen_repeat_hdlr2(mmi_pen_point_struct pos);
MMI_BOOL mmi_phoart_clip_pen_long_tap_hdlr2(mmi_pen_point_struct pos);
MMI_BOOL mmi_phoart_clip_pen_abort_hdlr2(mmi_pen_point_struct pos);
#endif /* __MMI_TOUCH_SCREEN__ */
/* save screen */
static void mmi_phoart_hilight_save_as2(void);
static void mmi_phoart_entry_editor_filename_screen2(void);
static void mmi_phoart_entry_editor_filename_internal2(void);
static void mmi_phoart_return_to_editor_screen2(void);
static void mmi_phoart_back_from_editor_screen2(void);
static void mmi_phoart_entry_editor_option_screen2(void);
static void mmi_phoart_hilight_editor_done2(void);
static void mmi_phoart_hilight_editor_cancel2(void);
static void mmi_phoart_hilight_editor_input2(void);
static void mmi_phoart_cancel_save_file2(void);
static void mmi_phoart_save_file2(void);
static void mmi_phoart_draw_image_border2(void);
static void mmi_phoart_draw_softkey2(PS8 lsk_str, PS8 rsk_str, BOOL is_clear_bg);
static void mmi_phoart_draw_title2(PS8 title_str, PS8 sel_str, BOOL is_clear_bg);
static BOOL mmi_phoart_load_cache_image2(PU8 buf_ptr);
gdi_handle my_layer;
gdi_handle base_layer;
void Touch_Screen2(mmi_pen_point_struct point)
{
FS_HANDLE storeWholeFile = -1;
S32 actWtite;
gdi_handle image_layer_handle;
MDI_RESULT ret;
if(point.x > 165 && point.x < 204 && point.y > 30 && point.y < 55)
{
//存储退出
gdi_layer_multi_layer_enable();
gdi_layer_get_active(image_layer_handle);
storeWholeFile = FS_Open(L"C:\\TEST1.bmp",FS_CREATE_ALWAYS);
gdi_layer_push_clip();
gdi_layer_set_clip(0, 0, UI_device_width - 1, UI_device_height - 1);
gdi_image_cache_bmp_get(100, 160, 120, 180,&g_whole_image_ptr);
//gdi_image_cache_bmp_draw(20, 90, &g_store_image_ptr);
gdi_layer_pop_clip();
//gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
FS_Write(storeWholeFile, g_whole_image_ptr.buf_ptr, strlen(g_whole_image_ptr.buf_ptr), &actWtite);
FS_Close(storeWholeFile);
gdi_layer_multi_layer_disable();
/*
FS_Open(L"C:\\TEST4.jpg",FS_CREATE_ALWAYS);
g_store_image_ptr.buf_ptr = g_image_store;
gdi_layer_push_clip();
gdi_layer_set_clip(0, 0, UI_device_width-1, UI_device_height-1);
gdi_image_cache_bmp_get(60, 80, 80, 100,&g_store_image_ptr);
//gdi_image_cache_bmp_draw(UI_device_width-20, UI_device_height-20, &g_bmp_ptr);
gdi_layer_pop_clip();
//gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
/* create a layer and capture this layer as jepg file */
/*gdi_layer_create_using_outside_memory(
0,
60,
g_phoart_cntx.resized_image_width,
g_phoart_cntx.resized_image_height,
&image_layer_handle,
(PU8) g_phoart_cntx.origin_image_buf,
(S32) PHOEDT_FRAME_BUFFER_SIZE);*/
//gdi_layer_get_active(&image_layer_handle);
//ret = mdi_camera_encode_layer_to_jpeg(image_layer_handle, L"C:\\TEST4.jpg");
//gdi_layer_free(image_layer_handle);
//FS_Write(storeFile, g_image_store, strlen(g_image_store), &actWtite); //为什么存储不进去呢??
//FS_Close(storeFile);
GoBackHistory();
}else if(point.x > 110 && point.x < 165 && point.y > 30 && point.y < 55)
{
//enter selection screen
//mmi_phoart_entry_option_screen2();
MySelectionList();
}else if(point.x > 55 && point.x < 110 && point.y > 30 && point.y < 55)
{
//enter clip
MyPhotoClip();
}else if(point.x > 0 && point.x < 55 && point.y > 30 && point.y < 55)
{
//open the file
mmi_phoart_entry_app_screen2();
}
}
void Convert_GBK_to_Unicode4(const char *pGBK, U16 *pUnicode, U16 len)
{
#ifndef MMI_ON_WIN32
mmi_chset_text_to_ucs2_str((kal_uint8*)pUnicode, len, (kal_uint8*)pGBK, GB2312_ENCODING_TYPE);
#else
MultiByteToWideChar(CP_ACP, 0, pGBK, len, (U16 *)pUnicode, len);
#endif
}
void My_Main(void)
{
S8 buf_filename[FMGR_PATH_BUFFER_SIZE];
S32 image_width;
S32 image_height;
PU8 buf_ptr;
U8 *gui_buffer;
GDI_RESULT result;
S32 offset_x;
S32 offset_y;
U16 img_type;
FS_HANDLE storeFile = -1;
FS_HANDLE hFile = -1;
U16 actWtite;
U16 actRead;
S32 file_len = 0;
FS_HANDLE storeWholeFile = -1;
S32 actWtite2;
S8 input_chan[160]={0};
S8 text_open[10]="打开";
S8 open_chan[20];
S8 text_clip[10]="剪切";
S8 clip_chan[20];
S8 text_select[10]="选择";
S8 select_chan[20];
S8 text_back[10]="返回";
S8 back_chan[20];
S8 text_title[20]="照片编辑器";
S8 title_chan[40];
CONST_HARDWARE color title_color_yellow = {240, 240, 0 , 120};
CONST_HARDWARE color menu_color_canyan = {0, 240, 240 , 120};
EntryNewScreen(2354, NULL, My_Main, NULL);
gdi_layer_reset_clip();
gdi_layer_reset_text_clip();
entry_full_screen();
clear_screen();
/*****************************************************************************
* Tile
*****************************************************************************/
gui_draw_rectangle(0, 0, UI_device_width - 1, 30, title_color_yellow);
gui_fill_rectangle(0, 0, UI_device_width - 1, 30, title_color_yellow);
if(g_file_path[0] == '\0')
{
Convert_GBK_to_Unicode4(text_title,(U16 *)title_chan,40);
gui_move_text_cursor(60,0);
gui_set_text_color(UI_COLOR_RED);
gui_print_text((U16 *)title_chan);
gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
}
else
{
//显示相片路径
gui_move_text_cursor(80,0);
gui_set_text_color(UI_COLOR_RED);
gui_print_text((U16 *)(&g_file_path[6]));
gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
}
/*****************************************************************************
* Menu
*****************************************************************************/
gui_draw_rectangle(0, 30, UI_device_width - 1, 60, menu_color_canyan);
gui_fill_rectangle(0, 30, UI_device_width - 1, 60, menu_color_canyan);
Convert_GBK_to_Unicode4(text_open,(U16 *)open_chan,20);
gui_move_text_cursor(0,30);
gui_set_text_color(UI_COLOR_RED);
gui_print_text((U16 *)open_chan);
gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
Convert_GBK_to_Unicode4(text_clip,(U16 *)clip_chan,20);
gui_move_text_cursor(55,30);
gui_set_text_color(UI_COLOR_RED);
gui_print_text((U16 *)clip_chan);
gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
Convert_GBK_to_Unicode4(text_select,(U16 *)select_chan,20);
gui_move_text_cursor(110,30);
gui_set_text_color(UI_COLOR_RED);
gui_print_text((U16 *)select_chan);
gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
Convert_GBK_to_Unicode4(text_back,(U16 *)back_chan,20);
gui_move_text_cursor(165,30);
gui_set_text_color(UI_COLOR_RED);
gui_print_text((U16 *)back_chan);
gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
/*****************************************************************************
* Layers
*****************************************************************************/
gdi_layer_multi_layer_enable();
gdi_layer_get_active(&g_phoart_cntx.base_layer_handle);
if(g_phoart_cntx.is_clip == FALSE)
{
mmi_fmgr_util_load_filepath(buf_filename, FMGR_PATH_ID_PHOTO_EDITOR);
gdi_image_draw_file(0,60,buf_filename);
}
else
{
gdi_layer_push_clip();
gdi_layer_set_clip(0, 0, UI_device_width-1, UI_device_height-1);
//gdi_layer_set_clip(g_x1, g_y1, g_x2, g_y2);
//gdi_image_cache_bmp_get(g_x1, g_y1, g_x2, g_y2, &g_bmp_ptr); //为什么中断??
//gdi_image_cache_bmp_get(60, 160, 100, 180, &g_bmp_ptr); // 存储空间太小了?
//把原来图片用颜色覆盖远远不够,一定要把他们的层合并刷到屏幕上
gui_fill_rectangle(0, 60, UI_device_width-1, UI_device_height-1, UI_COLOR_WHITE); //覆盖原来图片
//image_clip_move_x = UI_device_width>>1 - (g_x2 - g_x1)>>1; //点击两点的坐标有大小
//image_clip_move_y = UI_device_height>>1 - (g_y2 - g_y1)>>1;
//image_clip_offset_x = g_x1 + image
//gdi_image_cache_bmp_draw(g_x1+image_clip_move_x, g_y1+image_clip_move_y, &g_bmp_ptr); //居中显示剪切后的图片
gdi_image_cache_bmp_draw(60, 80, &g_bmp_ptr); //居中显示剪切后的图片
//gdi_anim_draw_resized(0,0,60,60,g_bmp_ptr.buf_ptr, g_phoart_cntx.base_layer_handle);
//gdi_image_draw_resized_file(0, 0, 60, 60, L"c:\\mtk.bmp"); //只能针对打开来看的见的图片文件这样用
//gdi_image_draw_resized_ext(0, 0, 60, 60, g_bmp_ptr.buf_ptr, 0, strlen(g_bmp_ptr.buf_ptr));
//gdi_image_draw_resized(UI_device_width - 60, UI_device_height - 60, UI_device_width-1, UI_device_height-1, (U8 *)g_bmp_ptr.buf_ptr);
gdi_layer_pop_clip();
gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
//重新画剪切出来的小块区域
//gdi_anim_draw_file_resized(OFFSET_X,OFFSET_Y,RESIZED_W,RESIZED_H,IMAGE_NAME,HANDLE_PTR)
//gdi_anim_draw_mem_resized(OFFSET_X,OFFSET_Y,RESIZED_W,RESIZED_H,IMAGE_PTR,IMAGE_TYPE,IMAGE_SIZE,HANDLE_PTR)
//gdi_anim_draw_mem_resized(UI_device_width-60, UI_device_height-60, 40, 40, g_store_image_ptr.buf_ptr, GDI_IMAGE_TYPE_BMP ,IMAGE_SIZE,HANDLE_PTR)
//模拟器不支持重画吗?
//gdi_anim_draw_resized(60,100,160,200,g_store_image_ptr.buf_ptr, g_phoart_cntx.base_layer_handle); //中断???
//gui_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
storeFile = FS_Open(L"C:\\test7.bmp",FS_CREATE_ALWAYS);
//FS_Write(storeFile, g_image_store, strlen(g_image_store), &actWtite); //为什么存储不进去呢??
FS_Write(storeFile, g_bmp_ptr.buf_ptr, strlen(g_bmp_ptr.buf_ptr), &actWtite);
//storeFile = FS_Open(L"C:\\test7.txt",FS_READ_WRITE);
//FS_Write(storeFile, "test", strlen("test"), (UINT *)&actWtite);
FS_Close(storeFile);
hFile = FS_Open(L"C:\\test7.bmp",FS_READ_ONLY);
FS_GetFileSize(hFile, (UINT*)&file_len);
FS_Read(hFile, g_image_store, file_len, (UINT*)&actRead);
FS_Close(hFile);
g_store_image_ptr.buf_ptr = g_image_store;
g_store_image_ptr.width = 2*g_bmp_ptr.width;
g_store_image_ptr.height = 2*g_bmp_ptr.height;
gdi_image_cache_bmp_draw(120, 150, &g_store_image_ptr); //这对函数也能对JPG的图片处理
//gdi_image_bmp_draw(0, 0, g_store_image_ptr.buf_ptr, U32 size); //以上两个函数的差别是
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -