iphone - Having problems splitting up UIImageView into smaller images -


i'm trying take uiimageview, resize image , display it. want break image smaller pieces , display them.

the resized image displays correctly appears "split up" images big; i'm thinking coming original (slightly bigger) image. following screenshot shows resized image on left , column of split images left hand side.

enter image description here

the fact resized image displaying correctly , smaller ones aren't has me confused. ideas appreciated - or alternative. here code:

- (void)viewdidload {     [super viewdidload];     // additional setup after loading view, typically nib.     width = imgoriginal.frame.size.width;     height = imgoriginal.frame.size.height;     whratio = width/height;      [self getoriginalimageinfo];     [self resizeimage];     resizedimage = [self resizeimage]; }  -(void) getoriginalimageinfo {     lblwidth.text = [nsstring stringwithformat:@"%0.2f", width];     lblheight.text = [nsstring stringwithformat:@"%0.2f", height];     lblwhratio.text = [nsstring stringwithformat:@"%0.2f", whratio]; }   -(uiimageview*) resizeimage {     if (whratio >= 0.7 && whratio <=0.89) {         imgoriginal.frame = cgrectmake(20, 20, 500, 600);         imgoriginal.autoresizingmask = no;         float resizedwhratio = (imgoriginal.frame.size.width)/(imgoriginal.frame.size.height);         lblresizedwidth.text = [nsstring stringwithformat:@"%0.2f", imgoriginal.frame.size.width];         lblresizedheight.text = [nsstring stringwithformat:@"%0.2f", imgoriginal.frame.size.height];         lblresizedwhratio.text = [nsstring stringwithformat:@"%0.2f", resizedwhratio];         return imgoriginal;     }     return nil; }  - (ibaction)easypressed:(id)sender {     nslog(@"easy button pressed");     cgimageref original = [resizedimage.image cgimage];     float piecewidth = (resizedimage.frame.size.width) / 5;     float pieceheight = (resizedimage.frame.size.height) / 6;     (int =0; i<6; i++) {         cgrect rectangle = cgrectmake(0, 0+((float)i*pieceheight), piecewidth, pieceheight);         cgimageref newtile =  cgimagecreatewithimageinrect(original, rectangle);         uiimageview *puzzlepiece = [[uiimageview alloc] initwithframe:cgrectmake(611, 20+((float)i*pieceheight), piecewidth, pieceheight)];         puzzlepiece.tag = i+1;         puzzlepiece.image = [uiimage imagewithcgimage:newtile];         puzzlepiece.alpha = 0.5;         [puzzlepiece.layer setbordercolor: [[uicolor blackcolor] cgcolor]];         [puzzlepiece.layer setborderwidth: 1.0];         [self.view addsubview:puzzlepiece];     } } 

try applying same scaling factor partial images main image!!!

or

take screenshot of uiimageview being displayed , split instead.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -