uiimage

stretchableImageWithLeftCapWidth:topCapHeight doesn't work in initWithCoder: of UIImageView subclass

I have a UIImageView subclass called ShadowView, which displays a shadow that can be used under anything. ShadowViews are to be loaded from a nib. In initWithCoder:, I have the following code: - (id)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (self != nil) { UIImage *shadowImage = [[UIImage ...

Subclassing UIImage and adding to UIImageView

Can anyone help me with this. I need to do custom drawing code in -drawRect so I subclassed UIImage. How would I initialize my custom UIImage with an image? Say I override the imageName method, what would I need to do in this method? After initializing can I add it to a UIImageview like so initwithImage:? ...

How to store an image using NSData in Objective C

How do I take a UIImage and store it preferably as NSData (to write to a file)? Is there some obvious method out there, or could someone provide a code snippet? Thanks in advance! PS. My next question will probably be for a code snippet to capture the current screen image. The snippets I've seen so far appear to be serious overkill f...

UIImagePickerController, UIImage, Memory and More!

I've noticed that there are many questions about how to handle UIImage objects, especially in conjunction with UIImagePickerController and then displaying it in a view (usually a UIImageView). Here is a collection of common questions and their answers. Feel free to edit and add your own. I obviously learnt all this information from some...

CAShaperLayer -renderInContext Doesn't Work?

I am able to create a UIImage from a Core Animation layer using the following code: - (UIImage*)contentsImage; { UIGraphicsBeginImageContext([self bounds].size); [self renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }...

Getting Image from URL/server

Hi All, I'm fairly new to iPhone development and I'm trying to fetch 'Images from Server' in my application. I'm using the following method to do this: enter code here - (UIImage *)imageFromURLString:(NSString *)urlString { NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [[NSMutableURLRequest al...

Is there an optimal way to render images in cocoa? Im using setNeedsDisplay.

Currently, any time I manually move a UIImage (via handling the touchesMoved event) the last thing I call in that event is [self setNeedsDisplay], which effectively redraws the entire view. My images are also being animated, so every time a frame of animation changes, i have to call setNeedsDisplay. I find this to be horrific since I d...

Memory managment when drawing to a view on the iPhone

Hey guys, I have a UIImage that I'm instantiating using imageWithData: (the data is loaded from the bundle using [NSData dataWithContentsOfFile:]). I'm then drawing the image like so: NSData *imageData = [NSData dataWithContentsOfFile:fileLocation]; UIImage *myImage = [UIImage imageWithData:imageData]; //These lines are superfluous ...

get size of a uiimage (bytes length) not height and width

I'm trying to get the length of a UIImage. Not the width or height of the image, but the size of the data. Thank you. ...

Stretching An Image in Tableview

What else is needed to display image to full tableview width? UIImage *image = [UIImage imageNamed:@"balloon_2.png"]; [image stretchableImageWithLeftCapWidth:15 topCapHeight:13]; cell.image = image; ...

How to Rotate a UIImage 90 degrees?

I have a UIImage that is UIImageOrientationUp (portrait) that I would like to rotate counter-clockwise by 90 degrees (to landscape). I don't want to use a CGAffineTransform. I want the pixels of the UIImage to actually shift position. I am using a block of code (shown below) originally intended to resize a UIImage to do this. I set a tar...

What happens behind-the-scenes when I create a new UIImage by assignment?

I am getting errors of type EXC-BAD-ACCESS where I create a new UIImage instance by assigning the value of a pre-existing UIImage (as below) and I am trying to figure out what the problem is. There is a heap of code to sort through and I am not sure where to start so I won't bother posting source -- but it might help me in my investigati...

How can to launch the Mail app from within my app?

How do I launch the iPhone Mail app (with a Photo attachment) from within my app? (Photo is a UIImage in my app). ...

[Iphone] FBConnect : send some images on somebody's wall

Hello I found out how to send some text on the user's wall, with the FBConnect API, on iphone. I even found how to put an image already on the internet : FBFeedDialog* dialog = [[[FBFeedDialog alloc] init] autorelease]; dialog.delegate = self; dialog.templateBundleId = 12345; dialog.templateData = @"{\"image\":[{\"src\":\"http://sample...

iPhone Objective C: UIImage - Region of Interest

Is there any way to get the min rectangle area which contains all the non-transparent part of an UIImage? Reading pixel by pixel to check where alpha == 0 ...isn't a good way I believe. Any better way? Many thanks for reading ...

Does UIImage's -imageNamed: method work for image files stored in 'Documents'?

My app downloads a small image file from a remote server and I am trying to display it along with some other small image files that are pre-installed in the app. I am using [UIImage imageNamed:@"TheImageName.png"] to get the images (see below for more detail). The pre-installed images display as expected but the image in my apps 'Documen...

How to save a UIImage to the application's Bundle?

I am currently getting images from the 'Documents' directory (using -imageWithContentsOfFile:) with no problems except that I cannot get the images to display immediately (for example as soon as touchesEnded was called). I am assuming that this has to do with image caching and that image objects created in the above way are not cached? S...

Any way to get a Cached UIImage from my 'Documents' directory?

I know that the -imageNamed: method returns a Cached UIImage, but the problem is that my image file is stored in 'Documents', and the -imageNamed: method seems to only search the Bundle... I am currently (reluctantly) using -imageWithContentsOfFile: to get my image from 'Documents' but it is not the same...Scaling up/down a UIImageView c...

How to draw a shape on top of a UIImage while respecting the image's alpha mask

I need a UIImageView that can draw itself in color or b/w according to a flag: BOOL isGrey; I'm trying to do it by drawing a black rectangle on top of the original image with the Quartz blendmode set to Color. This works except it doesn't respect the image's alpha mask. See illustration: Searching Google and SO, I found and tried...

What could a leaked UIImage of size 16 Bytes indicate?

16 Bytes is pretty small, right? None of the UIImages I create in my app are that small, yet the Leaks Instrument is reporting a leaked UIimage of size 16 Bytes... Any clues on what this could be? Incidentally, there was also a leaked CALayer object of 48 bytes... ...