forked from pyrite-dev/milsko
rewrite in c
This commit is contained in:
parent
bb599c9fbb
commit
1d4b1d4e35
3 changed files with 41 additions and 17 deletions
|
|
@ -6,7 +6,7 @@ LIBS = `pkg-config --libs freetype2`
|
|||
.PHONY: all clean
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
all: fuzzer font
|
||||
all: fuzzer font icon-converter icon-converter
|
||||
|
||||
fuzzer: fuzzer.o
|
||||
$(CC) -g -L../src/ -Wl,-R../src -o $@ fuzzer.o -lMw
|
||||
|
|
@ -14,8 +14,11 @@ fuzzer: fuzzer.o
|
|||
font: font.o
|
||||
$(CC) $(LDFLAGS) -o $@ font.o $(LIBS)
|
||||
|
||||
icon-converter: icon-converter.o
|
||||
$(CC) -o $@ icon-converter.o -lm
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f *.o font fuzzer
|
||||
rm -f *.o font fuzzer icon-converter
|
||||
|
|
|
|||
36
tools/icon-converter.c
Normal file
36
tools/icon-converter.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "../external/stb_image.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv){
|
||||
unsigned char* rgba;
|
||||
int width, height, bpp;
|
||||
int i;
|
||||
|
||||
if(argc != 3){
|
||||
printf("Usage: %s input name\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rgba = stbi_load(argv[1], &width, &height, &bpp, 4);
|
||||
|
||||
printf("MwU32 %s[] = {\n", argv[2]);
|
||||
printf(" (%d << 16) | %d,\n", width, height);
|
||||
for(i = 0; i < width * height; i++){
|
||||
unsigned char* px = &rgba[i * 4];
|
||||
unsigned int p = 0;
|
||||
int j;
|
||||
|
||||
for(j = 0; j < 4; j++){
|
||||
p = p << 8;
|
||||
p = p | px[j];
|
||||
}
|
||||
|
||||
printf(" 0x%x,\n", p);
|
||||
}
|
||||
printf(" 0\n");
|
||||
printf("};\n");
|
||||
|
||||
free(rgba);
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/sh
|
||||
if [ "x$1" = "x" -o "x$2" = "x" ]; then
|
||||
echo "Usage: $0 input name"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GEO=`convert $1 json:- 2>/dev/null | jq -r '(.[0].image.geometry.width | tostring) + "x" + (.[0].image.geometry.height | tostring)'`
|
||||
WIDTH=`echo $GEO | cut -dx -f1`
|
||||
HEIGHT=`echo $GEO | cut -dx -f2`
|
||||
|
||||
echo "MwU32 $2[] = {"
|
||||
echo " ($WIDTH << 16) | $HEIGHT,"
|
||||
convert $1 txt:- 2>/dev/null | grep -oE '#[0-9a-fA-F]{8}' | sed 's/^#/ 0x/' | sed -E 's/$/,/'
|
||||
echo " 0"
|
||||
echo "};"
|
||||
Loading…
Add table
Add a link
Reference in a new issue