quartz-2d

Core Graphics Performance on iOS

痴心易碎 提交于 2019-12-20 08:10:16
问题 Summary I'm working on a fairly straightforward 2D tower defense game for iOS. So far, I've been using Core Graphics exclusively to handle rendering. There are no image files in the app at all (yet). I've been experiencing some significant performance issues doing relatively simple drawing, and I'm looking for ideas as to how I can fix this, short of moving to OpenGL. Game Setup At a high level, I have a Board class, which is a subclass of UIView , to represent the game board. All other

How can I remove a UIView with rounded corners from its parent view?

删除回忆录丶 提交于 2019-12-20 04:20:37
问题 I'm creating an iPad app for 3.2 and later. My app has an overlay view which has a semi-transparency that makes everything below it darker. In the middle of this view I am chopping a hole in this semi-transparency to let part of the background filter through unscathed, with this code: - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGRect intersection = CGRectIntersection(hole.frame, rect); CGContextClearRect(context, intersection); } Additionally, the

Quartz PDF API Causing Out of Memory Crashes

我的未来我决定 提交于 2019-12-20 03:29:10
问题 I'm having crashing issues using the Quartz PDF API for iOS. At the moment I am compiling with the SDK 4.0 GM Seed and running on my 3.2 iPad (I have tried using the 3.2 SDK with identical results). All the code I am using is based on the standard Apple Quartz documentation and from various sources around the internets. So I can't image I'm doing something drastically different or wrong. The code runs perfectly in the Simulator (all versions, it's a Universal app) and even while using the

clipping a UIImage as per a polygon

一笑奈何 提交于 2019-12-19 11:47:16
问题 How can I let the user of my iphone app to clip a UIImage by a dynamically generated CGPath. Basically I display a rectangle overlaid on a UIImageView and the user can move the 4 corners of the rectangle to get a polygon with 4 sides. The rectangle is not filled so you see four lines overlaid on an image. The user should be able to clip out whatever is outside the 4 lines. Any help or pointers is much appreciated. 回答1: If you already have the CGPath, you just have to use CGContextAddPath and

How to use a UIImage as a mask over a color in Objective-C

99封情书 提交于 2019-12-18 11:07:08
问题 I have a UIImage that is all black with an alpha channel so some parts are grayish and some parts are completely see-through. I want to use that images as a mask over some other color (let's say white to make it easy), so the final product is now a white image with parts of it transparent. I've been looking around on the Apple documentation site here: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_images/dq_images.html#//apple_ref/doc

Perspective correction of UIImage from Points

一个人想着一个人 提交于 2019-12-18 10:31:37
问题 I'm working on a app where I'll let the user take a picture e.g of a business card or photograph. The user will then mark the four corners of the object (which they took a picture off) - Like it is seen in a lot of document/image/business card scanning apps: My question is how do i crop and fix the perspective according to these four points? I've been searching for days and looked at several image proccessing libraries without any luck. Any one who can point me in the right direction? 回答1:

iPhone, CGPDFDocument - PDF links

匆匆过客 提交于 2019-12-18 10:20:19
问题 I'm trying to write a simple PDF viewer using CGPDFDocument, based on QuartzDemo. There is common rendering: -(void)drawInContext:(CGContextRef)context { // PDF page drawing expects a Lower-Left coordinate system, // so we flip the coordinate system before we start drawing. CGContextTranslateCTM(context, 0.0, self.bounds.size.height); CGContextScaleCTM(context, 1.0, -1.0); // Grab the first PDF page CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNumber); // We're about to modify the

Create UIImage from shadowed view while retaining alpha?

一世执手 提交于 2019-12-18 09:35:23
问题 I have a somewhat unusual problem. In my app, I am shadowing a UIImageView using basic Quartz2d layer shadowing. Here's my code: imageView.layer.shadowOpacity = 1.0; // Pretty self explanatory imageView.layer.shadowRadius = 8.0; // My softness imageView.layer.shadowColor = [UIColor blackColor].CGColor; // Color of the shadow imageView.layer.shadowOffset = CGSizeMake(0.0, 0.0); // Offset of the shadow This produces a nice blur behind the image view. However, I am doing some animation with this

Efficient method to draw a line with millions of points

被刻印的时光 ゝ 提交于 2019-12-17 17:33:17
问题 I'm writing an audio waveform editor in Cocoa with a wide range of zoom options. At its widest, it shows a waveform for an entire song (~10 million samples in view). At its narrowest, it shows a pixel accurate representation of the sound wave (~1 thousand samples in a view). I want to be able to smoothly transition between these zoom levels. Some commercial editors like Ableton Live seem to do this in a very inexpensive fashion. My current implementation satisfies my desired zoom range, but

Create PDF Annotations in iOS

孤街醉人 提交于 2019-12-17 17:29:30
问题 I've been working on a pdf viewer with support for annotations and I need to be able to save new annotations that the user has created. I've seen tons of examples on how to draw text/lines/images, but that's only flattened content, I need to create actual annotation objects I've found no documentation or examples about it, so if anyone could point me in the right direction I would be extremely grateful Cheers! Edit: After several months of work we could release the v1 of this. We ended up