Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/image/bmp: support 4-bit format #58005

Open
susanhuhu opened this issue Jan 25, 2023 · 9 comments
Open

x/image/bmp: support 4-bit format #58005

susanhuhu opened this issue Jan 25, 2023 · 9 comments
Labels
FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@susanhuhu
Copy link

susanhuhu commented Jan 25, 2023

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

$ go version 1.18

Does this issue reproduce with the latest release?

Yes

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

go env Output $ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/snap/go/10030"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/snap/go/10030/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/xxx/go/src/yyy/go.mod"
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-build3498157493=/tmp/go-build -gno-record-gcc-switches"


### What did you do?

call image.DecodeConfig(bytes.NewReader(data)) for attached image

What did you expect to see?

Decode success

What did you see instead?

Errror bmp: unsupported BMP image

@seankhliao seankhliao changed the title affected/package: golang.org/x/image/bmp: unsupported BMP image x/image/bmp: unsupported BMP image Jan 25, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jan 25, 2023
@seankhliao
Copy link
Member

the image link is an expired link

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 25, 2023
@susanhuhu
Copy link
Author

How shall I share the image pls? this basically the 1st image displayed if you search 'bmp image example' in Google

@seankhliao
Copy link
Member

upload it here?

@susanhuhu
Copy link
Author

susanhuhu commented Jan 25, 2023

Github doesn't support it. It complains
image

@susanhuhu
Copy link
Author

Ok, here we go, I put it into a zip file BMPExample.zip

@AlexanderYastrebov
Copy link
Contributor

AlexanderYastrebov commented Jan 27, 2023

The library only supports 8, 24 or 32 bits per pixel https://pkg.go.dev/golang.org/x/image/bmp#DecodeConfig
but the image has 4 bpp

file /tmp/go58005.bmp 
/tmp/go58005.bmp: PC bitmap, Windows 3.x format, 640 x 480 x 4

so it fails here https://github.com/golang/image/blob/bb712eb67b2b77b691f7b4335cc013a0eb42b71c/bmp/reader.go#L240

@susanhuhu
Copy link
Author

Thanks for finding the root cause. Can we add support for 4bpp? sounds like an easy fix?

@susanhuhu
Copy link
Author

Or, do you know any golang image library that can support 4bpp?

@AlexanderYastrebov
Copy link
Contributor

See also related discussion #29711

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. FeatureRequest and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jan 30, 2023
@seankhliao seankhliao changed the title x/image/bmp: unsupported BMP image x/image/bmp: support 4-bit format Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants