Package bmp implements a BMP image decoder and encoder.
The BMP specification is at http://www.digicamsoft.com/bmp/bmp.html.
- 1, 2, 4, 8, 16, 24 and 32 bits per pixel
- Top-down images (read-only)
- RLE compression for 4 and 8 BPP images (read-only)
- RGB555 and RGB565 types for 16 BPP images (read-only)
Use go get:
go get github.com/sergeymakinen/go-bmp
Then import the package into your own code:
import "github.com/sergeymakinen/go-bmp"
f, _ := os.Open("file.bmp")
img, _ := bmp.Decode(f)
for i := 10; i < 20; i++ {
img.(draw.Image).Set(i, i, color.NRGBA{
R: 255,
G: 0,
B: 0,
A: 255,
})
}
f.Truncate(0)
bmp.Encode(f, img)
f.Close()
BSD 3-Clause