@@ -22,54 +22,22 @@ char *bmp_js_l(char *content, int size){
2222 unsigned int height = 1 ;
2323 const char _bmp_header1 [18 ] = {0x42 , 0x4d , 0x2f , 0x2a , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x7a , 0x00 , 0x00 , 0x00 , 0x6c , 0x00 , 0x00 , 0x00 };
2424 char sizew [4 ], sizeh [4 ];
25- const char _bmp_header2 [BMP_JS_HEADER_V - 32 ] = {0x01 , 0x00 , 0x18 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x10 , 0x00 , 0x00 , 0x00 , 0x13 , 0x0b , 0x00 , 0x00 , 0x13 , 0x0b , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x42 , 0x47 , 0x52 , 0x73 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x2a , 0x2f , 0x3d , 0x30 , 0x3b , 0x0a };
25+ const char _bmp_header2 [BMP_JS_HEADER_L - 32 ] = {0x01 , 0x00 , 0x18 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x10 , 0x00 , 0x00 , 0x00 , 0x13 , 0x0b , 0x00 , 0x00 , 0x13 , 0x0b , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x42 , 0x47 , 0x52 , 0x73 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x2a , 0x2f , 0x3d , 0x30 , 0x3b , 0x0a };
2626 const char _bmp_footer [6 ] = {0x2f , 0x2f , 0x00 , 0x00 , 0x00 , 0x00 };
27- char * buffer = (char * )malloc (BMP_JS_HEADER_V + size );
27+ char * buffer = (char * )malloc (BMP_JS_HEADER_L + size );
2828 for (int i = 0 ; i < 4 ; i ++ ){
2929 sizew [i ] = (width >> i * 8 ) & 0xff ;
3030 sizeh [i ] = (height >> i * 8 ) & 0xff ;
3131 }
3232 memcpy (buffer , _bmp_header1 , 18 );
3333 memcpy (& buffer [18 ], sizew , 4 );
3434 memcpy (& buffer [22 ], sizeh , 4 );
35- memcpy (& buffer [26 ], _bmp_header2 , BMP_JS_HEADER_V - 26 );
36- memcpy (& buffer [BMP_JS_HEADER_V - 6 ], content , size );
37- memcpy (& buffer [BMP_JS_HEADER_V - 6 + size ], _bmp_footer , 6 );
35+ memcpy (& buffer [26 ], _bmp_header2 , BMP_JS_HEADER_L - 26 );
36+ memcpy (& buffer [BMP_JS_HEADER_L - 6 ], content , size );
37+ memcpy (& buffer [BMP_JS_HEADER_L - 6 + size ], _bmp_footer , 6 );
3838 return buffer ;
3939}
4040
41- char * bmp_js_m (char * content , int size ){
42- const char _bmp_header1 [18 ] = {0x42 , 0x4d , 0x2f , 0x2a , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x7a , 0x00 , 0x00 , 0x00 , 0x6c , 0x00 , 0x00 , 0x00 };
43- char sizew [4 ], sizeh [4 ];
44- unsigned int * wh = getsize (size );
45- int width = wh [0 ];
46- int height = wh [1 ];
47- const char _bmp_header2 [96 ] = {0x01 , 0x00 , 0x18 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x10 , 0x00 , 0x00 , 0x00 , 0x13 , 0x0b , 0x00 , 0x00 , 0x13 , 0x0b , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x42 , 0x47 , 0x52 , 0x73 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
48- char * buffer = (char * )malloc (BMP_JS_HEADER_M + width * 3 * height + height * 9 );
49- for (int i = 0 ; i < 4 ; i ++ ){
50- sizew [i ] = (width >> i * 8 ) & 0xff ;
51- sizeh [i ] = (height >> i * 8 ) & 0xff ;
52- }
53- memcpy (buffer , _bmp_header1 , 18 );
54- memcpy (& buffer [18 ], sizew , 4 );
55- memcpy (& buffer [22 ], sizeh , 4 );
56- memcpy (& buffer [26 ], _bmp_header2 , 96 );
57- char * chnk = chunk (content , size );
58- memcpy (& buffer [122 ], createline (chnk , (width - 3 ) * 3 ), width * 3 );
59- for (int i = 1 ; i < height ; i ++ ){
60- memcpy (& buffer [122 + (width * 3 )* i ], createline (& chnk [i * ((width - 3 ) * 3 )], (width - 3 ) * 3 ), width * 3 );
61- }
62- return buffer ;
63- }
64-
65- char * chunk (char * content , int size ){
66- char _chunkhead [6 ] = {0x2a , 0x2f , 0x3d , 0x30 , 0x3b , 0x0a };
67- char * chunks = (char * )malloc (size + 6 );
68- memcpy (chunks , _chunkhead , 6 );
69- memcpy (& chunks [6 ], content , size );
70- return chunks ;
71- }
72-
7341char * bmp_js_i (char * content , int csize , char * image , int isize ){
7442 const char _bmp_header [7 ] = {0x42 , 0x4d , 0x3d , 0x30 , 0x3b , 0x2f , 0x2a };
7543 const char _bmp_header_end [BMP_JS_HEADER_I ] = {0x2a , 0x2f , 0x3b };
@@ -88,19 +56,3 @@ char *bmp_filename(char *fn, int size){
8856 memcpy (& newfile [size ], _bmp_ending , BMP_ENDING );
8957 return newfile ;
9058}
91-
92- unsigned int * getsize (int size ){
93- int * wh = (int * )malloc (sizeof (int ) * 2 );
94- wh [0 ] = (int )sqrt ((double )size ) + 2 ;
95- wh [1 ] = (size / wh [0 ] + 2 )/2 + 1 ;
96- printf ("%d, %dx%d\n" , size , wh [0 ], wh [1 ]);
97- return wh ;
98- }
99-
100- char * createline (char * line , int len ){
101- char _line_end [9 ] = {0x2f , 0x2a , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x2a , 0x2f };
102- char * newline = (char * )malloc (len + 9 );
103- memcpy (newline , line , len );
104- memcpy (& newline [len ], _line_end , 9 );
105- return newline ;
106- }
0 commit comments