# HG changeset patch # User Matti Hamalainen # Date 1551780871 -7200 # Node ID e38705223ce4361ab9237522b50963069f03c198 # Parent f43011ea9b9f9e16aaed1f46ef9273093fd4541b Support grayscale output. diff -r f43011ea9b9f -r e38705223ce4 tools/libgfx.c --- a/tools/libgfx.c Tue Mar 05 10:54:47 2019 +0200 +++ b/tools/libgfx.c Tue Mar 05 12:14:31 2019 +0200 @@ -336,8 +336,72 @@ *ptr3 = ptr2 + rowWidth, *ptr4 = ptr3 + rowWidth; - if (img->format == DM_COLFMT_PALETTE || - img->format == DM_COLFMT_GRAYSCALE) + if (img->format == DM_COLFMT_GRAYSCALE) + { + for (x = 0; x < img->width; x++) + { + Uint8 c = img->data[(y * img->pitch) + (x * img->bpp) / 8]; + + switch (spec->format) + { + case DM_COLFMT_PALETTE: + case DM_COLFMT_GRAYSCALE: + for (xscale = 0; xscale < spec->scaleX; xscale++) + *ptr1++ = c; + break; + + case DM_COLFMT_RGBA: + if (spec->planar) + { + for (xscale = 0; xscale < spec->scaleX; xscale++) + { + *ptr1++ = c; + *ptr2++ = c; + *ptr3++ = c; + *ptr4++ = 0xff; + } + } + else + { + for (xscale = 0; xscale < spec->scaleX; xscale++) + { + *ptr1++ = c; + *ptr1++ = c; + *ptr1++ = c; + *ptr1++ = 0xff; + } + } + break; + + case DM_COLFMT_RGB: + if (spec->planar) + { + for (xscale = 0; xscale < spec->scaleX; xscale++) + { + *ptr1++ = c; + *ptr2++ = c; + *ptr3++ = c; + } + } + else + { + for (xscale = 0; xscale < spec->scaleX; xscale++) + { + *ptr1++ = c; + *ptr1++ = c; + *ptr1++ = c; + } + } + break; + + default: + res = DMERR_NOT_SUPPORTED; + goto done; + } + } + } + else + if (img->format == DM_COLFMT_PALETTE) { for (x = 0; x < img->width; x++) {