mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Replace []uint8 with []byte
This commit is contained in:
parent
bba20e8b8c
commit
80596820cf
4
image.go
4
image.go
@ -206,7 +206,7 @@ func (i *Image) Dispose() error {
|
||||
// When the image is disposed, ReplacePixels does nothing.
|
||||
//
|
||||
// ReplacePixels always returns nil as of 1.5.0-alpha.
|
||||
func (i *Image) ReplacePixels(p []uint8) error {
|
||||
func (i *Image) ReplacePixels(p []byte) error {
|
||||
if i.restorable == nil {
|
||||
return nil
|
||||
}
|
||||
@ -215,7 +215,7 @@ func (i *Image) ReplacePixels(p []uint8) error {
|
||||
panic(fmt.Sprintf("ebiten: len(p) was %d but must be %d", len(p), l))
|
||||
}
|
||||
w2, h2 := math.NextPowerOf2Int(w), math.NextPowerOf2Int(h)
|
||||
pix := make([]uint8, 4*w2*h2)
|
||||
pix := make([]byte, 4*w2*h2)
|
||||
for j := 0; j < h; j++ {
|
||||
copy(pix[j*w2*4:], p[j*w*4:(j+1)*w*4])
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ func (c *drawImageCommand) quadsNum() int {
|
||||
// replacePixelsCommand represents a command to replace pixels of an image.
|
||||
type replacePixelsCommand struct {
|
||||
dst *Image
|
||||
pixels []uint8
|
||||
pixels []byte
|
||||
}
|
||||
|
||||
// Exec executes the replacePixelsCommand.
|
||||
|
@ -104,7 +104,7 @@ func (i *Image) DrawImage(src *Image, vertices []float32, clr *affine.ColorM, mo
|
||||
theCommandQueue.EnqueueDrawImageCommand(i, src, vertices, clr, mode)
|
||||
}
|
||||
|
||||
func (i *Image) Pixels() ([]uint8, error) {
|
||||
func (i *Image) Pixels() ([]byte, error) {
|
||||
// Flush the enqueued commands so that pixels are certainly read.
|
||||
if err := theCommandQueue.Flush(); err != nil {
|
||||
return nil, err
|
||||
@ -116,8 +116,8 @@ func (i *Image) Pixels() ([]uint8, error) {
|
||||
return opengl.GetContext().FramebufferPixels(f.native, math.NextPowerOf2Int(i.width), math.NextPowerOf2Int(i.height))
|
||||
}
|
||||
|
||||
func (i *Image) ReplacePixels(p []uint8) {
|
||||
pixels := make([]uint8, len(p))
|
||||
func (i *Image) ReplacePixels(p []byte) {
|
||||
pixels := make([]byte, len(p))
|
||||
copy(pixels, p)
|
||||
c := &replacePixelsCommand{
|
||||
dst: i,
|
||||
|
@ -63,7 +63,7 @@ type Image struct {
|
||||
filter graphics.Filter
|
||||
|
||||
// baseImage and baseColor are exclusive.
|
||||
basePixels []uint8
|
||||
basePixels []byte
|
||||
baseColor color.RGBA
|
||||
|
||||
// drawImageHistory is a set of draw-image commands.
|
||||
@ -101,7 +101,7 @@ func NewImageFromImage(source image.Image, filter graphics.Filter) *Image {
|
||||
width, height := size.X, size.Y
|
||||
rgbaImg := CopyImage(source)
|
||||
w2, h2 := math.NextPowerOf2Int(width), math.NextPowerOf2Int(height)
|
||||
p := make([]uint8, 4*w2*h2)
|
||||
p := make([]byte, 4*w2*h2)
|
||||
for j := 0; j < height; j++ {
|
||||
copy(p[j*w2*4:(j+1)*w2*4], rgbaImg.Pix[j*rgbaImg.Stride:])
|
||||
}
|
||||
@ -130,7 +130,7 @@ func NewScreenFramebufferImage(width, height int, offsetX, offsetY float64) *Ima
|
||||
}
|
||||
|
||||
// BasePixelsForTesting returns the image's basePixels for testing.
|
||||
func (i *Image) BasePixelsForTesting() []uint8 {
|
||||
func (i *Image) BasePixelsForTesting() []byte {
|
||||
return i.basePixels
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ func (i *Image) Fill(r, g, b, a uint8) {
|
||||
}
|
||||
|
||||
// ReplacePixels replaces the image pixels with the given pixels slice.
|
||||
func (i *Image) ReplacePixels(pixels []uint8) {
|
||||
func (i *Image) ReplacePixels(pixels []byte) {
|
||||
theImages.makeStaleIfDependingOn(i)
|
||||
i.image.ReplacePixels(pixels)
|
||||
i.basePixels = pixels
|
||||
|
Loading…
Reference in New Issue
Block a user