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

graphics: Rendering a scaled image might miss edge pixels #611

Closed
hajimehoshi opened this issue May 13, 2018 · 2 comments
Closed

graphics: Rendering a scaled image might miss edge pixels #611

hajimehoshi opened this issue May 13, 2018 · 2 comments
Labels
Milestone

Comments

@hajimehoshi
Copy link
Owner

This test fails on MacBook Pro:

func TestImageStretch(t *testing.T) {
        img0, _ := NewImage(16, 17, FilterDefault)

        pix := make([]byte, 4*16*17)
        for i := 0; i < 16*16; i++ {
                pix[4*i] = 0xff
                pix[4*i+3] = 0xff
        }
        for i := 0; i < 16; i++ {
                pix[4*(16*16+i)+1] = 0xff
                pix[4*(16*16+i)+3] = 0xff
        }
        img0.ReplacePixels(pix)

        const h = 4096
        img1, _ := NewImage(16, h, FilterDefault)
        for i := 1; i < h; i++ {
                img1.Clear()
                op := &DrawImageOptions{}
                op.GeoM.Scale(1, float64(i)/16)
                r := image.Rect(0, 0, 16, 16)
                op.SourceRect = &r
                img1.DrawImage(img0, op)
                for j := -1; j <= 1; j++ {
                        got := img1.At(0, i+j).(color.RGBA)
                        want := color.RGBA{}
                        if j < 0 {
                                want = color.RGBA{0xff, 0, 0, 0xff}
                        }
                        if got != want {
                                t.Errorf("At(%d, %d) (i=%d): got: %#v, want: %#v", 0, i+j, i, got, want)
                        }
                }
        }
}
@hajimehoshi hajimehoshi added this to the v1.7.0 milestone May 13, 2018
@hajimehoshi
Copy link
Owner Author

--- FAIL: TestImageStretch (2.43s)
image_test.go:830: At(0, 4093) (i=4094): got: color.RGBA{R:0x0, G:0x0, B:0x0, A:0x0}, want: color.RGBA{R:0xff, G:0x0, B:0x0, A:0xff}
image_test.go:830: At(0, 4094) (i=4095): got: color.RGBA{R:0x0, G:0x0, B:0x0, A:0x0}, want: color.RGBA{R:0xff, G:0x0, B:0x0, A:0xff}
FAIL
FAIL    github.com/hajimehoshi/ebiten   2.970s

@hajimehoshi hajimehoshi modified the milestones: v1.7.0, v1.8.0 May 13, 2018
@hajimehoshi
Copy link
Owner Author

The situation was more complicated than I thought. On MacBook Pro 2018, the result depends on what kind of tests are executed at the same time. I think this is a bug on the GPU, but am not sure.

@hajimehoshi hajimehoshi removed this from the v1.8.0 milestone Sep 27, 2018
@hajimehoshi hajimehoshi added this to the v1.10.0 milestone Jul 30, 2019
hajimehoshi added a commit that referenced this issue Jul 31, 2019
Before this change, enlarging a 1px image with x4095 scale was not
accurate and edges were missing. This change fixes this issue.

Updates #611
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant