Paste iPhone continuously into a raster object? What am I missing?

I'm sure this is a direct problem that I should be confused about (I'm new to the iPhone): I try to constantly draw shapes using the CG API into a bitmap object and always show up to date the current version of this bitmap on the screen, inside the UIScrollView object, so that the user could pan, zoom, etc.

Using a UIView with drawRect is not good because it is the current thing. I have a separate stream where all the drawing commands are issued, and I need them to be applied and accumulated on the same framebuffer (like a website page rendering engine). I continue to see that all of the GCContext image-related APIs seem to CREATE a completely new image when you want it to appear on the screen. This sounds bad because it creates a different copy of the image.

I suppose I'm looking for a way to create an off-screen bitmap, render for it as much as I want using Core Graphics, and whenever I want, blt this image to the screen, but still retain the ability to continue drawing and click on the screen again , later.

Thanks in advance!

+3
source share
1 answer

You can use CGLayer. Create it once with CGLayerCreateWithContext(), and then restore the context of the layer with CGLayerGetContext()whenever you need to paste it.

To draw a layer in a different graphics context, call CGContextDrawLayerAtPoint()or CGContextDrawLayerInRect().

+4
source

Source: https://habr.com/ru/post/1769221/


All Articles