On Wed, Nov 9, 2016 at 4:14 AM,  <jordan.stinso...@gmail.com> wrote:
> I'm trying to write out a png with an alpha component as a jpeg. As I
> understand it, I should be able to use the draw package to do this.
>
>         // src is an image.RGBA
>         newImg := image.NewRGBA(src.Bounds())
>
> draw.Draw(newImg, newImg.Bounds(), &image.Uniform{color.White},
> image.Point{}, draw.Src)
> draw.Draw(newImg, newImg.Bounds(), src, src.Bounds().Min, draw.Over)
>
> return jpeg.Encode(w, newImg, &jpeg.Options{Quality: 85})
>
> I expected this blend the src rgb components with the white background using
> the alpha value. It appears to be ignoring the alpha value all together. Is
> this expected? I'm using go1.7.1.

That sounds unexpected to me too. &image.Uniform{color.White} can just
be image.White, but that shouldn't be the problem.

What is your source image? If you load it in another image viewer or
editor, does it show transparency (usually depicted as a checkerboard
pattern)? How are you loading it, in Go? What happens if you add a
printf:

fmt.Printf("src has type %T\n", src)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to