diff options
-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 |