uiimageview

renderInContext taxes App Memory

强颜欢笑 提交于 2019-12-05 14:49:15
I'm running this code on a 2448 X 2448 pixel Image. fullScaleView is also 2448 X 2448 ( fullScreenView Rect:{{0, 0}, {2448, 2448}} ). The App memory jumps from 49.7MB to 240MB down to 172MB after the method is complete. It stays at 172MB. It doesn't seem like the app should still be running at such high a memory footprint after this one renderInContext . Where and how should I force a release? (iOS 7 XCode 5 ARC). UIGraphicsBeginImageContextWithOptions(fullScaleView.bounds.size, fullScaleView.opaque, 1.0); [fullScaleView.layer renderInContext: UIGraphicsGetCurrentContext()]; UIImage *viewImage

skewing a UIImageView using CGAffineTransform

南笙酒味 提交于 2019-12-05 14:49:00
I am trying to skew a rectangle so the two vertical sides are slanted but parallel and the top and bottom are horizontal. I am trying to use CGAffineTransform and have found this code but I am not figuring out what to put in the various parts. imageView.layer.somethingMagic.imageRightTop = (CGPoint){ 230, 30 }; imageView.layer.somethingMagic.imageRightBottom = (CGPoint){ 300, 150 }; #define CGAffineTransformDistort(t, x, y) (CGAffineTransformConcat(t, CGAffineTransformMake(1, y, x, 1, 0, 0))) #define CGAffineTransformMakeDistort(x, y) (CGAffineTransformDistort(CGAffineTransformIdentity, x, y))

ios - SizeToFit on UIImageView not working

流过昼夜 提交于 2019-12-05 14:19:31
I have a UIImageView which loads in images from the documents directory on the ios file system . The problem is that when I call [imageView sizeToFit]; It does not work. I think it is because the image hasn't loaded fully at that point and so the sizeToFit part is called before it has the image width & height. Could someone point me in the direction of a fix please. Here is my code: imageView.contentMode = UIViewContentModeScaleAspectFit; imageView.image = [UIImage imageWithContentsOfFile:[FileOperations getLibraryPath:[NSString stringWithFormat:@"%d.png", listData.imageId]]]; [imageView

Objective C: Programmatically create a UIImageView

放肆的年华 提交于 2019-12-05 12:20:50
I'm trying to make a UIImageView with a .png load up in the location of a button when it is clicked. brickAnim = UIImageView.alloc; ///////freezes during runtime [brickAnim initWithFrame:currentBrick.frame]; [brickAnim setImage:[NSString stringWithFormat:@"brick-1.png"]]; [self.view addSubview:brickAnim]; current brick is the name of the button that's being clicked. I've narrowed it down and figured out that the first line causes the app to freeze and exit. I can't figure out what I'm doing wrong. try brickAnim = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"brick-1.png"]];

Xcode: SDWebImage clear cache for single image

余生颓废 提交于 2019-12-05 11:45:02
问题 I'm using SDWebImage to asynchronous image downloader with cache support. It's working perfectly except that sometimes the image got updated on the server with same name, thus I need to clear it from client device cache but no success! I found here that I have to use "removeImageForKey" but it's not recognized by Xcode! I'm using the following code to set the image: [imgPic setImageWithURL:[NSURL URLWithString:@"http://domain.com/image.jpg"] placeholderImage:[UIImage imageNamed:@"tmpPic.png"]

Is it possible to set the position of an UIImageView's image?

为君一笑 提交于 2019-12-05 11:31:30
问题 I have a UIImageView that displays a bigger image. It appears to be centered, but I would like to move that image inside that UIImageView . I looked at the MoveMe sample from Apple, but I couldn't figure out how they do it. It seems that they don't even have an UIImageView for that. Any ideas? 回答1: Original Answer has been superseded by CoreAnimation in iOS4. So as Gold Thumb says: you can do this by accessing the UIView's CALayer. Specifically its contentRect: From the Apple Docs: The

How to set the resolution of a saved image from the UIImagePickerController

佐手、 提交于 2019-12-05 10:53:11
问题 I'm using an UIImagePickerController to set a picture from my cameraroll to a UIImageView. However the image is getting scaled automaticly inside this UIImageView because I mentioned 'scale to fit' inside the IB. I'd like to save my chosen image with a resolution of 80x80 pixels so that I won't have to scale. (My App is getting realy slow because of this scaling issue.) Here's a snippit from my code: -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage :

iOS - can stretch a UIImageView but not a UIButton?

半世苍凉 提交于 2019-12-05 10:51:22
Behold: //UIImageView* stretchTest = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]]; //[self addSubview:stretchTest]; UIButton *stretchTest = [UIButton buttonWithType:UIButtonTypeCustom]; [stretchTest setFrame:CGRectMake(0, 0, 400, 100)]; [stretchTest setBackgroundImage:[UIImage imageNamed:@"image.png"] forState:UIControlStateNormal]; [self addSubview:stretchTest]; stretchTest.contentStretch = CGRectMake(0.5, 0.5, 0, 0); stretchTest.contentMode = UIViewContentModeScaleToFill; CGRect frame = stretchTest.frame; frame.size.height = 300; stretchTest.frame = frame; Using the

Anti Alias, UIImage and Performance

佐手、 提交于 2019-12-05 10:49:23
I have a UIImage loaded into a UIImageView . The UIImage is larger than the UIImageView and it has been scaled down to fit. Obviously the scaled down UIImage shows jagged edges. What is the best way to anti-alias this image with regards to performance? I've seen this method using drawInRect but I've also read that drawInRect does not give the best performance . I've read several different articles and I've tried a few methods myself. But after reading a few more posts on the performance differences between using UIViews and Core Graphics, I was wondering which method for anti aliasing an image

touches event handler for UIImageView

假如想象 提交于 2019-12-05 10:27:15
I am just getting stated with iPhone development and can't seem to find the answer I am looking for what I want to do. It seems like I should be able to programmatically create a UIImageView and then set up an event handler for it's touch functions. in c# i would have something that looks like Button b = new Button(); b.Click+= my handler code right now I have this CGRect myImageRect = CGRectMake(0.0f, 0.0f, 141.0f, 151.0f); UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect]; myImage.userInteractionEnabled = YES; [myImage setImage:[UIImage imageNamed:@"myImage.png"]];