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

image/draw: subimage rectangle's MIN point is not start (0,0) #33681

Closed
leexingliang opened this issue Aug 16, 2019 · 3 comments
Closed

image/draw: subimage rectangle's MIN point is not start (0,0) #33681

leexingliang opened this issue Aug 16, 2019 · 3 comments

Comments

@leexingliang
Copy link

@leexingliang leexingliang commented Aug 16, 2019

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

go version go1.12.1 linux/amd64

Does this issue reproduce with the latest release?

Not

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/work/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/work/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/work/fencoder/huifang-fencoder/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build595600236=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I want to capture part of the RGBA image with rectangle by using image.RGBA.SubImage funcation.

func subimage(src *image.RGBA, rect image.Rectangle) *image.RGBA {
	// src.Rect = image.Rectangle{
	// 	Min: image.Point{0, 0},
	// 	Max: image.Point{1000, 1000},
	// }

	dstrect := image.Rect(100, 100, 200, 200)
	dstimage := src.SubImage(dstrect)

        fmt.Println("dstimage rectangle: ", dstimage.Bounds())
        return dstimage.(*image.RGBA)
}

What did you expect to see?

dstimage rectangle: (0,0)-(100,100)

that equal image.Rect(0, 0, rect.Dx(), rect.Dy())

What did you see instead?

for above code

dstimage rectangle: (100,100)-(200,200)
@nigeltao
Copy link
Contributor

@nigeltao nigeltao commented Aug 17, 2019

This is intentional. See https://blog.golang.org/go-image-package, which says that "A common mistake is assuming that an Image's bounds start at (0, 0)".

Loading

@nigeltao nigeltao closed this Aug 17, 2019
@nigeltao
Copy link
Contributor

@nigeltao nigeltao commented Aug 17, 2019

Judging from the issue title, "subimage rectangle's MIN point is not (0,0)", I assume that you are expecting that dstimage's rectangle starts at (0, 0).

In other words, the "What did you expect to see?" and "What did you see instead?" sections' contents should be swapped around.

Loading

@leexingliang
Copy link
Author

@leexingliang leexingliang commented Aug 18, 2019

Judging from the issue title, "subimage rectangle's MIN point is not (0,0)", I assume that you are expecting that dstimage's rectangle starts at (0, 0).

In other words, the "What did you expect to see?" and "What did you see instead?" sections' contents should be swapped around.

yeah, i will mod it

Loading

@leexingliang leexingliang changed the title image/draw: subimage rectangle's MIN point is not (0,0) image/draw: subimage rectangle's MIN point is not start (0,0) Aug 18, 2019
@golang golang locked and limited conversation to collaborators Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants