ios - Return a copy of a UIImage instead of change in place -
i'm newbie @ ios development, , have run seems odd me. i've got following method take large image , make smaller version of it, upload both server:
- (void)prepareanduploadimages { uiimage *originalimage = self.imageview.image; uiimage *smallerimage = [originalimage resizedimagewithcontentmode:uiviewcontentmodescaleaspectfill bounds:cgsizemake(1024.0, 768.0) interpolationquality:1]; [self uploadimage:originalimage withfilename:@"original.jpg"]; [self uploadimage:smallerimage withfilename:@"smaller.jpg"]; }
this uploading images fine, weird thing when land on server "original.jpg"
image shrunk version , "smaller.jpg"
full-size image.
i'm using uiimage resizedimagewithcontentmode:
method uiimagecategories, it's return looks this:
return [self resizedimage:newsize interpolationquality:quality];
the resizedimage:interpolationquality method it's calling returns this:
return [self resizedimage:newsize transform:transform drawtransposed:drawtransposed interpolationquality:quality];
that resizedimage:transform:... method call returns this:
// resized image context , uiimage cgimageref newimageref = cgbitmapcontextcreateimage(bitmap); uiimage *newimage = [uiimage imagewithcgimage:newimageref scale:self.scale orientation:uiimageorientationup]; ... return newimage;
so, have expected code setting smallerimage
new image created return value method called on original image, instead appears behavior original image modified in place, before modified in place returns self? don't know, seems weird.
can explain me what's going on here, , how can fix code desired behaviour?
figured out:
i thought original image larger 1024 across, wasn't. happening, size given in points, not pixels, "smaller" image making upscaling image, not downscaling image. that's throwing me off.
if cut size in half pixel dimensions i'm looking for.
thanks comments, helped!
Comments
Post a Comment