Image saving works!
This commit is contained in:
parent
b018d727a0
commit
766a5878e6
4 changed files with 11 additions and 11 deletions
21
main.nim
21
main.nim
|
|
@ -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
|
||||
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)
|
||||
saveBMP24("mandelbrot.bmp", raw, 800, 600)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue