core-graphics

Can't draw shadow after clipping

房东的猫 提交于 2019-12-13 05:13:59
问题 I needed to draw a shadow around photos of users. I drew those circle photos by drawing a circle and then clipping the context. Here's the snippet of my code: + (UIImage*)roundImage:(UIImage*)img imageView:(UIImageView*)imageView withShadow:(BOOL)shadow { UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, [UIScreen mainScreen].scale); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextAddEllipseInRect(context, CGRectMake(0,0, imageView.width, imageView.height));

Drawing getting pixelated in iOS

无人久伴 提交于 2019-12-13 05:08:53
问题 I am working on a drawing application, I am drawing into CGlayers , I am creating a CGlayer this way -(void)drawRect { if(self.DrawingLayer == nil) { CGFloat scale = self.contentScaleFactor; CGRect bounds = CGRectMake(0, 0, self.bounds.size.width * scale, self.bounds.size.height * scale); CGLayerRef layer = CGLayerCreateWithContext(context, bounds.size, NULL); CGContextRef layerContext = CGLayerGetContext(layer); CGContextScaleCTM(layerContext, scale, scale); self.DrawingLayer = layer; }

core text view memory leak

丶灬走出姿态 提交于 2019-12-13 04:23:34
问题 I have created a core text view and visually it's working great but i run it for 30 minutes with a lot of data coming in and it crashes. The debugger starts saying 'received memory warning'. I think the views i'm drawing that refresh on every new line that comes in from telnet, are not leaving memory on a redraw completely. code below. The first part of this code might be an issue. I found on a redraw i had to clear the old views or it over layed or drew on top and text got garbled. But it

How do i draw this arc (image included) using core graphics?

一世执手 提交于 2019-12-13 04:20:35
问题 I have this code so far: CGPoint midLeft = CGPointMake(0, additionalHeight); CGPoint bottomCenter = CGPointMake(self.bounds.size.width / 2, self.bounds.size.height); CGPoint midRight = CGPointMake(self.bounds.size.width, additionalHeight); CGPoint topRight = CGPointMake(self.bounds.size.width, 0); CGPoint topLeft = CGPointMake(0, 0); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextMoveToPoint(context, midLeft.x, midLeft.y); CGContextAddLineToPoint(context, midRight.x, midRight

Transparency in CGContext

◇◆丶佛笑我妖孽 提交于 2019-12-13 04:06:16
问题 I'm trying to set a transparent background for a CGContext but keep getting : CGBitmapContextCreateImage: invalid context 0x0 Here's what I've got. If I switch kCGImageAlphaLast to kCGImageAlphaNoneSkipFirst it works but the alpha channel is completely ignored. I'm very new to this color & context stuff - any ideas? -(BOOL) initContext:(CGSize)size { int bitmapByteCount; int bitmapBytesPerRow; bitmapBytesPerRow = (size.width * 4); bitmapByteCount = (bitmapBytesPerRow * size.height);

Create CGContext for CGLayer

99封情书 提交于 2019-12-13 03:36:32
问题 I want to pre-render some graphics into CGLayer for fast drawing in future. I found that CGLayerCreateWithContext requires a CGContext parameter. It can be easily found in drawRect: method. But I need to create a CGLayer outside of drawRect: . Where should I get CGContext ? Should I simply create temporary CGBitmapContext and use it? UPDATE: I need to create CGLayer outside of drawRect: because I want to initialize CGLayer before it is rendered. It is possible to init once on first drawRect

Changing grouped tables border radius

吃可爱长大的小学妹 提交于 2019-12-13 02:58:27
问题 Is it possible to change how radius of the grouped UITableView? The rounded corners are way to drastic for my design. 回答1: I believe that the only way to do this is to provide your own background images for your table cells. You can provide 3 images to have a rounded feel to the UITableView like Apple Does. in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath set the cell's backgroundView to a UIView with the image you want based on the

iOS CTFramesetterCreateWithAttributedString not sizing correctly

为君一笑 提交于 2019-12-13 02:54:35
问题 I am building an app that takes a few different text files and strings them together, then builds a pdf out of them. I needed to add the file's text add separate times so I can add in hyperlinks to the text from each file. I have made some progress and got it to display almost accurately, but it appears CTFramesetterCreateWithAttributedString is not sizing correctly. For example, the first of the three files displays too much, in other words, after the text ends there is a blank page that

Save CGImageRef as JPEG2000

随声附和 提交于 2019-12-13 02:16:50
问题 I'm trying to figure out how to save a CGImageRef as JPEG2000. At the moment I get scattered-looking image output. I have the following code which works for every other format except kUTTypeJPEG2000. Saving as kUTTypeGIF or kUTTypePNG works fine. Interesting, saving as kUTTypeJPEG2000 without an alpha channel works too. How can I get the image to output correctly? - (void)saveImage:(CGImageRef)image path:(NSString *)path { // Set the image compression quality CFMutableDictionaryRef properties

How to convert from CGImageRef to GraphicsMagick Blob type?

无人久伴 提交于 2019-12-13 02:14:09
问题 I have a fairly standard RGBA image as a CGImageRef. I'm looking to convert this into a GraphicsMagick Blob (http://www.graphicsmagick.org/Magick++/Image.html#blobs) What's the best way to go about transposing it? I have this but it produces only a plain black image if I specify PNG8 in the pathString or it crashes: - (void)saveImage:(CGImageRef)image path:(NSString *)pathString { CGDataProviderRef dataProvider = CGImageGetDataProvider(image); NSData *data = CFBridgingRelease