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

Method ImageCopy

xyz/render.go:154–168  ·  view source on GitHub ↗

ImageCopy returns a copy of the current rendered image from the Frame RenderFrame. A re-used image.RGBA is returned. This same image is used across calls to avoid large memory allocations, so it will automatically update after the next ImageCopy call. The underlying image is in the [ImgCopy] field.

()

Source from the content-addressed store, hash-verified

152// The underlying image is in the [ImgCopy] field.
153// If a persistent image is required, call [imagex.CloneAsRGBA].
154func (sc *Scene) ImageCopy() (*image.RGBA, error) {
155 fr := sc.Frame
156 if fr == nil {
157 return nil, fmt.Errorf("xyz.Scene ImageCopy: Scene does not have a Frame")
158 }
159 sy := &sc.Phong.Sys
160 tcmd := sy.MemCmdStart()
161 fr.GrabImage(tcmd, 0) // note: re-uses a persistent Grab image
162 sy.MemCmdEndSubmitWaitFree()
163 err := fr.Render.Grab.DevGoImageCopy(&sc.imgCopy)
164 if err == nil {
165 return &sc.imgCopy, err
166 }
167 return nil, err
168}
169
170// ImageUpdate configures, updates, and renders the scene, then returns [Scene.Image].
171func (sc *Scene) ImageUpdate() (*image.RGBA, error) {

Callers 1

ImageMethod · 0.80

Calls 5

MemCmdStartMethod · 0.80
DevGoImageCopyMethod · 0.80
ErrorfMethod · 0.65
GrabImageMethod · 0.45

Tested by

no test coverage detected