This commit is contained in:
Kartik K. Agaram 2021-07-13 05:23:53 -07:00
parent 2777479a94
commit 250de0442b
1 changed files with 2 additions and 14 deletions

16
img.mu
View File

@ -27,8 +27,8 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
var img-storage: image
var img/esi: (addr image) <- address img-storage
load-image img, data-disk
render-image screen, img, 0/x, 0/y, 0x300/width, 0x300/height
#? render-image screen, img, 0x20/x, 0x80/y, 0x258/width=600, 0x190/height=400
#? render-image screen, img, 0/x, 0/y, 0x300/width, 0x300/height
render-image screen, img, 0x20/x, 0x80/y, 0x258/width=600, 0x190/height=400
#? render-image screen, img, 0x20/x, 0x80/y, 0x12c/width=300, 0xc8/height=200
#? render-pgm-image screen, img, 0x220/x, 0x80/y, 0x12c/width=300, 0xc8/height=200
}
@ -455,12 +455,6 @@ fn dither-pgm-unordered _src: (addr image), _dest: (addr image) {
var dest-height-a/ecx: (addr int) <- get dest, height
copy-to *dest-height-a, tmp
}
# compute scaling factor 255/max
var target-scale/eax: int <- copy 0xff
var scale-f/xmm7: float <- convert target-scale
var src-max-a/eax: (addr int) <- get src, max
var tmp-f/xmm0: float <- convert *src-max-a
scale-f <- divide tmp-f
# transform 'data'
var capacity/ebx: int <- copy src-width
capacity <- multiply src-height
@ -484,12 +478,6 @@ fn dither-pgm-unordered _src: (addr image), _dest: (addr image) {
compare x, src-width
break-if->=
var initial-color/eax: byte <- _read-pgm-buffer src-data, x, y, src-width
# . scale to 255 levels
var initial-color-int/eax: int <- copy initial-color
var initial-color-f/xmm0: float <- convert initial-color-int
initial-color-f <- multiply scale-f
initial-color-int <- convert initial-color-f
var initial-color/eax: byte <- copy-byte initial-color-int
var error/esi: int <- _read-dithering-error errors, x, y, src-width
# error += (initial-color << 16)
{