mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 09:22:01 +01:00
graphics: Set pixels at NewImageFromImage
This commit is contained in:
parent
ea440f5b17
commit
2a0ca3c393
6
image.go
6
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)
|
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user