Questions tagged [quartz-2d]

Quartz 2D is the primary two-dimensional graphics rendering API for Mac OS X, part of the Core Graphics framework.

Quartz 2D is the primary two-dimensional graphics rendering API for Mac OS X, part of the Core Graphics framework.

From apple official document:

Quartz 2D provides low-level, lightweight 2D rendering with unmatched output fidelity regardless of display or printing device. Quartz 2D is resolution- and device-independent; you don’t need to think about the final destination when you use the Quartz 2D application programming interface (API) for drawing.

The Quartz 2D API is easy to use and provides access to powerful features such as transparency layers, path-based drawing, offscreen rendering, advanced color management, anti-aliased rendering, and PDF document creation, display, and parsing.

The Quartz 2D API is part of the Core Graphics framework, so you may see Quartz referred to as Core Graphics or, simply, CG.

Quartz 2D uses the painter’s model for its imaging. In the painter’s model, each successive drawing operation applies a layer of “paint” to an output “canvas,” often called a page.

For more information:

Related tags:

667 questions
6
votes
1 answer

CGPath as a string

Is there any way to get at the actual data of a CGPath, so it can be saved to a file and restored later? And is there any documentation on how that data is structured? I would like to write it as a string (like a SVG path string), or some way with…
user1082474
  • 119
  • 8
6
votes
1 answer

In iOS Development, using Core Graphics and/or Quartz 2D, how can I draw a circle filled with a gradient in such a manner that it looks like a sphere?

So far I have looked at using CGContextDrawLinearGradient() and CGContextDrawRadialGradient(), however, with the former I can't figure out how to make the gradient look like a sphere, and with the latter, I can't figure out how to make the gradient…
cyndrus
  • 63
  • 1
  • 3
6
votes
3 answers

How to get the real RGBA or ARGB color values without premultiplied alpha?

I'm creating an bitmap context using CGBitmapContextCreate with the kCGImageAlphaPremultipliedFirst option. I made a 5 x 5 test image with some major colors (pure red, green, blue, white, black), some mixed colors (i.e. purple) combined with some…
Proud Member
  • 40,078
  • 47
  • 146
  • 231
6
votes
1 answer

How can I create a PDF with a higher dpi on iOS?

I'm creating a PDF, to be used as a mail attachment, inside my app. Which works fine, but I have no idea how to create anything but a 72dpi PDF. I start like this CGRect mediaBox = CGRectMake(0, 0, 595, 842); CGContextRef context =…
Pieter
  • 17,435
  • 8
  • 50
  • 89
6
votes
1 answer

CTFontDrawGlyphs draws at incorrect position

EDITED: I replaced my original code stub with a self-contained version I am using Quartz2D to draw musical symbols to a CGContext. I am doing this in a Playground using Swift 4. Musical Notes are composed of a single CGGlyph for the notehead and a…
MassMover
  • 529
  • 2
  • 17
6
votes
1 answer

Saving CGContextRef

I have a drawing app in which I would like to create an undo method. The drawing takes place inside the TouchesMoved: method. I am trying to create a CGContextRef and push it to the stack OR save it in a context property that can be restored later…
Mark A.
  • 1,073
  • 10
  • 15
6
votes
3 answers

Quartz 2d / Core Graphics: What is the right way to draw some text?

I've been at this for awhile, it seems that there's many ways to go about this in quartz 2d: 1) Draw text using core graphics methods... CGContextSelectFont CGContextSetRGBFillColor CGContextShowTextAtPoint and on and on, which is horribly low…
Shai UI
  • 50,568
  • 73
  • 204
  • 309
6
votes
2 answers

UIGraphicsBeginPDFPage() randomly crashes on 64bit devices (CGPDFSecurityManagerCreateDecryptor ())

I'm struggling with a pdf export method that's was running just fine until I ported the app to the arm64 achitecture. Bacisally, the method opens an existing PDF, it creates a new pdf file, and draws the content of the first pdf into the newly…
Arex
  • 81
  • 5
6
votes
4 answers

Create a table of contents from a pdf file

I'm using quartz to display pdf content, and I need to create a table of contents to navigate through the pdf. From reading Apple's documentation I think I am supposed to use CGPDFDocumentGetCatalog, but I can't find any examples on how to use this…
ryan
  • 61
  • 1
  • 1
  • 2
6
votes
1 answer

Quartz 2D substitude for graphicsPort in SDK 10.10

The scenario: I'm editing some CGImages and strangely enough until now I was first creating NSImages from those CGImages before drawing them. So I tried to change the code so that I would draw the CGImages directly in into…
Enie
  • 649
  • 5
  • 18
6
votes
2 answers

Is this a good way to do a game loop for an iPhone game?

I'm new to iPhone dev, but trying to build a 2D game. I was following a book, but the game loop it created basically said: function gameLoop update() render() sleep(1/30th second) gameLoop The reasoning was that this would run at…
Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275
6
votes
1 answer

Custom "resizable image" drawing in iOS

The UIImage API provides methods to resize an image in a way that certain areas get stretched, while others remain unaltered - great for background images for resizable UI elements. Now I am looking for a way to customize this behavior for more…
de.
  • 7,068
  • 3
  • 40
  • 69
6
votes
3 answers

Drawing a circle ,filled different parts with different color

I am a novice ios programmer.In one of my project i need to draw a circle in which different portion of the circle would be filled up with different colors.I can draw the circle.But i am not being able to determine the different portion of the…
sujat
  • 287
  • 2
  • 16
6
votes
1 answer

PDFDocument does not use custom URL protocol

If have initialized an PDFDocument with an URL and assigned it to a PDFView: view.document = [[[PDFDocument alloc] initWithURL: url] autorelease]; The URL is a file URL. I want to overwrite the URL loading with a custom NSURLProtocol to support a…
diederikh
  • 25,221
  • 5
  • 36
  • 49
6
votes
1 answer

Can I query the current point from a CGContext?

Apple's Quartz2d Programming Guide says "Quartz keeps track of the current point, which is the last location used for path construction." Is there some way for me to query what the current point is, given a CGContext reference? I'm writing…
c roald
  • 1,984
  • 1
  • 20
  • 30