func NewBitmap(code barcode.Barcode) *Bitmap { dim := code.Bounds().Max b := &Bitmap{data: make([]bool, dim.X*dim.Y), height: dim.Y, width: dim.X} for y := 0; y < dim.Y; y++ { for x := 0; x < dim.X; x++ { if code.At(x, y) == color.Black { b.Set(x, y, true) } } } return b }