From d05d162cb81664f292834fa5d48d623d2b6147a7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 16 Jul 2017 15:29:43 +0200 Subject: Misc code improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-rectangle-tessellation.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/blind-rectangle-tessellation.c') diff --git a/src/blind-rectangle-tessellation.c b/src/blind-rectangle-tessellation.c index a139934..2d83222 100644 --- a/src/blind-rectangle-tessellation.c +++ b/src/blind-rectangle-tessellation.c @@ -4,8 +4,7 @@ USAGE("[-F pixel-format] block-width block-height") #define SET_XYZA(TYPE)\ - (pixwidth *= sizeof(double),\ - colours = alloca(4 * pixwidth),\ + (colours = alloca(4 * stream.pixel_size),\ ((TYPE *)colours)[ 0] = (TYPE)0.412457445582367600,\ ((TYPE *)colours)[ 1] = (TYPE)0.212673370378408280,\ ((TYPE *)colours)[ 2] = (TYPE)0.019333942761673460,\ @@ -30,7 +29,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; @@ -48,15 +46,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); @@ -66,7 +61,8 @@ main(int argc, char *argv[]) for (y2 = 0; y2 < height; y2++) for (x1 = 0; x1 < 2; x1++) for (x2 = 0; x2 < width; x2++) - ewriteall(STDOUT_FILENO, colours + (y1 * 2 + x1) * pixwidth, pixwidth, ""); + ewriteall(STDOUT_FILENO, colours + (y1 * 2 + x1) * stream.pixel_size, + stream.pixel_size, ""); return 0; } -- cgit v1.2.3-70-g09d2