Image saving works!

This commit is contained in:
joachimschmidt557 2019-04-20 14:24:21 +02:00
parent b018d727a0
commit 766a5878e6
4 changed files with 11 additions and 11 deletions

View file

@ -1,15 +1,14 @@
import mandelbrot, colors import mandelbrot, colors, nimBMP
echo mandelbrot.generateImage(800, 600, 150'f64, 32, 570)[0][0] let img = mandelbrot.generateImage(800, 600, 150'f64, 32, 570)
var raw:seq[uint8]
import stb_image/write as stbiw for y in img:
for x in y:
let rgb = x.extractRGB()
raw.add(rgb.r.uint8)
raw.add(rgb.g.uint8)
raw.add(rgb.b.uint8)
# Stuff some pixels saveBMP24("mandelbrot.bmp", raw, 800, 600)
var data: seq[uint8] = @[]
data.add(0x00)
data.add(0x80)
data.add(0xFF)
# save it (as monochrome)
stbiw.writeBMP("three.bmp", 3, 1, stbiw.Y, data)

BIN
mandelbrot.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

View file

@ -11,3 +11,4 @@ bin = @["main"]
requires "nim >= 0.19.9" requires "nim >= 0.19.9"
requires "stbimage >= 2.3" requires "stbimage >= 2.3"
requires "nimbmp >= 0.1.6"

BIN
three.bmp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 B