chore: move coin and hand to statics and modify c compilation
This commit is contained in:
parent
d6ab4e4022
commit
b17657884a
4
build.sh
4
build.sh
|
@ -51,8 +51,8 @@ echo -e "$pengers_html" > pengers_image.html.temp
|
|||
sed -e '/<!-- penger images src -->/rpengers_image.html.temp' index.html.template > index.html
|
||||
rm pengers_image.html.temp
|
||||
|
||||
./png2c "hand.png" > hand.c
|
||||
./png2c "coin.png" > coin.c
|
||||
./out/png2c "static/assets/hand.png" > out/hand.c
|
||||
./out/png2c "static/assets/coin.png" > out/coin.c
|
||||
|
||||
clang -O3 --target=wasm32 -fno-builtin -nostdlib --no-standard-libraries -Wl,--no-entry $export_cmd -Wl,--allow-undefined -o $f.wasm $a
|
||||
|
||||
|
|
20
png2c.c
20
png2c.c
|
@ -20,11 +20,23 @@ int main(int argc, const char *argv[])
|
|||
}
|
||||
|
||||
if (argc < 3) { // no id provided
|
||||
int file_name_len = strlen(img_path) - strlen(".png");
|
||||
char *last_slash = strrchr(img_path, '/');
|
||||
char extracted[50];
|
||||
|
||||
printf("int %.*s_height = %d;\n", file_name_len, img_path, height);
|
||||
printf("int %.*s_width = %d;\n", file_name_len, img_path, width);
|
||||
printf("unsigned int %.*s_img[%d][%d] = {\n", file_name_len, img_path, height, width);
|
||||
if (last_slash != NULL) {
|
||||
// Extract the part after the last '/'
|
||||
strcpy(extracted, last_slash + 1);
|
||||
|
||||
// Remove the '.png' extension
|
||||
char *dot = strrchr(extracted, '.');
|
||||
if (dot != NULL) {
|
||||
*dot = '\0'; // Null-terminate the string at the '.'
|
||||
}
|
||||
}
|
||||
|
||||
printf("int %s_height = %d;\n", extracted, height);
|
||||
printf("int %s_width = %d;\n", extracted, width);
|
||||
printf("unsigned int %s_img[%d][%d] = {\n", extracted, height, width);
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
printf(" ");
|
||||
|
|
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 474 B |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Loading…
Reference in New Issue