core-graphics

How can I read binary image file using Core Graphics?

I created an image in Matlab and changed it into binary image file. I want to read in the file using Core Graphics APIs. Thanks ...

Xcode Error

i am getting this error "_CGRectZero", referenced from: _CGRectZero$non_lazy_ptr in RootViewController.o _CGRectZero$non_lazy_ptr in SecondViewController.o ld: symbol(s) not found collect2: ld returned 1 exit status Build failed (1 error) could someone tell me a solution to solve this? ...

Extracting rgb from UIColor

Seen this asked before but my example does not seem to work. const CGFloat *toCol = CGColorGetComponents([[UIColor greenColor] CGColor]); The array is empty from looking at it with GDB. Any hints? ...

Overlapping and touching CoreGraphics rectangles have a .5px border

My core graphics fills are acting strange when the get close together, touching or overlapping. This issue is on the iPhone Simulator and iPhone OS 2.2. Here we have two labels and a custom view with two CGContextFillRect(): overlap problem When the blue and red are brought together they develop this irritating .5px merging line. I c...

How can I get all points in CGPath curve or quad curve

Hi, I have made a quad curve path using the method CGPathAddQuadCurveToPoint. I got the path perfectly. But, I want to know all the coordinate points which are participated in the path. Is there a way to retrieve all the coordinate points in a path? If not do u have any other solution for retrieving all the points in a curve mathemat...

What kind of data is size_t holding?

In a code-snippet I have seen this: size_t w = CGImageGetWidth(inImage); The docs don't give me any useful info about "size_t". Does anyone know what this is? ...

How can I find out how many bytes one pixel has in an CGImageRef?

The doc is mentioning an CGBitmapContextGetBitsPerPixel(). I am almost sure that I would just have to divide this by 8. But since I didnt study computer science, I am confused about the detail. Would it make a difference if it's an 8 bit PNG or 24 bit PNG? Or some other PNG? So to get securely the bytes per pixel of an CGContextRef, wo...

How can I obtain clean alpha channel information from an PNG image in iPhone OS?

I have created an context like this (simplified): CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate (bitmapData, pixWide, pixHeigh, 8, // bits per component bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedFirst); Now, when I try to extract the data for the fi...

How many bits per component do I have to specify for pngcrunch-optimized 24bit PNG files with alphatransparency?

CGBitmapContextCreate takes an parameter that's not very obvious to me: For example, for a 32-bit pixel format and an RGB color space, you would specify a value of 8 bits per component. I have created 24-bit PNG files with alphatransparency, and added them to Xcode. At compile time, Xcode optimizes those PNG tiles with pngcru...

How does the coordinate system in an CGContextRef look like?

I assume that the origin is on the bottom left, and the y-axis expands up, starting from 0. The x-axis expands to the right, starting from 0. I just ask because I get very weird results from my drawing code... want to make sure that I didn't get this part wrong. ...

Just in theory: How is the alpha component premultiplied into the other components of an PNG in iPhone OS, and how can it be unpremultiplied properly?

Actually, I thought that there would be an easy way to achieve that. What I need is pure alpha value information. For testing, I have a 50 x 55 px PNG, where on every edge a 5x5 pixel rectangle is fully transparent. In these areas alpha has to be 0.Everywhere else it has to be 255. I made very sure that my PNG is created correctly, and i...

How can I draw an CGImageRef context on the screen?

I have a beautiful CGImageRef context, which I created the whole day to get alpha values ;) It's defined like that: CGContextRef context = CGBitmapContextCreate (bitmapData, pixWidth, pixHeiht 8, pixWidth, NULL, kCGImageAlphaOnly); So for my understanding, that context represents somehow my image. But "virtually", non-visible somewhe...

iPhone SDK: How to Draw a Rounded Rectangle With a Semi-Transparent Gradient and a Drop Shadow

I'm experimenting with drawing on the iPhone by manually creating parts of the UI for my application (In this case a graph). Essentially, I want to draw a rectangle with rounded corners, a drop-shadow, and a semi-transparent gradient as the fill of the rectangle. Here is a screen shot of my photoshop mockup: I've gotten has far as crea...

Anomalous results getting color components of some UIColors

I'm trying to extract the rgb components of a UIColor in order to hand-build the pixels in a CGBitmapContext. The following sample code works fine for most of the UIColor constants but, confusingly, not all. To wit: CGColorRef color = [[UIColor yellowColor] CGColor]; const float* rgba = CGColorGetComponents(color); float r = rgba[0]; f...

Animate the drawing of a line (Quartz 2D?)

How would you go about animating the drawing of a line in a UIView on the iPhone? Is this possible? It can be drawn but can it easily be animated so it appears to be hand drawn? ...

Why does my Quartz arcs display thicker than the straight lines?

Hi! I'm trying to create a custom UIButton that should look like a UIButtonTypeRoundedRect. In my drawRect:, I'm creating a path with first one call to CGContextMoveToPoint() and then four calls to CGContextAddArc(). I then stroke the path. However, in the resulting image the four rounded corners are clearly thicker than the rest of the...

NStimer slow when use CGContextClipToRect in iphone device

I am new to iphone development. I used NSTimer scheduledTimerWithTimeInterval 0.01 seconds for game loop. The game consists drawscreen function inwhich I use CGContextClipToRect to clip the large images for animation. But the speed 0.01 seconds is working in simulator only not in the iphone(device). How can i overcome this problem? I res...

How can I move an rotated view relative to the coordinate system of it's superview?

When changing the center point of an 10 degrees rotated view, the specified coordinates for the center point will not match the coordinate system of the superview. As an example, when you want to go straight up by y - 50, and no horizontal movement (i.e. x = theRotatedView.center.x), the shift in y-direction will be rotated. The view wi...

How to create bubbble message box similar to iPhone buildin SMS app?

How to create bubbble message box similar to iPhone buildin SMS app? I'm trying to create a table cells with a bubble message box, similar to the iPhone SMS app or iChat. Anybody have example code I can refer to? ...

Point not in Rect but CGRectContainsPoint says yes

If I have a UIImageView and want to know if a user has tapped the image. In touchesBegan, I do the following but always end up in the first conditional. The window is in portrait mode and the image is at the bottom. I can tap in the upper right of the window and still go into the first condition, which seems very incorrect. - (void)t...