graphics: Set pixels at NewImageFromImage

This commit is contained in:
Hajime Hoshi 2016-06-12 21:29:25 +09:00
parent ea440f5b17
commit 2a0ca3c393

View File

@ -407,13 +407,17 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) {
draw.Draw(newImg, newImg.Bounds(), origImg, origImg.Bounds().Min, draw.Src) draw.Draw(newImg, newImg.Bounds(), origImg, origImg.Bounds().Min, draw.Src)
rgbaImg = newImg 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() imageM.Lock()
defer imageM.Unlock() defer imageM.Unlock()
img := &imageImpl{ img := &imageImpl{
width: w, width: w,
height: h, height: h,
filter: filter, filter: filter,
pixels: pixels,
} }
var err error var err error
img.image, err = graphics.NewImageFromImage(rgbaImg, glFilter(ui.GLContext(), filter)) img.image, err = graphics.NewImageFromImage(rgbaImg, glFilter(ui.GLContext(), filter))