From 2a0ca3c393632cd5b980f86ac7bb925c6e9b0101 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 12 Jun 2016 21:29:25 +0900 Subject: [PATCH] graphics: Set pixels at NewImageFromImage --- image.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/image.go b/image.go index 6a20691e0..6e6da2834 100644 --- a/image.go +++ b/image.go @@ -407,13 +407,17 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) { draw.Draw(newImg, newImg.Bounds(), origImg, origImg.Bounds().Min, draw.Src) rgbaImg = newImg } - // TODO: Set pixels here? + pixels := make([]uint8, 4*w*h) + for j := 0; j < h; j++ { + copy(pixels[j*w*4:(j+1)*w*4], rgbaImg.Pix[j*rgbaImg.Stride:]) + } imageM.Lock() defer imageM.Unlock() img := &imageImpl{ width: w, height: h, filter: filter, + pixels: pixels, } var err error img.image, err = graphics.NewImageFromImage(rgbaImg, glFilter(ui.GLContext(), filter))