uiimage

multiple setting of the image for UIImageView

Hi, Recently I've been trying to save on render time by minimizing the amount of time spent on allocation and duplication of resources as images by using an already allocated UIImageViews and UIImages. What I try to do is maintain a map of all UIImages - each one unique, and reassign each one to to several UIImageViews, by demand from ...

How can I validate an image file I download from the Web on iPhone?

I am downloading images using the NSURLConnection sendSynchronousRequest method and that works fine. However, occasionally I run into an issue where the image URL points to something other than an image file. For example, I found this non-image URL was causing issues: http://www.100plusposters.com/images/ExoticFlowers.jpg The URL ret...

Optimized Image Loading in a UIScrollView

I have a UIScrollView that has a set of images loaded side-by-side inside it. You can see an example of my app here: http://www.42restaurants.com. My problem comes in with memory usage. I want to lazy load the images as they are about to appear on the screen and unload images that aren't on screen. As you can see in the code I work out a...

UIImage from bytes held in NSString

Hi all, I am trying to create a UIImage from a byte array that is actually held within a NSString. Can someone please tell me how I can do that? Here is what I was thinking of doing: NSString *sourceString = @"mYActualBytesAREinHERe="; //get the bytes const char *bytesArray = [sourceString cStringUsingEncoding:NSASCIIStringEncoding];...

Converting a CGLayer to a *transparent* UIImage and PNG file in CoreGraphics iphone

Hi all, I've been making a simple painting app for the iphone. I'm trying to convert the drawn image to a transparent PNG (I don't want a white background). I'd also like to get a UIImage representation to use in a UIImageView. Currently, I respond to touch events and draw paths to a CGLayer which is then drawn to my views context. I h...

How to mask a UIImage so that white becomes transparent on iphone?

Hi All, I have a UIImage (generated by a user drawing) that has a white background. I'd like to make the white portions of this image transparent. I'd also like to save this to a PNG file. I've looked around on forums but can't figure out how to mask the image correctly. Has anyone tried this before? Thanks. ...

How to create a UIImage from the current graphics context?

I'd like to create a UIImage object from the current graphics context. More specifically, my use case is a view that the user can draw lines on. They may draw incrementally. After they are done, I'd like to create a UIImage to represent their drawing. Here is what drawRect: looks like for me now: - (void)drawRect:(CGRect)rect { CGCo...

Is there a nine-patch loader for iPhone?

Android has a nice way of defining stretchable images called a nine-patch. See these docs for a description of the concept. The idea is to surround a png image with a 1-pixel border where you can define the stretchable areas and the padding dimensions of the image. This is absolutely brilliant and I'd like to use the idea in my iPhone...

Any quick and dirty anti-aliasing techniques for a rotated UIImageView?

I've got a UIImageView (full frame and rectangular) that i'm rotating with a CGAffineTransform. The UIImage of the UIImageView fills the entire frame. When the image is rotated and drawn the edges appear noticeably jagged. Is there anything I can do to make it look better? It's clearly not being anti-aliased with the background. ...

Save Image to sandbox from UIImage in iPhone

Hi, I am showing very big size images in UITableView, because of this my app is getting crashed after some time. Now i want to resize the image and save it to disk. can some one help me resizing the image from NSData/UIImage and saving saving it to the disk. I got the code to resize the image from UIImage, so as the result i have my re...

SQLite + Core Data Vs. File system on Iphone App that shows photos. What's more performant?

Hello, I have an application where the user will navigate around a set of photographs. What's best in terms of performance for this scenario, SQLite + Core DATA for persisting the photos as NSData objects or having the photos as png files directly on the file system? thanks. ...

Combining images

I want to place the picked image ontop of another image, so that my picked image wil be placed in some sort of frame i made in photoshop. After combining the images i want to save it to the disk. Does anyone knows how to do it, or mayby a link to examples? ...

UIImagePNGRepresentation slow or am I doing something wrong?

I'm working on an iPhone App that uses the camera to take pictures, then I'm saving them to the Applications Documents directory. I'm using the following code to convert the UIImage to NSData, NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)]; Then I write the NSData using [imageData writeToFile:path atomical...

How to custom a UITableViewCell like the one in Photo Album app?

I'm trying to create a custom UITableViewCell but I have never done so before. I know I am supposed to subclass UITableViewCell but I need more info to start from. I want each cell to display several (2~4) UIImageViews just like is done in the Photo Album app. Has anyone done this before? Or is there a good tutorial that you know of? Ple...

How to 'Flatten' multiple UIImageViews into ONE?

I have a feeling this is not an easy task but I need to combine or flatten a UIImageView with another UIImage view lying above it. For example: I have two UIImageViews. One of them has a UIImage of a grassy field (1200 x 1200 pixels). The other is a UIImage of a basketball (128 x 128 pixels), and it is positioned above the image of the g...

How to ensure that UIImage is never released?

I grabbed the crash log from the iPhone: Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000c Crashed Thread: 0 Thread 0 Crashed: 0 libobjc.A.dylib 0x30011940 objc_msgSend + 20 1 CoreFoundation 0x30235f1e CFRelease + 98 2 UIKit ...

Interfacing blurring routine with UIImage or CGImageRef... (iPhone)

I found some blurring code at http://incubator.quasimondo.com/processing/stackblur.pde. Any ideas how to feed it, and get back, a UIImage or CGImageRef or something usable on the iPhone? I'm not sure what format their BImage file is (Bitmap?) and what corresponds to it in Cocoa Touch. Thanks. ...

Resizing UIimages pulled from the Camera also ROTATES the UIimage?

I am getting UIimages from the camera and assigning them to UIImageViews to be displayed. When I do this the camera gives me a 1200 x 1600 pixel image which I then assign to a UIImageView in my Application. The image is displayed as expected in the image view under this condition. However, when I attempt to RESIZE the retrieved UIImage b...

In a UIImage (or its derivatives), how can I replace one color with another?

For example, I have a UIImage (from which I can get a CGImage, CGLayer, etc., if needed), and I want to replace all of the red pixels (1, 0, 0) with blue (0, 0, 1). I have code to figure out which pixels are the target color (see this SO question & answer), and I can substitute the appropriate values in rawData but (a) I'm not sure how ...

UIImageView dimensions not what I set in IB

I set a UIImageView to 70x70 pixels. In the actual view they look 70px high and 30 wide. This is when there is no source UIImage set and with a background color so I can see it's layout. However, when I do set a UIImage to it the layout does not change, remains portrait. Is there something I am overlooking that affects the layout dimens...