core-graphics

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...

Releasing CGImage (CGImageRef)

I'm curious if I'm following proper memory management with CGImageRef, which I'm passing through several methods (since it's CG object, I assume it doesn't support autorelease). Memory management with non-NSObjects and interaction with other NSObjects is still somewhat new to me. Here what I'm doing: I'm creating the CGImageRef inside ...

How do I add a gradient to the text of a UILabel, but not the background?

hey, I want to be able to have a gradient fill on the text in a UILabel I know about CGGradient but i dont know how i would use it on a UILabel's text i found this on google but i cant manage to get it to work http://silverity.livejournal.com/26436.html ...

Can I edit the pixels of the UIImage's property CGImage

UIImage has a read-only property CGImage. I have to read its pixels to a memory block and edit them and then make a new UIImage to replace the old one. I want to know if there is a way bypass the read-only property and edit those pixels directly. Thanks. Thanks all. I have found a way to do it. Write a class with those method: -(vo...

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...

How to use a CGLayer to draw multiple images offscreen

Ultimately I'm working on a box blur function for use on iPhone. That function would take a UIImage and draw transparent copies, first to the sides, then take that image and draw transparent copies above and below, returning a nicely blurred image. Reading the Drawing with Quartz 2D Programming Guide, it recommends using CGLayers for ...

How do I draw a point inside of an instance of UIImageView?

How do I use Core Graphics to draw inside of a instantiated UIImageView (No class files to override drawrect with -- just a reference to the instance)? I want to draw a simple point of fixed width (say, 10 pixels diameter) and of a certain color. ...

How to prevent drawings to a UIView context from dissappearing?

I'd like to create a simple fingerpainting feature in my app. Problem is any drawings I do to my UIView subclass view instance are erased after each drawRect call... How do you go about preserving your context drawings in your UIViews? ...

Trying to set unique CoreGraphics (iphone) States for each Stroke...

I've got a number of 'line' objects -- each storing information about a line drawn using Core Graphics. The problem is, that though there may be several line objects each having a unique color and stroke width, all lines are getting drawn under the SAME color and stroke width. Each line object has attributes such as stroke color, strok...

Drawing woes with CALayer.

First of all, im finding the iPhone online docs to be not-so-very thoroughly clear when it comes to the various ways of rendering a layer. I get the jist of it, but im not clear when to use which methods and which requires the layer to be added as a sub layer or not. My project started off trivially with me loading images and simply dra...

CGImageRef in OS X application?

Hi, I have a .c code snipped that I don't want to port to Objective-C. This .c file worked on the iPhone platform, but not on OS X. It seems that the compiler doesn't know what to do with #import <CoreGraphics/CoreGraphics.h> and so it doesn't know CGImageRef: ImageArray3D *ia3d_createWithCGImage(CGImageRef image, int nLargestEleme...

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 is the fastest way to implement a UIView background?

Hi, I have an UIView which I want to give a gradient background and I'm wondering how to implement that as efficient as possible. I am considering three options: Create an UIImageView as subview and give it an image of the gradient to display. Draw the gradient image in drawRect: of the original UIView. Draw the gradient in drawRect:...

Saving CGImageRef to a png file?

Hi, in my Cocoa application, I load a .jpg file from disk, manipulate it. Now it needs to be written to disk as a .png file. How can you do that? Thanks for your help! ...

How to get UIImage from texture of an EAGLView?

I am trying to get a UIImage from a texture I loaded into EAGLView using the following way: //Try to get UIImage from EAGLView and assign to imageDataPhoto1 UIGraphicsBeginImageContext(myEAGLView.bounds.size); [myEAGLView.layer renderInContext:UIGraphicsGetCurrentContext()]; imageDataPhoto1 = UIGraphicsGetImageFromCurrentImageContext()...

Any way to BRIGHTEN a UIImage without using OpenGL ES?

Does anyone know of a way to simply and effectively brighten a UIImage by a specific amount? I am currently fiddling with the Apple Sample Code Example GLImageProcessing with poor results...My app currently does not use OpenGLES or EAGLViews and it is awkward trying to bridge the technology. ...

How can I iterate on RGBA of EACH pixel in a bitmap context?

How do I iterate on EACH PIXEL in a bitmap context? I found some source that seems to be attempting to do this but it is somehow flawed. Can someone tell me how to fix this code so that I can iterate on the RGBA of each pixel? -(UIImage*)modifyPixels:(UIImage*)originalImage { NSData* pixelData = (NSData*)CGDataProviderCopyData(CGImageG...

Core Graphics has poor PIXEL iteration performance on iPhone?

I am trying to do an iteration on pixels to change the RGBA values of a UIImage without using OpenGL. I tried testing out iteration performance using the below code but was very displeased. It seemed like I could only get a few thousand iterations per second. And for a UIImage with several hundred thousand pixels, this would take way TOO...

Improving Finger Painting Performance...

Simple Painting: Fingering the iPhone screen paints temporary graphics to a UIView. These temporary graphics are erased after a touch ends, and are then stored into an underlying UIView. The process is simple: 1) Touch Starts & Moves >> 2) Paint Temporary Graphics on top UIView>> 3) Touch Ends >> 4) Pass Temporary Graphics To under...

Quartz/CG: Draw a filled path where each line has a different stroke?

What's the best practice for drawing a closed, filled path where each line has a different stroke? ...