about summary refs log tree commit diff stats
path: root/511image.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-07-29 08:24:27 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-07-29 08:24:27 -0700
commite55d3f5814d0f243d9d6a51f05433c14f0939055 (patch)
tree3da63846ece6e84599abd02c30a71e4068448148 /511image.mu
parent54765018beb8a9c0dde67de527dbfedefdecaed0 (diff)
downloadmu-e55d3f5814d0f243d9d6a51f05433c14f0939055.tar.gz
maintain aspect ratio when rendering images
Diffstat (limited to '511image.mu')
-rw-r--r--511image.mu13
1 files changed, 13 insertions, 0 deletions
diff --git a/511image.mu b/511image.mu
index 6696be59..94787d66 100644
--- a/511image.mu
+++ b/511image.mu
@@ -1098,3 +1098,16 @@ fn render-raw-image screen: (addr screen), _img: (addr image), xmin: int, ymin:
     loop
   }
 }
+
+fn scale-image-height _img: (addr image), width: int -> _/ebx: int {
+  var img/esi: (addr image) <- copy _img
+  var img-height/eax: (addr int) <- get img, height
+  var result-f/xmm0: float <- convert *img-height
+  var img-width/eax: (addr int) <- get img, width
+  var img-width-f/xmm1: float <- convert *img-width
+  result-f <- divide img-width-f
+  var width-f/xmm1: float <- convert width
+  result-f <- multiply width-f
+  var result/ebx: int <- convert result-f
+  return result
+}