I'm trying to enable resizing and moving of an image within a certain view.
doing so, the challenge is not to lose the image quality.
I have a UIImageView
placed inside UIView
(I'm not using UIScrollView
as implementing it, i found it not suitable for this case) and I'm following the UIPanGestureRecognizer
and UIPinchGestureRecognizer
for dragging and zooming.
the problem is when I'm trying to recreate the new image in the boundaries of the UIView
:
if the UIImageView
is in the boundaries of the UIView
it's fine, taking the visible rect scaling according to CGImageCreateWithImageInRect
.
However, if the inner UIImageView
is smaller than the UIView
(zoom-out) or moved so it doesn't cover the whole UIView
, it just creates the image in the original size, or not in the position I was intending.
The solution that works is renderInContext , which makes an image of what is visible in the UIView
- but that the image quality is drastically reduced.
is there a way to do it without losing the image quality? maybe add some edges with 0 alpha, so it will suit the frames of the UIView
, yet suits memory demands?