From cfbd2afc19739baa339b40a6ec5b612fd41fdad0 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Sun, 4 Jul 2021 15:41:43 -0700 Subject: [PATCH] Add example for printing tag --- examples/img.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 examples/img.c diff --git a/examples/img.c b/examples/img.c new file mode 100644 index 000000000..bfb21a4d7 --- /dev/null +++ b/examples/img.c @@ -0,0 +1,29 @@ +#if 0 +/*─────────────────────────────────────────────────────────────────╗ +│ To the extent possible under law, Justine Tunney has waived │ +│ all copyright and related or neighboring rights to this file, │ +│ as it is written in the following disclaimers: │ +│ • http://unlicense.org/ │ +│ • http://creativecommons.org/publicdomain/zero/1.0/ │ +╚─────────────────────────────────────────────────────────────────*/ +#endif +#include "libc/stdio/stdio.h" +#include "libc/x/x.h" +#include "third_party/stb/stb_image.h" + +/** + * @fileoverview Utility for printing HTML tags. + */ + +int main(int argc, char *argv[]) { + void *p; + size_t n; + int yn, xn, cn; + if (argc != 2) return 1; + if (!(p = xslurp(argv[1], &n))) return 2; + if (!(p = stbi_load_from_memory(p, n, &xn, &yn, &cn, 0))) return 3; + printf("\"[%s]\"\n", + argv[1], (xn + 1) >> 1, (yn + 1) >> 1, argv[1]); + return 0; +}