image.go
func (i *Image) SubImage(r image.Rectangle) image.Image {
	i.copyCheck()
	if i.isDisposed() {
		return nil
	}

	img := &Image{
		mipmap: i.mipmap,
		filter: i.filter,
	}

	// Keep the original image's reference not to dispose that by GC.
	if i.isSubImage() {
		img.original = i.original
	} else {
		img.original = i
	}
	img.addr = img

	r = r.Intersect(i.Bounds())
	// Need to check Empty explicitly. See the standard image package implementations.
	if r.Empty() {
		img.bounds = image.ZR
	} else {
		img.bounds = r
	}
	return img
}
func (i *Image) SubImage(r image.Rectangle) image.Image {
	i.copyCheck()
	if i.isDisposed() {
		return nil
	}

	img := &Image{
		mipmap: i.mipmap,
		filter: i.filter,
	}

	// Keep the original image's reference not to dispose that by GC.
	if i.isSubImage() {
		img.original = i.original
	} else {
		img.original = i
	}
	img.addr = img

	r = r.Intersect(i.Bounds())
	// Need to check Empty explicitly. See the standard image package implementations.
	if r.Empty() {
		img.bounds = image.ZR
	} else {
		img.bounds = r
	}
	return img
}
func ( i * Image ) SubImage ( r image . Rectangle ) image . Image { i . copyCheck ( ) if i . isDisposed ( ) { return nil } img := & Image { mipmap : i . mipmap , filter : i . filter , } // Keep the original image's reference not to dispose that by GC. if i . isSubImage ( ) { img . original = i . original } else { img . original = i } img . addr = img r = r . Intersect ( i . Bounds ( ) ) // Need to check Empty explicitly. See the standard image package implementations. if r . Empty ( ) { img . bounds = image . ZR } else { img . bounds = r } return img }
// SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.
//
// The returned value is always *ebiten.Image.
//
// If the image is disposed, SubImage returns nil.
//
// In the current Ebiten implementation, SubImage is available only as a rendering source.
SubImage returns an image representing the portion of the image p visible through r . The returned value shares pixels with the original image . The returned value is always * ebiten . Image . If the image is disposed SubImage returns nil . In the current Ebiten implementation SubImage is available only as a rendering source .