iphone - resize image 600x600 to 100x100 programmatically -
i have image height 600 , width 600 want display image programmatically in uiimageview 100x100. try image not original image add screen shoot of image first 100x100 , second 200x200. second fine.but first 1 not original image. idea please
in.h
@interface viewcontroller : uiviewcontroller { iboutlet uiimageview *imageview1; iboutlet uiimageview *imageview2; } @end
in.m
- (void)viewdidload { [super viewdidload]; imageview1.frame=cgrectmake(100, 50, 100, 100); imageview2.frame=cgrectmake(50, 200, 200, 200); imageview1.image = [uiimage imagenamed:@"untitled-7.png"]; imageview2.image = [uiimage imagenamed:@"untitled-7.png"]; }
please try this
uiimage *originalimage = [uiimage imagenamed:@"5.png"]; cgsize destinationsize = cgsizemake(100, 100); uigraphicsbeginimagecontext(destinationsize); [originalimage drawinrect:cgrectmake(0,0,destinationsize.width,destinationsize.height)]; uiimage *newimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); uiimageview *newimageview = [[uiimageview alloc] initwithframe:cgrectmake(20, 20, 100, 100)]; newimageview.image = newimage; [self.view addsubview:newimageview];
Comments
Post a Comment