-(void) Configuredetailswithimage: (UIImage *) Image label: (NSString *) label Showsbuttons: (BOOL) showsbutton{ = image; = label; if (Showsbutton = = NO) { = YES; = YES; } Else if (Showsbutton = = YES) { = NO; = NO; }}
-(void) Setmainimage: (UIImage *) image{ [Self.filteredimages removeallobjects]; if (Image! = nil) { [self populateimageviewwithimage:image]; } = image; *currentindexpath = Self.tableView.indexPathForSelectedRow; [Self.tableview Reloaddata]; [Self.tableview Selectrowatindexpath:currentindexpath Animated:yes scrollposition:uitableviewscrollpositiontop];}
1+ (UIImage *) Scaleimage: (UIImage *) Image tosize: (cgsize) Size2 {3 uigraphicsbeginimagecontext (size);4[Image Drawinrect:cgrectmake (0,0, Size.width, Size.Height)];5UIImage *scaledimage =Uigraphicsgetimagefromcurrentimagecontext ();6 Uigraphicsendimagecontext ();7 returnScaledimage;8 }9 Ten+ (UIImage *) Aspectscaleimage: (UIImage *) Image tosize: (cgsize) Size One { A if(Image.size.height <image.size.width) - { - floatRatio = Size.Height/Image.size.height; theCgsize newSize = Cgsizemake (Image.size.width *ratio, size.height); - - Uigraphicsbeginimagecontext (newSize); -[Image Drawinrect:cgrectmake (0,0, Newsize.width, Newsize.height)]; + } - Else + { A floatRatio = Size.width/Image.size.width; atCgsize newSize = Cgsizemake (Size.width, image.size.height*ratio); - - Uigraphicsbeginimagecontext (newSize); -[Image Drawinrect:cgrectmake (0,0, Newsize.width, Newsize.height)]; - } -UIImage *aspectscaledimage =Uigraphicsgetimagefromcurrentimagecontext (); in Uigraphicsendimagecontext (); - returnAspectscaledimage; to } + -+ (UIImage *) Aspectfillimage: (UIImage *) Image tosize: (cgsize) Size the { * uigraphicsbeginimagecontext (size); $ if(image.size.height<image.size.width)Panax Notoginseng { - floatRatio = size.height/Image.size.height; the[Image Drawinrect:cgrectmake (0,0, image.size.width*ratio, size.height)]; + } A Else the { + floatRatio = size.width/Image.size.width; -[Image Drawinrect:cgrectmake (0,0, Size.width, image.size.height*ratio)]; $ } $UIImage *aspectscaledimage =Uigraphicsgetimagefromcurrentimagecontext (); - Uigraphicsendimagecontext (); - returnAspectscaledimage; the}
1- (void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath2 {3 if(Self.mainimage! =Nil)4 {5UIImage *image;6NSString *label;7BOOL showsbuttons =NO;8 if(Indexpath.row = =0)9 {TenImage =Self.mainimage; OneLabel =@"Select an Image to Display"; AShowsbuttons =YES; - } - Else if(Indexpath.row = =1) the { -Image =[Masterviewcontroller scaleImage:self.mainImage toSize:self.detailViewController.imageView.frame.size]; -Label =@"Chosen Image Resized"; - } + Else if(Indexpath.row = =2) - { +Image =[Masterviewcontroller aspectScaleImage:self.mainImage toSize:self.detailViewController.imageView.frame.size] ; ALabel =@"Chosen Image Scaled"; at } - Else if(Indexpath.row = =3) - { -Image = [Self.filteredimages objectatindex:0]; -Cgsize contentsize =self.detailViewController.imageView.frame.size; -Image =[Masterviewcontroller aspectscaleimage:image tosize:contentsize]; inLabel =@"Hue Adjustment"; - } to Else if(Indexpath.row = =4) + { -Image = [Self.filteredimages objectatindex:1]; theCgsize contentsize =self.detailViewController.imageView.frame.size; *Image =[Masterviewcontroller aspectscaleimage:image tosize:contentsize]; $Label =@"Straightening Filter";Panax Notoginseng } - Else if(Indexpath.row = =5) the { +Image = [Self.filteredimages objectatindex:2]; ACgsize contentsize =self.detailViewController.imageView.frame.size; theImage =[Masterviewcontroller aspectscaleimage:image tosize:contentsize]; +Label =@"Series Filter"; - } $ [Self.detailviewcontroller configuredetailswithimage:image Label:label showsbuttons:showsbuttons]; $ } -}
Strategy 10-4: Zooming the image