Skip to content

image/color: NRGBA provides alpha-premultiplied values, and RGBA provides non-alpha-premultiplied values. The doc claims the exact opposite. #55327

@ScienceMarc

Description

@ScienceMarc

What version of Go are you using (go version)?

$ go version
go version go1.19 linux/amd64

Does this issue reproduce with the latest release?

Yes. This issue has been present in every version since weekly.2011-10-06.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/marc/.cache/go-build"
GOENV="/home/marc/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/marc/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/marc/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3829980571=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://go.dev/play/p/ckINKpbqQ2L

What did you expect to see?

This should be alpha-premultiplied (0 0 0 0): 0 0 0 0
This should be alpha-premultiplied (0 0 0 0): 0 0 0 0

This shouldn't be alpha-premultiplied (0 32639 65535 0): 0 32639 65535 0
This shouldn't be alpha-premultiplied (0 2147483647 4294967295 0): 0 2147483647 4294967295 0

What did you see instead?

This should be alpha-premultiplied (0 0 0 0): 0 32639 65535 0
This should be alpha-premultiplied (0 0 0 0): 0 32767 65535 0

This shouldn't be alpha-premultiplied (0 32639 65535 0): 0 0 0 0
This shouldn't be alpha-premultiplied (0 2147483647 4294967295 0): 0 0 0 0


I may be completely misinterpreting the documentation, or even misinterpreting the concept of alpha-premultiplication, but based on the Wikipedia page for Alpha compositing the current behavior is inverted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions