MCPcopy Create free account
hub / github.com/cogentcore/core / SetGoImage

Method SetGoImage

vgpu/vals.go:216–235  ·  view source on GitHub ↗

SetGoImage sets Texture image data from an *image.RGBA standard Go image, at given layer, and sets the Mod flag, so it will be sync'd by Memory or if TextureOwns is set for the var, it allocates Host memory. This is most efficiently done using an image.RGBA, but other formats will be converted as ne

(img image.Image, layer int, flipY bool)

Source from the content-addressed store, hash-verified

214// the image data (requires row-by-row copy) -- can avoid this
215// by configuring texture coordinates to compensate.
216func (vl *Value) SetGoImage(img image.Image, layer int, flipY bool) error {
217 if vl.HasFlag(ValueTextureOwns) {
218 if layer == 0 && vl.Texture.Format.Layers <= 1 {
219 vl.Texture.ConfigGoImage(img.Bounds().Size(), layer+1)
220 }
221 vl.Texture.AllocHost()
222 }
223 err := vl.Texture.SetGoImage(img, layer, flipY)
224 if err != nil {
225 fmt.Println(err)
226 } else {
227 vl.SetMod()
228 }
229 if vl.HasFlag(ValueTextureOwns) {
230 vl.Texture.AllocTexture()
231 // svimg, _ := vl.Texture.GoImage()
232 // images.Save(svimg, fmt.Sprintf("dimg_%d.png", vl.Index))
233 }
234 return err
235}
236
237// MemReg returns the memory region for this value
238func (vl *Value) MemReg(vr *Var) MemReg {

Callers

nothing calls this directly

Calls 9

HasFlagMethod · 0.95
SetModMethod · 0.95
ConfigGoImageMethod · 0.80
PrintlnMethod · 0.80
AllocTextureMethod · 0.80
SizeMethod · 0.65
SetGoImageMethod · 0.65
BoundsMethod · 0.45
AllocHostMethod · 0.45

Tested by

no test coverage detected