why logo is black
i put a yellow logo,but get a black one
Hi @banbo. Honestly, I've never thought of making logo colorful, it's black and white by design. But I see no problem in (optionally) preserving the color, so will take a look on it soon.
Any solution for this issue?
I tried to change the color in your code but still it fails
I tried to change the color in your code but still it fails
I tried using his library to rewrite a piece of code in it to be able to print the color of the logo
func (e Encoder) Encode(str string, logo image.Image, size int) (*bytes.Buffer, error) {
var buf bytes.Buffer
code, err := qr.New(str, e.QRLevel)
if err != nil {
return nil, err
}
img := code.Image(size)
cimg := image.NewRGBA(img.Bounds())
e.overlayLogo(img, logo, cimg)
err = png.Encode(&buf, cimg)
if err != nil {
return nil, err
}
return &buf, nil
}
// overlayLogo blends logo to the center of the QR code,
// keep all colors
func (e Encoder) overlayLogo(dst, src image.Image, cimg draw.Image) {
draw.Draw(cimg, dst.Bounds(), dst, image.Point{}, draw.Over)
offset := dst.Bounds().Max.X/2 - src.Bounds().Max.X/2
for x := 0; x < src.Bounds().Max.X; x++ {
for y := 0; y < src.Bounds().Max.Y; y++ {
r, g, b, alpha := src.At(x, y).RGBA()
cimg.Set(x+offset, y+offset, color.RGBA{R: uint8(r), G: uint8(g), B: uint8(b), A: uint8(alpha)})
}
}
}
implemented qr-codes with color logo in my fork https://github.com/delivery-club/qrlogo