From 4f9581d08e16efe79babddaabb451d4efaca1a60 Mon Sep 17 00:00:00 2001 From: Liu Chao Date: Sun, 16 Jun 2013 15:23:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=9B=BE=E5=83=8F=E8=BD=AC?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=9A=84=E7=A8=8B=E5=BA=8F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/graph2array.c | 81 +++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 44 deletions(-) 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; }