core-graphics

Overriding drawRect: and pushing new offset CGContexts onto the stack

I have overridden the drawRect: in my UIView and I want to draw several tiles. I'm looping through them all and I have a separate function that draws each individual tile. The way I'm doing it now is I pass the tile's calculated CGRect to the function. At the moment, any drawing methods have to include the x & y offsets of the rect pass...

Blending Three Images into Graphics Context Using Alpha Blend Mode kBlendModeOverlay

Does kCGBlendModeOverlay not work exactly like Photoshop's Overlay blending mode? I'm trying to overlay three images into a graphic context via: [uiimageGreen drawAtPoint:CGPointMake(x, y) blendMode:kCGBlendModeOverlay alpha:1.0]; [uiimageRed drawAtPoint:CGPointMake(x, y) blendMode:kCGBlendModeOverlay alpha:1.0]; [uiimageBlue drawAtPoin...

Learning Graphics Framework for iPhone Development

I have some development experience of CocoaTouch Layer, Core Service Layer iPhone Applications. Now, I have to migrate for some pure 2d and 3d graphical iPhone Applications. For that as per my knowledge, I need following frameworks to learn : 1) Core Graphics 2) OpenGL ES 3) Quartz Core I want to know that what should be the approach...

ColorMap in iPhone Core Graphics?

Hey guys! I have a monochrome image with 256 levels of grayscale. I want to map each level to a specific color and apply to the image to get a colored image as a result. How can I do it? To be more precise here is the pair in Java 2D API that I need to find replacement for: http://java.sun.com/javase/6/docs/api/java/awt/image/Lookup...

draw In Seperate layers-objective c core graphics

Hi All, Im developing a charting application for the iphone using core graphics. My requirement is as follows. I've implemented my all the drawing functions inside the drawRect method. when some update happen in the chart, i need to call [self setNeedsDisplay:true] and it invokes the drawRect method from the begining.(means it executes a...

Drawing a line between one CGPoint and another.

I have 2 CGPoints and a would like to draw straight line between them, how would I do this? ...

Loading image into OpenGL ES from c++ code in iPhone

Hi, I'm creating an iPhone game and I need to load an image from a PNG file into OpenGL (and bind it as a texture). I'm using function glTexImage2D to achieve this goal. I know how to load an image into OpenGL using UIImage (by converting it into CGImage and afterwards drawing into a context). How can I call my Objective-C code from w...

Why are the corners of my UIImage being cut when I rotate it?

hi all i rotate my UIImage for crop. when i am rotate my image it just cuts from corners here my code. -(UIImage*)imageLeftRotation:(UIImage*) newImage size:(CGSize) imgSize angle:(int) rotateAngle{ UIImage *image = newImage; CGImageRef imgRef = image.CGImage; CGFloat width = CGImageGetWidth(imgRef); CGFloat height = C...

How to draw a native looking statusitem background on a CALayer

Hi. Actually I want to draw the background of a selected NSStatusItem on the CALayer of my custom statusItemView. But since - (void)drawStatusBarBackgroundInRect:(NSRect)rect withHighlight:(BOOL)highlight does not work (?) on layers I've tried it to draw the color with the backgroundColor property. But converting the selectedMenuIte...

How to dump CALayer into CGImageRef?

Hello, I have some custom, CoreAnimation based UI. I'd like to implement mouse dragging of certain CALayers and I'd like to stick an image of dragged layer to the cursor. The problem is, that I can't get the CALayer (which isn't image/.contents based) into an image of some kind - like CGImageRef or NSImage. Any ideas? ...

Flatten CALayer sublayers into one layer

In my app I have one root layer, and many images which are sublayers of rootLayer. I'd like to flatten all the sublayers of rootLayer into one layer/image, that don't have any sublayers. I think I should do this by drawing all sublayers in core graphics context, but I don't know how to do that. I hope you'll understand me, and sorry for...

How to get each pixel coordinates of any shape in iPhone

I am using UIView subclass to draw an alphabet using QuartzCore Framework.Using this code only hollow characters are drawn(By Making the stroke color- blue color).Here I need each pixel position (coordinates) of the character that is added on current view.Please give me an idea how I will get each pixel point coordinates(Only the blue po...

How do I determine the location of each pixel in a square drawn via Core Graphics?

Hi, I am trying to get each pixel point of a Square drawn using Core graphics.Here by making the stroke color black color,I am drawing the Square.Please give me an idea how I will get all pixel point on which this square is drawn. - (void)drawRect:(CGRect)rect { CGMutablePathRef path = CGPathCreateMutable(); CGContextRef ctx =...

Drawing a text along a path in QuartzCore

Say I have an array of points that form a line and a text. How can I go about drawing the text along this line in - (void)drawRect:(CGRect)rect of a UIView? I am able to draw the path without a problem. Is there a standard method that I overlooked or a framework that would allow me to draw the text along that path? Ideally I woul...

How to deal with image resizing for different orientations

I've been following this excellent resource here: http://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more and based some of my code off it. But can't seem to get my head around how to accomplish what I want to do. Basically, I want to take any image from the iPhone (landscape or portrait) and display ...

Problem drawing with core graphics

I'm trying to speed up my drawing code. Instead of creating a graphics context, drawing the current image into it, and drawing over it, I'm trying to create a context using some pixel data, and just modify that directly. The problem is, I'm pretty new to core graphics and I can't create the initial image. I want just a solid red image, b...

hardware acceleration / performance and linkage of different macosx graphics apis, frameworks and layers

the more i read about the different type of views/context/rendering backends, the more i get confused. regarding to http://en.wikipedia.org/wiki/Quartz_%28graphics_layer%29 MacOSX offers Quartz (Extreme) as a render-backend which itself is part of Core Graphics. in the Apple docs and in some books too they say that in any case somehow y...

What's the right memory management pattern for buffer->CGImageRef->UIImage ?

I have a function that takes some bitmap data and returns a UIImage * from it. It looks something like so: UIImage * makeAnImage() { unsigned char * pixels = malloc(...); // ... CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, pixels, pixelBufferSize, NULL); CGImageRef imageRef = CGImageCreate(..., provid...

Is there a penalty for mixing color spaces? (Core Graphics)

If I'm writing drawing code in Core Graphics on Mac OS X or iPhone OS, I can set the active fill color to red by calling: CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0); // RGB(1,0,0) If I want 50% gray, I could call: CGContextSetRGBFillColor(context, 0.5, 0.5, 0.5, 1.0); // RGB(0.5,0.5,0.5) But for shades of gray it's tempt...

setNeedsDisplayInRect redrawing entire view when using CATiledLayer

Hi all, this is my first time posting so please excuse any lapses in stackoverflow etiquette. I haven't found any example code or any questions that address the problem I'm having, so hopefully someone can shed some light on this. I'm using Quartz and I have a CATiledLayer on which I have drawn several boxes you can click on. When y...