I need to create a mono bitmap image with a colour depth of 1 bit, for example:
$ file exampleMono.bmp
> exampleMono.bmp: PC bitmap, Windows 3.x format, 640 x 1000 x 1
In Go, I'm able to generate a simple bmp image with the following:
tempPal := color.Palette([]color.Color{
color.Black, color.White,
})
img := image.NewPaletted(image.Rect(640, 1000,0,0), tempPal)
filename := fmt.Sprintf("img-%d.bmp", time.Now().Unix())
file, _ := os.Create(filename)
bmp.Encode(file, img)
file.close
However, the resulting bmp file has a colour depth of 8-bits.
$ file img-1611574755.bmp
> img-1611574755.bmp: PC bitmap, Windows 3.x format, 640 x 1000 x 8
I've had a look through the bmp, image and draw packages in Go and haven't found anything that appears to provide the ability to set the colour depth to 1 bit. Is it possible to achieve what I need in Go and if so, how?
question from:
https://stackoverflow.com/questions/65884109/generate-1-bit-depth-bmp-image 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…