diff options
Diffstat (limited to '')
| -rw-r--r-- | src/blind-triangle-tessellation.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/blind-triangle-tessellation.c b/src/blind-triangle-tessellation.c index e4eeb21..8d298f0 100644 --- a/src/blind-triangle-tessellation.c +++ b/src/blind-triangle-tessellation.c @@ -4,8 +4,7 @@ USAGE("[-F pixel-format] block-width block-height") #define SET_XYZA(TYPE)\ - (pixwidth *= sizeof(double),\ - colours = alloca(8 * pixwidth),\ + (colours = alloca(8 * stream.pixel_size),\ ((TYPE *)colours)[ 0] = (TYPE)0.412457445582367600,\ ((TYPE *)colours)[ 1] = (TYPE)0.212673370378408280,\ ((TYPE *)colours)[ 2] = (TYPE)0.019333942761673460,\ @@ -46,7 +45,6 @@ main(int argc, char *argv[]) { size_t width, height; const char *pixfmt = "xyza"; - size_t pixwidth = 4; char *colours; size_t x1, y1, x2, y2, k; @@ -64,15 +62,12 @@ main(int argc, char *argv[]) width = etozu_arg("block-width", argv[0], 1, SIZE_MAX); height = etozu_arg("block-height", argv[1], 1, SIZE_MAX); - pixfmt = get_pixel_format(pixfmt, "xyza"); - if (!strcmp(pixfmt, "xyza")) + eset_pixel_format(&stream, pixfmt); + if (stream.encoding == DOUBLE) SET_XYZA(double); - else if (!strcmp(pixfmt, "xyza f")) - SET_XYZA(float); else - eprintf("pixel format %s is not supported, try xyza\n", pixfmt); + SET_XYZA(float); - strcpy(stream.pixfmt, pixfmt); stream.width = 2 * width; stream.height = 2 * height; fprint_stream_head(stdout, &stream); @@ -83,7 +78,7 @@ main(int argc, char *argv[]) for (x1 = 0; x1 < 2; x1++) { for (x2 = 0; x2 < width; x2++) { k = y1 * 4 + x1 * 2 + (x2 * height > y2 * width); - ewriteall(STDOUT_FILENO, colours + k * pixwidth, pixwidth, "<stdout>"); + ewriteall(STDOUT_FILENO, colours + k * stream.pixel_size, stream.pixel_size, "<stdout>"); } } } |
