about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-07-13 13:32:54 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-07-13 13:32:54 -0700
commitbee126654f1dca0525b53a5580c6f924fc3b017b (patch)
tree2dadaa76b1f324a046b5f339d4f1bca42e3f419a
parent96bf3700fda0ab1065976276cb9606e58b756327 (diff)
downloadmu-bee126654f1dca0525b53a5580c6f924fc3b017b.tar.gz
give up on .pgm files with color depths != 255
Things kinda seem to work for color depths close to 255, but it isn't
really the goal here, and I don't have the skills of numerical analysis
to track this down.
-rw-r--r--img.mu14
1 files changed, 5 insertions, 9 deletions
diff --git a/img.mu b/img.mu
index d258dd72..11cb7816 100644
--- a/img.mu
+++ b/img.mu
@@ -17,7 +17,6 @@ type image {
              #  1: portable bitmap (P1) - pixels 0 or 1
              #  2: portable greymap (P2) - pixels 1-byte greyscale values
              #  3: portable pixmap (P3) - pixels 3-byte rgb values
-  max: int
   width: int
   height: int
   data: (handle array byte)
@@ -252,13 +251,12 @@ fn initialize-image-from-pgm _self: (addr image), in: (addr stream byte) {
   {
     tmp <- parse-decimal-int-from-slice curr-word
     compare tmp, 0xff
-    break-if-<=
-    abort "initialize-image-from-pgm: no more than 255 levels of grey"
+    break-if-=
+    set-cursor-position 0/screen, 0/x 2/y
+    draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "levels of grey is not 255; continuing and hoping for the best", 0x2b/fg 0/bg
   }
-  var dest/edi: (addr int) <- get self, max
-  copy-to *dest, tmp
   # save width, height
-  dest <- get self, width
+  var dest/edi: (addr int) <- get self, width
   copy-to *dest, width
   dest <- get self, height
   copy-to *dest, height
@@ -796,10 +794,8 @@ fn initialize-image-from-ppm _self: (addr image), in: (addr stream byte) {
     break-if-=
     abort "initialize-image-from-ppm: supports exactly 255 levels per rgb channel"
   }
-  var dest/edi: (addr int) <- get self, max
-  copy-to *dest, tmp
   # save width, height
-  dest <- get self, width
+  var dest/edi: (addr int) <- get self, width
   copy-to *dest, width
   dest <- get self, height
   copy-to *dest, height