From 6b05027c94eb0fd685ce824a9df6a02779636c76 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sun, 28 Jan 2024 18:27:36 +0200 Subject: [PATCH] floor tool --- .gitignore | 1 + tools/floor/Makefile | 12 ++++++++++ tools/floor/floor.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 tools/floor/Makefile create mode 100644 tools/floor/floor.c diff --git a/.gitignore b/.gitignore index 09004c7..170e017 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ *.z80 tools/pngdump/pngdump tools/json2tmap/json2tmap +tools/floor/floor core disasm .cache/ diff --git a/tools/floor/Makefile b/tools/floor/Makefile new file mode 100644 index 0000000..3c2877a --- /dev/null +++ b/tools/floor/Makefile @@ -0,0 +1,12 @@ +obj = floor.o +bin = floor + +CFLAGS = -pedantic -Wall -g +LDFLAGS = -limago -lm + +$(bin): $(obj) + $(CC) -o $@ $(obj) $(LDFLAGS) + +.PHONY: clean +clean: + rm -f $(obj) $(bin) diff --git a/tools/floor/floor.c b/tools/floor/floor.c new file mode 100644 index 0000000..4db2d22 --- /dev/null +++ b/tools/floor/floor.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include + +void scale_line(uint32_t *dst, uint32_t *src, float scale, int xsz); + +int main(int argc, char **argv) +{ + uint32_t *img, *newimg, *src, *dst; + float scale, y, z; + int i, scanline, xsz, ysz; + + if(!argv[1] || !argv[2]) { + fprintf(stderr, "usage: %s \n", argv[0]); + return 1; + } + + if(!(img = img_load_pixels(argv[1], &xsz, &ysz, IMG_FMT_RGBA32))) { + fprintf(stderr, "failed to open: %s\n", argv[1]); + return 1; + } + + if(!(newimg = calloc(1, xsz * ysz * 4))) { + perror("malloc failed"); + return 1; + } + + dst = newimg; + for(i=0; i