I am creating a vector drawing application, and let me tell you that this is NOT an easy task to work properly and requires quite a bit of work.
Some points to keep in mind:
- If you do not use vector graphics (for example, CGPaths vectors), you cannot delete pixels. UIImage, for example, only has this permission.
- So that your drawing does not look uneven, you are going to need to redraw everything. If you have a lot of drawing, this can be an expensive task.
- A good WHILE resolution scaling is almost impossible, because it will require too much context, and your drawing is likely to exceed the capabilities of the device.
I use the main graphics for drawing, so I solved this problem by selecting and managing several CGContexts and using them as buffers. I have one context that is ALWAYS stored at my minimum increased level (scale factor 1). This context is involved at all times and makes it such that when the time is completely turned off, the time taken to re-draw is not executed, since it has already been done. Another context is used for drawing when scaling. If not scaled, this context is ignored (since in any case it will have to be redrawn based on the new zoom level). The high-level algorithm for how I perform scaling is as follows:
- (IBAction)handlePinchGesture:(UIGestureRecognizer *)sender { if(sender.state == UIGestureRecognizerStateBegan) {
This becomes even more complicated for me because I have extra buffers for buffers, because drawing images of my paths is much faster than drawing paths when there are a lot of drawings.
Between managing multiple contexts, setting up your code for efficient use in multiple contexts, after proper OOD, scaling a new drawing based on your current scaling and translation, etc., this is a mountain of work. I hope this either motivates you and puts you on the right path, or you decide that getting rid of this pixelation is not worth the effort :)
MikeS source share