core-graphics

iPhone + CGAffineTransFormRotate(pi/2) + statusBarHidden:YES + presentModalViewController = 20 pixels of white space

I think the title is pretty descriptive: I perform all 3 of these operations on a view, the result is 20 pixels of white space along the left side of the screen (if holding the iPhone is landscapeLeft). I tried to fix it by performing a CGAffineTransFormTranslate(transform, -20, 0) That just "slides" the view underneath the whitespace...

CATransform3D vs. CGAffineTransform?

Whats the difference between the two? I'm sure they have pros and cons, and situations they are better performers in. Any resources that compare the two? Is one better for animation (I imagine the CATransform3D)? Why? Also I think I read somewhere that text clarity can be an issue, is one better at scaling text? ...

UIImage: Resize, then Crop

I've been bashing my face into this one for literally days now, and even though I feel constantly that I am right on the edge of revelation, I simply cannot achieve my goal. I thought, ahead of time in the conceptual phases of my design, that it would be a trivial matter to grab a image from the iPhone's camera or library, scale it down...

iPhone, how do you draw from a texturepage using coregraphics?

Hi, I'm trying to work out how to draw from a TexturePage using CoreGraphics. Given a texture page (CGImageRef) which contains multiple 64x64 packed textures, how do I render sub areas from that page onto the device context. CGContextDrawImage seems to only take a destination rect. I noticed CGImageCreateWithImageInRect, however this ...

How to make one color transparent on a UIImage?

On my iPhone app I have a UIImage instance. I want to get a derived a UIImage that is the result of the first UIImage where one of its colors (e.g. magenta) is made transparent. How can I do this? ...

draw a line in UIImageView problem

In my application i can draw a line in a UIImageView by the code below,and i want redraw the line even longer when i call the function,however,the output come out is not as expected,it will just draw a new line and remove the old one,the length is remain the same jus the y position different,i dont know which line of my code is wrong or ...

Using Core Graphics/ Cocoa, can you draw to a bitmap context from a background thread?

I'm drawing offscreen to a CGContext created using CGBitmapContextCreate, then later generating a CGImage from it with CGBitmapContextCreateImage and drawing that onto my view in drawRect (I'm also drawing some other stuff on top of that - this is an exercise in isolating different levels of variability and complexity). This all works f...

JPEG Quality when creating a JPEG in Carbon

I'm writing a Carbon application and we are creating JPEG files. I'm currently doing this by using Quartz CGImageDestinations and kCGImagePropertyJFIFDictionary. However, JFIF doesn't seem to have any entry for compression quality. Does anyone know how to set this? thanks ...

CoreGraphics on iPhone, trying to draw a "pill" type ellipse

I'm trying to draw a pill type ellipse, as in Apple's Mail application which displays the number of emails in the inbox. Any idea why the following isn't drawing? - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGFloat minX = CGRectGetMinX(rect); CGFloat minY = CGRectGetMinY(rect); CGFloat ...

How can I clear the corners outside of a rounded rect using the iPhone SDK?

I am attempting to implement a custom view. This view should display an image surrounded by a gray, rounded rect border. I can get the image to display fine, as well as the border, however, since the border has rounded corners, I need a way to clear those corners such that they correctly display whatever is behind the view. How can I acc...

Why does the iphone CGImageCreate with data from standard BMP bits give the wrong result?

hi,everybody: i have a gdi engine that result in the standard bmp bits stream ,and now i wanna to display it by the CG in iphone , i use it like this: // size -> image size // rect -> current view rect // pBits -> the BITMAPINFO image bits stream long imgSizePerRow = ((long)(24 * size.width + 31) / 32) * 4; CGDataProviderRef provid...

When is a CGBitmapContext not a BitmapContext?

I have a CGContext that I create with CreateARGBBitmapContext from here. When I do CGBitmapContextGetBitsPerComponent it tells me 8 bits per component (Which is correct) However, when I do CGBitmapContextGetBitmapInfo or CGBitmapContextGetData, I get NULL. Those are only supposed to give NULL when the context isn't a bitmap context. How...

Black and White graphics context

I'm working in Quartz/Core-graphics. I'm trying to create a black and white, 1b per pixel graphics context. I currently have a CGImageRef with a grayscale image (which is really black and white). I want to draw it into a black and white BitmapContext so I can get the bitmap out and compress it with CCITT-group 4. (For some reason Quart...

Producing CCITT compressed TIFF from CGImage

I have a CGImage (core graphics, C/C++). It's grayscale. Well, originally it was B/W, but the CGImage may be RGB. That shouldn't matter. I want to create a CCITT-Group 4 TIFF. I can create an LZW TIFF (grayscale or color) via creating a destination with the correct dictionary and adding the image in. No problem. However, there doesn't...

Graphics, UIKit, Core Animation, Quartz, Core Graphics on the iPhone. SO confusing!

My problem is this: I have a simple block image that I want to make a grid out of. I have created an array of CGPoints in my UIView. Then I used blackImage = [UIImage imageNamed:@"black.png"]; and then - (void)drawRect:(CGRect)rect { for (int j = 0 ; j <= 11; j++) { for (int i = 0 ; i <= 7; i++) { [blac...

How do I get the visibleRect Rectangle out of an UIImageView?

Actually that should work, but it doesnt: CALayer *myLayer = [myUIImageView layer]; CGRect visRect = [myLayer visibleRect]; I get an "invalid initializer" error, although my view is loaded definitely since in the next few lines I obtain the frame from the view and move the view around. But under no circumstances I can obtain that visi...

When Apple talks about "graphics state", do they mean the graphik I create or do they mean the settings I use?

They say, that there is a Stack that saves graphic states. Well, I am not sure what they mean by that term. Does the CGContextSaveGState save the current drawing I made, or does it save the drawing settings I currently have, like color, line width, font size, etc.? ...

What does CGColorGetComponents() return?

CGFloat* colors = CGColorGetComponents(hsbaColor.CGColor); Does this return a float, or an array of floats? It looks like the asterisk is shorthand for creating an array. Is that correct? When I call this function on the CGColor property of an HSB UIColor object does it convert the values to RGB? ...

How do I draw a shadow under a UIView?

I'm trying to draw a shadow under the bottom edge of a UIView in Cocoa Touch. I understand that I should use CGContextSetShadow() to draw the shadow, but the Quartz 2D programming guide is a little vague: Save the graphics state. Call the function CGContextSetShadow, passing the appropriate values. Perform all the drawing to which you ...

Creating a quick look style zooming effect

I would like to create an effect than an image zooms up from a thumbnail size to full screen. I am not sure what's the right steps to achieve this. Should I create a transparent full screen window and animate a layer on top of it? ...