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.
()
| 152 | // The underlying image is in the [ImgCopy] field. |
| 153 | // If a persistent image is required, call [imagex.CloneAsRGBA]. |
| 154 | func (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]. |
| 171 | func (sc *Scene) ImageUpdate() (*image.RGBA, error) { |
no test coverage detected