improve res tools

This commit is contained in:
lixianjing 2022-05-09 09:50:08 +08:00
parent d2e06c3cc5
commit 086776417a
4 changed files with 40 additions and 14 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2022/05/09
* 修改打包工具配合desiger打包lcd旋转资源的修改感谢智明提供补丁
2022/05/07
* 增加代码开启高效旋转的接口以及代码动态判断是否使用高效旋转(感谢智明提供补丁)。
* edit/mledit支持右键菜单。

View File

@ -44,7 +44,7 @@ ret_t tk_enable_fast_lcd_portrait(bool_t enable);
python .\scripts\update_res.py all x1 bgra+bgr565 0
~~~
2. 如果 data 格式的位图的旋转角度为 0 度的话(在 Desiger 工具中可以取消勾选快速旋转模式来达到设置旋转角度为 0 的效果),可以支持动态 lcd 旋转,但是效率会下降,而使用文件系统或者 res 格式的位图数据则不会降低效率。
2. 如果 data 格式的位图的旋转角度为 0 度的话,可以支持动态 lcd 旋转,但是效率会下降,而使用文件系统或者 res 格式的位图数据则不会降低效率。
3. 在没有定义 WITH_STB_IMAGE 宏(使用 data 格式的位图数据)的情况下,并且是位图旋转角度不为 0 度的话,是**不支持程序动态旋转**,需要在程序开始前就需要设置好旋转的角度,同时旋转角度应该和资源保持一致。
@ -52,7 +52,7 @@ ret_t tk_enable_fast_lcd_portrait(bool_t enable);
5. WITH_FAST_LCD_PORTRAIT 宏只是把功能增加到工程中,还需要用户自行调用 tk_enable_fast_lcd_portrait 来开启,如果没有调用 tk_enable_fast_lcd_portrait 函数的话,默认不启用,退化为以前就的 lcd 旋转方案。
> 如果是使用 Desiger 工具打包的话,第 1 点和第 3 点都会处理好的,用户只要注意动态 lcd 旋转的问题。
> 如果是使用 Desiger 工具的话,第 1 点和第 3 点都以及相关函数的调用都会处理好的,用户只要注意代码中动态 lcd 旋转的问题。
## 二、功能移植

View File

@ -19,6 +19,8 @@ def use_theme_config_from_project_json():
global IS_GENERATE_INC_BITMAP
global APP_THEME
global APP_ROOT
global LCD_ORIENTATION
global LCD_FAST_ROTATION_MODE
project_json = common.join_path(APP_ROOT, 'project.json')
if not os.path.exists(project_json):
@ -42,6 +44,18 @@ def use_theme_config_from_project_json():
if 'activedTheme' in assets:
APP_THEME = assets['activedTheme']
if LCD_FAST_ROTATION_MODE == None :
if 'lcdFastRotationMode' in assets:
LCD_FAST_ROTATION_MODE = assets['lcdFastRotationMode']
else :
LCD_FAST_ROTATION_MODE = False
if LCD_ORIENTATION == None :
if 'lcdOrientation' in assets:
LCD_ORIENTATION = assets['lcdOrientation']
else :
LCD_ORIENTATION = '0'
if 'themes' not in assets:
return
@ -61,12 +75,9 @@ def use_theme_config_from_project_json():
DPI = assets['screenDPR']
for theme_name, theme_setting in assets['themes'].items():
orientation = '0'
theme_name = common.to_file_system_coding(theme_name)
color_format = theme_setting['lcd']['colorFormat']
color_depth = theme_setting['lcd']['colorDepth']
if 'orientation' in theme_setting['lcd'] :
orientation = theme_setting['lcd']['orientation']
if color_format == 'MONO':
imagegen_options = 'mono'
@ -94,7 +105,7 @@ def use_theme_config_from_project_json():
filename = common.join_path(config_dir, font_name+'_'+font_size+'.txt')
common.write_file(filename, text)
theme = {'name': theme_name, 'imagegen_options': imagegen_options, 'lcd_orientation': orientation, 'packaged': theme_setting['packaged']}
theme = {'name': theme_name, 'imagegen_options': imagegen_options, 'packaged': theme_setting['packaged']}
if theme_name == 'default':
THEMES.insert(0, theme)
else:
@ -153,10 +164,13 @@ def run(awtk_root, is_excluded_file_handler = None):
global OUTPUT_ROOT
global IS_GENERATE_INC_RES
global IS_GENERATE_INC_BITMAP
global LCD_ORIENTATION
global LCD_FAST_ROTATION_MODE
GDPI=''
LCD_ORIENTATION=''
IMAGEGEN_OPTIONS=''
LCD_ORIENTATION=None
LCD_FAST_ROTATION_MODE=None
sys_args = common.get_args(sys.argv[1:])
if len(sys_args) > 0 :
common.set_action(sys_args[0])
@ -166,6 +180,7 @@ def run(awtk_root, is_excluded_file_handler = None):
IMAGEGEN_OPTIONS = sys_args[2]
if len(sys_args) > 3:
LCD_ORIENTATION = sys_args[3]
LCD_FAST_ROTATION_MODE = False
AWTK_ROOT = awtk_root
APP_ROOT = common.getcwd()
@ -208,6 +223,7 @@ def run(awtk_root, is_excluded_file_handler = None):
common.init(AWTK_ROOT, ASSETS_ROOT, THEMES, ASSET_C, OUTPUT_ROOT)
common.set_tools_dir(TOOLS_ROOT)
common.set_lcd_rortrail_info(LCD_ORIENTATION, LCD_FAST_ROTATION_MODE)
common.set_dpi(DPI)
common.set_app_theme(APP_THEME)
common.set_enable_generate_inc_res(IS_GENERATE_INC_RES)

