core-graphics

How can I fix CGContextRestoreGState: invalid context 0x0

喜欢而已 提交于 2019-12-10 15:53:41
问题 This is the code that I am working with: CGRect imageRect = CGRectMake(0, 0, oldImage.size.width, oldImage.size.height); CGRect newRect = imageRect; UIGraphicsBeginImageContextWithOptions(newRect.size, NO, oldImage.scale); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextScaleCTM(ctx, 1, -1); CGContextTranslateCTM(ctx, 0, -(newRect.size.height)); CGContextSaveGState(ctx); CGContextClipToMask(ctx, newRect, oldImage.CGImage); CGContextSetFillColorWithColor(ctx, [UIColor colorWithWhite

CGContextShowTextAtPoint and white space

徘徊边缘 提交于 2019-12-10 14:59:34
问题 Why is it that the following code ignores the white-space? UIColor *textColor = [UIColor colorWithRed:153.0/255.0 green:102.0/255.0 blue:51.0/255.0 alpha:1.0]; CGContextSetFillColorWithColor(ctx, [textColor CGColor]); CGContextSelectFont(ctx, "Helvetica Neue Bold" , 14, kCGEncodingMacRoman); CGContextSetTextMatrix(ctx, CGAffineTransformMakeScale(1, -1)); CGContextSetShadowWithColor(ctx, CGSizeMake(0.0, 1.0), 1.0, [[UIColor whiteColor] CGColor]); //CGContextSetAllowsAntialiasing(ctx, YES);

iPhone cannot create CGBitmapContext

*爱你&永不变心* 提交于 2019-12-10 14:47:44
问题 I have a problem with creating a CGBitmapContext. CGContextRef bitmapContext = CGBitmapContextCreate(nil, imageSize.width, imageSize.height, 8, imageSize.width * 4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst) When I run my application normally it works. But when I run it in my 'Test application' (a running app that will perform my tests) the context is logged as (null) and I get the following errors: <Error>: CGContextSetFillColorWithColor: invalid context 0x0 <Error>:

How to determine which part of an nsstring fits into a rect?

人走茶凉 提交于 2019-12-10 13:41:40
问题 This is about PDF formatting using core graphics. But it could be about any type of paging when it comes to printing a string on two pages. I need to spread a string over several pages. For smaller strings this is no real problem. For those I use the NSString UIKit extensions sizeWithFont to determine, whether the full text fits on the current page or not. If it does, then I print it with drawInRect and if it does not then I move it to the next page. Works fine but is not suitable for longer

How to set CGBITMAP_CONTEXT_LOG_ERRORS environmental variable?

久未见 提交于 2019-12-10 12:36:45
问题 While using CGBitmapContextCreate I get error in XCode CGBitmapContextCreate: unsupported parameter combination: set CGBITMAP_CONTEXT_LOG_ERRORS environmental variable to see the details How can I set this var? I tried launchctl setenv CGBITMAP_CONTEXT_LOG_ERRORS /Users/user/Documents/cgbitmap_errors.log and launchctl setenv CGBITMAP_CONTEXT_LOG_ERRORS 1 and restarting XCode with no success. I also tried combination with defaults write com.apple.dt.Xcode UseSanitizedBuildSystemEnvironment

Best Practice for laying out images for printing in a WYSIWYG Mac app?

对着背影说爱祢 提交于 2019-12-10 12:00:05
问题 I'm in the concept phase of a Mac application that should let the user easily select and layout images for printing. It's a document-based app and a document can have multiple pages with lots of pictures in different sizes and rotations on it. The UI would kind of be like the UI of Pages.app. Those pictures can possibly be large hi-res images. The user should also be able to print them in the best quality that the images offer. I have re-watched some WWDC sessions about Quartz, 2D drawing

iPhone CALayer animation

倖福魔咒の 提交于 2019-12-10 11:58:25
问题 I am drawing a line animation, connecting 2 points with a line. This is my code: -(void) drawObject{ rootLayer = [CALayer layer]; rootLayer.frame = self.view.bounds; [self.view.layer addSublayer:rootLayer]; lineStartPath = CGPathCreateMutable(); CGPathMoveToPoint(lineStartPath, nil, 160, 50); CGPathAddLineToPoint(lineStartPath, nil, 160, 50); CGPathCloseSubpath(lineStartPath); lineEndPath = CGPathCreateMutable(); CGPathMoveToPoint(lineEndPath, nil, 160, 50); CGPathAddLineToPoint(lineEndPath,

Xcode 6.0.1, Swift, UIKit, CoreGraphics missing

痞子三分冷 提交于 2019-12-10 11:33:42
问题 To make it short: Do never ever give a project a frameworks name! I called my project "CoreGraphics". Original question: I cant use CoreGraphics in a newly created simple Single View Application I start Xcode 6.0.1 (6A317) New Project: Single View Application: Swift New File: Cocoa Touch Class "CustomView" of type UIView I uncomment the template for drawRect(rect: CGRect) {} Compiler Error: Use of undeclared type 'CGRect'. import UIKit is in place I tried to add CoreGraphics to "Linked

Image inside NSScrollView drawing on top of other views

亡梦爱人 提交于 2019-12-10 10:59:35
问题 I have a custom NSView that lives inside of a NSScrollView that is in a NSSplitView . The custom view uses the following drawing code: - (void)drawRect:(NSRect)dirtyRect { NSGraphicsContext *ctx = [NSGraphicsContext currentContext]; [ctx saveGraphicsState]; // Rounded Rect NSRect rect = [self bounds]; NSRect pathRect = NSMakeRect(rect.origin.x + 3, rect.origin.y + 6, rect.size.width - 6, rect.size.height - 6); NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:pathRect cornerRadius

programmatically generate ppt in iOS

◇◆丶佛笑我妖孽 提交于 2019-12-10 10:54:38
问题 For generating PDF files we can use Core Graphics. Similarly is there any framework / class that can be used for generating .ppt (power point presentation) files via code ? Or is there any third party framework for this purpose. 回答1: There's no in-built Apple API, and I've never heard of a third-party framework for this. 回答2: Seems there are still no open source solutions for this for iOS platform. Aspose seems to have something and another commercial that pretty recently emerged - libpptx