ios4 - Merging a previosly rotated by gesture UIImageView with another one. WYS is not WYG -
ios4 - Merging a previosly rotated by gesture UIImageView with another one. WYS is not WYG -
i'm getting crazy while trying merge 2 uiimageview.
the situation:
a background uiimageview (userphotoimageview) an overlayed uiimageview (productphotoimageview) can streched, pinched , rotatedi phone call function on uiimages can take coords , new stretched size uiimageview containing them (they synthesized in class)
- (uiimage *)mergeimage:(uiimage *)bottomimg withimage:(uiimage *)topimg;
maybe simplest way rendering layer of top uiimageview in new cgcontextref this:
[bottomimg drawinrect:cgrectmake(0, 0, bottomimg.size.width, bottomimg.size.height)]; [productphotoimageview.layer renderincontext:ctx];
but in way loose rotation effect previosly applied gestures.
a sec way trying apply affinetransformation uiimage reproduce gestureeffects , draw in context this:
uiimage * scaledtopimg = [topimg imagebyscalingproportionallytosize:productphotoview.frame.size]; uiimage * rotatedscaledtopimg = [scaledtopimg imagerotatedbydegrees:angle]; [rotatedscaledtopimg drawatpoint:cgpointmake(productphotoview.frame.origin.x, productphotoview.frame.origin.y)];
the problem of sec approach i'm not able final rotation degrees (the angle parameter should filled in code above) amount since user started interact, because rotationgesture reset 0 after applying next callback delta current rotation.
for sure easy way first one, freezing 2 uiimageviews displayed in moment still didn't find anyway it.
ok there workaround crazy merging stuff, it's definitively not elegant solution. avoid handling kind of affinetransformation capture imagescreen , crop it.
cgimageref screenimage = uigetscreenimage(); cgrect fullrect = [[uiscreen mainscreen] applicationframe]; cgimageref savecgimage = cgimagecreatewithimageinrect(screenimage, fullrect); cgrect croprect = cgrectmake(x,y,width,height); cgimageref savecgimage = cgimagecreatewithimageinrect(screenimage, croprect);
told wasnt elegant, useful.
ios4 uiimageview uiimage cgcontext
Comments
Post a Comment