Strategy 10-4: Zooming the image

Source: Internet
Author: User

-(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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.