core-graphics

Put border around partially transparent Image being drawn on CGContext

倾然丶 夕夏残阳落幕 提交于 2019-12-03 18:24:25
问题 I have an image with a yellow vase in the foreground and transparent background: I'm drawing it on a CGContext: CGContextDrawImage(context, CGRectMake(0, 0, 100, 100), myImage.CGImage); I can draw a shadow around it by using the following statement before CGContextDrawImage : CGContextSetShadowWithColor(context, CGSizeMake(0,0), 5, [UIColor blueColor].CGColor); But I want to put a stroke around the image, so that it'll looks like following: If I did this: CGContextSetRGBStrokeColor

CGContext text drawing doesn't scale up on iPhone 4

▼魔方 西西 提交于 2019-12-03 17:39:19
问题 I am trying to create an app that scales up nicely on the iPhone 4. Currently most of it scales up perfectly, except for one crucial piece: the text that I draw inside a CALayer, inside its drawInContext: method. Here is my code: - (void)drawInContext:(CGContextRef)context { UIGraphicsPushContext(context); CGContextSetGrayFillColor(context, 1.0f, 1.0f); CGContextFillRect(context, self.bounds); CGContextSetAllowsAntialiasing(context, true); CGContextSetShouldAntialias(context, true);

Create the indented look found in UINavigationBarButton - programmatically

╄→гoц情女王★ 提交于 2019-12-03 17:16:48
I'm trying to programmatically recreate the indented button look that can be seen on a UINavigationBarButton. Not the shiny two tone look or the gradient, just the perimeter shading: It looks like an internal dark shadowing around the entire view perimeter, slightly darker at the top? And then an external highlighting shadow around the lower view perimeter. I've played a bit with Core Graphics, and experimented with QuartzCore and shadowing with view.layer.shadowRadius and .shadowOffset, but can't even get the lower highlighting to look right. I'm also not sure where to start to achieve both a

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

末鹿安然 提交于 2019-12-03 17:12:36
问题 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(..., provider, ...); UIImage * image = [[UIImage alloc] initWithCGImage:imageRef]; return [image autorelease]; } Can anyone explain exactly who owns what memory here? I want to clean up

draw a line by using CGPath [closed]

泄露秘密 提交于 2019-12-03 17:04:42
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . How can I draw a line by using CGPath ? 回答1: As you didn't really specify more than how to draw a line with a path, I'll just give you an example. Drawing a diagonal line between the top left corner and the

ios - Drawing Brush from finger toches moves

匆匆过客 提交于 2019-12-03 16:55:44
i want to draw in my iPad app as in the following image in my app i have placed a image and while moving the finger(touch movement) i am repeating the images, but my image seems to be as follows. Following is my code to draw the image CGBlendMode blendMode = kCGBlendModeColorDodge; UIGraphicsBeginImageContext(drawImage.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); //// NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"Watercolor-edge-45x45.png

iPhone Performance Differences in Quartz Drawing vs. Pre-Baked Images (which I guess simplifies to Quartz vs. Quartz)

允我心安 提交于 2019-12-03 16:54:02
New to Quartz and I am curious on the drawing speeds of simple shapes, gradients, and shadows; specifically comparing Quartz drawing functions to Quartz image drawing on the iPhone. Say that I need to draw a filled, stroked, and shadowed rectangle. I'm assuming that importing a pre-baked rect as a PNG and drawing it using drawInRect: or drawAtPoint: is faster than using Quartz's drawing functions to draw the same thing, since the latter requires explicit calculations. On the other hand, drawing an image I assume increases memory use and application size since I have to import the image and

Flattening a CGPath

血红的双手。 提交于 2019-12-03 16:39:46
Simply put, I'm looking for an equivalent to NSBezierPath's -bezierPathByFlatteningPath that can be used on iOS. It doesn't matter to me whether this is a function dealing directly with a CGPath or a method on UIBezierPath, because the two can easily be converted back and forth. Neither the CGPath Reference nor the UIBezierPath Class Reference indicate the presence of any such function or method. Also: I'm aware of CGPath's CGPathApply function, and I lack both the time and the skill-set to implement my own flattening algorithm by iterating over the path's elements in a CGPathApplierFunction .

Mac OS X Window Server vs. X11: the insane task

岁酱吖の 提交于 2019-12-03 16:29:53
Dedicated to all who likes low-level Window Server (CoreGraphicsPrivate.h, etc), X11 on Mac, SIMBL and other crazy stuff :) There's a simple X11-emulated application on Mac (like xterm, xeyes and so on) with one window. While running, X11 somehow creates a native Quartz window to represent this emulated application, and this window is accessible via Quartz Window Services so that I can get its CSWindowID, title, position, size and owner's PID (PID of X11.app). But it does not support Accessibility API, so there's no way to control it (except, maybe Core Graphichs private functions from the

What is different between CoreGraphics and CoreAnimation?

耗尽温柔 提交于 2019-12-03 16:05:12
I am developing iphone game using coregraphics. but the speed is very slow. I could not play my game.. So, I googled a lot.. During the googling, I found the belows. CoreGraphics, CoreAnimation, OpenGL ES, CALayer, Quartz 2D I am so confused between them. Someone told me coregraphics is not using GPU. Some told me it is using GPU. coregraphics is best or openGL is best, calayer is better. ^^;;;; What is different between them and which one is using GPU?? Which one is the best to make a game. I have many image to draw. Please let me know..... Thanks in advance. The iOS graphics APIs are layered