diff --git a/test/graph2array.c b/test/graph2array.c index c0d75796..dda3834c 100755 --- a/test/graph2array.c +++ b/test/graph2array.c @@ -15,86 +15,73 @@ char help_text[]={ "%s image_file_path\n" }; -static void -get_filename(char *filepath, char *out_name) -/* 根据文件路径,获取文件名 */ -{ - int m,n = 0; - char *p; - for(m=0; m\n" + "#include LC_LCUI_H\n" + "#include LC_GRAPH_H\n\n" ); /* red channel */ - fprintf( fp, " unsigned char red[] = {" ); + fprintf( fp, "static unsigned char graph_red[] = {" ); for( i=0; iwidth*buff->height; ++i ) { if( i%MAX_ROW_PIXEL_NUM == 0 ) { - fprintf( fp, "\n " ); + fprintf( fp, "\n\t" ); } fprintf( fp, "0x%02x,", buff->rgba[0][i] ); } - fprintf( fp, "\n };\n" ); + fprintf( fp, "\n};\n\n" ); /* green channel */ - fprintf( fp, " unsigned char green[] = {" ); + fprintf( fp, "static unsigned char graph_green[] = {" ); for( i=0; iwidth*buff->height; ++i ) { if( i%MAX_ROW_PIXEL_NUM == 0 ) { - fprintf( fp, "\n " ); + fprintf( fp, "\n\t" ); } fprintf( fp, "0x%02x,", buff->rgba[1][i] ); } - fprintf( fp, "\n };\n" ); + fprintf( fp, "\n};\n\n" ); /* blue channel */ - fprintf( fp, " unsigned char blue[] = {" ); + fprintf( fp, "static unsigned char graph_blue[] = {" ); for( i=0; iwidth*buff->height; ++i ) { if( i%MAX_ROW_PIXEL_NUM == 0 ) { - fprintf( fp, "\n " ); + fprintf( fp, "\n\t" ); } fprintf( fp, "0x%02x,", buff->rgba[2][i] ); } - fprintf( fp, "\n };\n" ); + fprintf( fp, "\n};\n\n" ); /* alpha channel */ if( buff->have_alpha ) { - fprintf( fp, " unsigned char alpha[] = {" ); + fprintf( fp, "static unsigned char graph_alpha[] = {" ); for( i=0; iwidth*buff->height; ++i ) { if( i%MAX_ROW_PIXEL_NUM == 0 ) { - fprintf( fp, "\n " ); + fprintf( fp, "\n\t" ); } fprintf( fp, "0x%02x,", buff->rgba[3][i] ); } - fprintf( fp, "\n };\n" ); + fprintf( fp, "\n};\n\n" ); } fprintf( fp, - " if( Graph_Valid( buff ) ) {\n" + "int InCoreIMG_LoadMyIIMG ( LCUI_Graph *buff )\n" + "{\n" + " int ret;\n" + " if( Graph_IsValid( buff ) ) {\n" " Graph_Free( buff );\n" " }\n" " Graph_Init( buff );\n" @@ -105,16 +92,22 @@ graph_conv( LCUI_Graph *buff, char *out_filename ) " if( ret == 0 ) {\n" " memcpy( buff->rgba[0], red, sizeof(red) );\n" " memcpy( buff->rgba[1], green, sizeof(green) );\n" - " memcpy( buff->rgba[2], blue, sizeof(blue) );\n" - " if( buff->have_alpha ) {\n" - " memcpy( buff->rgba[3], alpha, sizeof(alpha) );\n" - " }\n" - " }\n" - " return ret;\n" - "}\n", + " memcpy( buff->rgba[2], blue, sizeof(blue) );\n", buff->have_alpha?"TRUE":"FALSE", buff->type, buff->width, buff->height ); + if( buff->have_alpha ) { + fprintf( fp, + " if( buff->have_alpha ) {\n" + " memcpy( buff->rgba[3], alpha, sizeof(alpha) );\n" + " }\n" + ); + } + fprintf( fp, + " }\n" + " return ret;\n" + "}\n" + ); fclose( fp ); return 0; }