diff --git a/docs/changes.md b/docs/changes.md index ff907d8c4..37ebd1363 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -2,6 +2,7 @@ * 2019/07/09 * 完整弹出窗口动画,支持在不同位置弹出。 + * 支持bmp(感谢俊杰提供补丁)。 * 2019/07/08 * 表达式支持条件运算。 diff --git a/scripts/update_res_common.py b/scripts/update_res_common.py index 8c995f27d..935ee82fd 100755 --- a/scripts/update_res_common.py +++ b/scripts/update_res_common.py @@ -169,6 +169,7 @@ def gen_res_png_jpg(): inc = joinPath(OUTPUT_DIR, 'images/'+basename) inc = inc.replace('.png', '.data') inc = inc.replace('.jpg', '.data') + inc = inc.replace('.bmp', '.data') inc = inc.replace('.gif', '.data') inc = fix_output_file_name(inc) imagegen(raw, inc) diff --git a/src/base/assets_manager.c b/src/base/assets_manager.c index 99449f44a..1fe6dba97 100644 --- a/src/base/assets_manager.c +++ b/src/base/assets_manager.c @@ -141,6 +141,10 @@ static asset_info_t* try_load_image(assets_manager_t* am, const char* name, extname = ".gif"; break; } + case ASSET_TYPE_IMAGE_BMP: { + extname = ".bmp"; + break; + } case ASSET_TYPE_IMAGE_BSVG: { extname = ".bsvg"; subpath = "assets/raw/images/svg"; @@ -285,6 +289,10 @@ asset_info_t* assets_manager_load_asset(assets_manager_t* am, asset_type_t type, return info; } + if ((info = try_load_image(am, name, ASSET_TYPE_IMAGE_BMP, TRUE)) != NULL) { + return info; + } + if ((info = try_load_image(am, name, ASSET_TYPE_IMAGE_JPG, TRUE)) != NULL) { return info; } @@ -298,6 +306,10 @@ asset_info_t* assets_manager_load_asset(assets_manager_t* am, asset_type_t type, return info; } + if ((info = try_load_image(am, name, ASSET_TYPE_IMAGE_BMP, FALSE)) != NULL) { + return info; + } + if ((info = try_load_image(am, name, ASSET_TYPE_IMAGE_JPG, FALSE)) != NULL) { return info; } diff --git a/tools/res_gen/main.c b/tools/res_gen/main.c index cb10b9349..e4102458d 100644 --- a/tools/res_gen/main.c +++ b/tools/res_gen/main.c @@ -47,6 +47,8 @@ int main(int argc, char** argv) { output_res_c_source(out_filename, ASSET_TYPE_FONT, ASSET_TYPE_FONT_TTF, input_buff, size); } else if (end_with(in_filename, ".png")) { output_res_c_source(out_filename, ASSET_TYPE_IMAGE, ASSET_TYPE_IMAGE_PNG, input_buff, size); + } else if (end_with(in_filename, ".bmp")) { + output_res_c_source(out_filename, ASSET_TYPE_IMAGE, ASSET_TYPE_IMAGE_BMP, input_buff, size); } else if (end_with(in_filename, ".jpg")) { output_res_c_source(out_filename, ASSET_TYPE_IMAGE, ASSET_TYPE_IMAGE_JPG, input_buff, size); } else if (end_with(in_filename, ".gif")) {