View File

@ -23,6 +23,7 @@ THEME = 'default'
THEME_PACKAGED = True
IMAGEGEN_OPTIONS = 'bgra+bgr565'
LCD_ORIENTATION = '0'
LCD_FAST_ROTATION_MODE = False
ON_GENERATE_RES_BEFORE = None
ON_GENERATE_RES_AFTER = None
EXEC_CMD_HANDLER = None
@ -81,6 +82,7 @@ def emit_generate_res_before(type):
'theme': THEME,
'imagegen_options': IMAGEGEN_OPTIONS,
'lcd_orientation' : LCD_ORIENTATION,
'lcd_fast_rotation_mode' : LCD_FAST_ROTATION_MODE,
'input': INPUT_DIR,
'output': OUTPUT_DIR,
'awtk_root': AWTK_ROOT
@ -95,6 +97,7 @@ def emit_generate_res_after(type):
'theme': THEME,
'imagegen_options': IMAGEGEN_OPTIONS,
'lcd_orientation' : LCD_ORIENTATION,
'lcd_fast_rotation_mode' : LCD_FAST_ROTATION_MODE,
'input': INPUT_DIR,
'output': OUTPUT_DIR,
'awtk_root': AWTK_ROOT
@ -116,6 +119,11 @@ def set_tools_dir(dir):
global BIN_DIR
BIN_DIR = dir
def set_lcd_rortrail_info(lcd_orientation, lcd_fast_rotation_mode):
global LCD_ORIENTATION
global LCD_FAST_ROTATION_MODE
LCD_ORIENTATION = lcd_orientation
LCD_FAST_ROTATION_MODE = lcd_fast_rotation_mode
def set_dpi(dpi):
global DPI
@ -146,7 +154,6 @@ def set_current_theme(index):
global THEME
global THEME_PACKAGED
global IMAGEGEN_OPTIONS
global LCD_ORIENTATION
global INPUT_DIR
global OUTPUT_DIR
@ -160,12 +167,9 @@ def set_current_theme(index):
elif isinstance(theme, dict):
THEME = theme['name']
THEME_PACKAGED = True
LCD_ORIENTATION = '0'
IMAGEGEN_OPTIONS = 'bgra+bgr565'
if 'imagegen_options' in theme:
IMAGEGEN_OPTIONS = theme['imagegen_options']
if 'lcd_orientation' in theme:
LCD_ORIENTATION = theme['lcd_orientation']
if 'packaged' in theme:
THEME_PACKAGED = theme['packaged']
@ -376,7 +380,9 @@ def fontgen(raw, text, inc, size, options, theme):
str(size) + ' ' + options + ' ' + theme)
def imagegen(raw, inc, options, theme, lcd_orientation):
def imagegen(raw, inc, options, theme, lcd_orientation, lcd_fast_rotation_mode):
if not lcd_fast_rotation_mode :
lcd_orientation = '0'
exec_cmd(to_exe('imagegen') + ' \"' + raw + '\" \"' + inc + '\" ' + options + ' ' + theme + ' ' + lcd_orientation)
@ -457,7 +463,7 @@ def gen_res_png_jpg():
if IS_GENERATE_INC_RES:
resgen(raw, inc, THEME, '.res')
if IS_GENERATE_INC_BITMAP:
imagegen(raw, inc, IMAGEGEN_OPTIONS, THEME, LCD_ORIENTATION)
imagegen(raw, inc, IMAGEGEN_OPTIONS, THEME, LCD_ORIENTATION, LCD_FAST_ROTATION_MODE)
# 如果当前主题的gen选项与default主题不一致则按新的gen选项重新生成图片的位图数据
if IS_GENERATE_INC_BITMAP and THEME != 'default':
@ -470,7 +476,7 @@ def gen_res_png_jpg():
if os.path.exists(raw):
make_dirs(inc)
imagegen(raw, inc, IMAGEGEN_OPTIONS, THEME, LCD_ORIENTATION)
imagegen(raw, inc, IMAGEGEN_OPTIONS, THEME, LCD_ORIENTATION, LCD_FAST_ROTATION_MODE)
def gen_res_all_image():
@ -1190,6 +1196,7 @@ def dump_args():
print('DPI = '+DPI)
print('THEMES = '+str(THEMES))
print('IMAGEGEN_OPTIONS = '+IMAGEGEN_OPTIONS)
print('LCD_FAST_ROTATION_MODE = '+str(LCD_FAST_ROTATION_MODE))
print('LCD_ORIENTATION = LCD_ORIENTATION_'+LCD_ORIENTATION)
print('AWTK_ROOT = '+AWTK_ROOT)
print('BIN_DIR = '+BIN_DIR)