diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-07-08 00:26:58 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-07-08 00:26:58 -0700 |
commit | 0f29e612384f8243530ab04a589ce856707e6956 (patch) | |
tree | b45325bc96e5ef5c0d32a1a2219193d12c1ea7ce | |
parent | 9c70f7c643a55c7c575b261a167750bd1dceb06e (diff) | |
download | mu-0f29e612384f8243530ab04a589ce856707e6956.tar.gz |
better greyscale
-rw-r--r-- | img.mu | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/img.mu b/img.mu index 1fbe907c..5b916568 100644 --- a/img.mu +++ b/img.mu @@ -299,8 +299,7 @@ fn render-pgm-image screen: (addr screen), _self: (addr image), xmin: int, ymin: var src-a/eax: (addr byte) <- index data, i var src/eax: byte <- copy-byte *src-a var src-int/eax: int <- copy src - # shades of grey = just a non-zero luminance - var color/eax: int <- nearest-color-euclidean-hsl 0/hue, 0/saturation, src-int + var color/eax: int <- nearest-grey src-int pixel screen, x, y, color } x <- increment @@ -313,6 +312,13 @@ fn render-pgm-image screen: (addr screen), _self: (addr image), xmin: int, ymin: } } +fn nearest-grey level-255: int -> _/eax: int { + var result/eax: int <- copy level-255 + result <- shift-right 4 + result <- add 0x10 + return result +} + fn render-ppm-image screen: (addr screen), _self: (addr image), xmin: int, ymin: int, width: int, height: int { var self/esi: (addr image) <- copy _self var img-width-a/ecx: (addr int) <- get self, width |