- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
The Quartz context in Objective-C
The Quartz context QR Code ISO/IEC18004 Generator In Objective-C Using Barcode maker for iPhone Control to generate, create QR image in iPhone applications. www.OnBarcode.comPainting UPC-A Supplement 5 In Objective-C Using Barcode creation for iPhone Control to generate, create UPCA image in iPhone applications. www.OnBarcode.comThe second major way to manipulate images is through the OpenGL ES API. This cross-platform API, originally developed by Silicon Graphics, could be the topic of its own book, so we ll just show you how to get started with it. But most of this chapter is going to be about Quartz, a topic that we re going to dive into immediately. Drawing USS Code 39 In Objective-C Using Barcode encoder for iPhone Control to generate, create Code 3/9 image in iPhone applications. www.OnBarcode.comUCC.EAN - 128 Creation In Objective-C Using Barcode maker for iPhone Control to generate, create USS-128 image in iPhone applications. www.OnBarcode.com19.1 An introduction to Quartz 2D
EAN 13 Generator In Objective-C Using Barcode drawer for iPhone Control to generate, create European Article Number 13 image in iPhone applications. www.OnBarcode.comCreate QR Code ISO/IEC18004 In Objective-C Using Barcode encoder for iPhone Control to generate, create QR Code ISO/IEC18004 image in iPhone applications. www.OnBarcode.comQuartz 2D is a two-dimensional drawing library that s tightly integrated into the iPhone OS. It works well with all the relevant iPhone frameworks, including Core Animation, OpenGL ES, and the UIKit. Fundamentally, Quartz s drawings depend upon three core ideas: context, paths, and state, each of which will be the topic of a future section. Barcode Creation In Objective-C Using Barcode generator for iPhone Control to generate, create Barcode image in iPhone applications. www.OnBarcode.comDraw UPC - E1 In Objective-C Using Barcode maker for iPhone Control to generate, create UPC-E image in iPhone applications. www.OnBarcode.comContext is a description of where the graphics are being written to, as defined by a CGContextRef. You ll usually be writing to a UIView or to a bitmap. Layers are a little less important for this overview, but they re where Quartz drawing occurs. They can be stacked one on top of another, creating a complex result. When working with the iPhone, you ll often only have a single layer associated with each of your UIKit objects. Paths are what you ll typically be drawing within Quartz. These are collections of lines and arcs that are drawn in advance, and then are painted to the screen by either stroking or filling the path in question (or, possibly, by clipping it). State saves the values of transformations, clipping paths, fill and stroke settings, alpha values, other blending modes, text characteristics, and more. The current state can be stored with CGContextSaveGState and restored with CGContextRestoreGState, allowing for easy switching among complex drawing setups. Denso QR Bar Code Creator In Objective-C Using Barcode drawer for iPad Control to generate, create QR Code 2d barcode image in iPad applications. www.OnBarcode.comDraw QR-Code In VS .NET Using Barcode generation for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications. www.OnBarcode.comQuartz is built on the older Core Foundation framework that we ve met a few times over the course of this part of the book. This means that you ll need to use older styles of variables to integrate with Cocoa Touch using toll-free bridging, and to respect Core Foundation s memory-management techniques. Take a look at the Using Core Foundation sidebar in chapter 16 if you need a refresher on these topics. If you need more information on any Quartz topic, your should reference the Quartz 2D Programming Guide at Apple s developer website. It s a fine introduction to Quartz, though not as focused on the iPhone as you d probably like, a deficiency that we ll correct in this chapter. Using Quartz requires little special setup. It can be easily integrated into any template and any project that you want. Just be sure to include the Core Graphics framework and the CoreGraphics/CoreGraphics.h include file before you get started. With that said, we re ready to dive into our first major Quartz topic: the context. PDF-417 2d Barcode Creator In Java Using Barcode creator for Java Control to generate, create PDF-417 2d barcode image in Java applications. www.OnBarcode.com1D Maker In Visual Basic .NET Using Barcode creation for VS .NET Control to generate, create Linear image in .NET applications. www.OnBarcode.com19.2 The Quartz context
Painting QR In Objective-C Using Barcode creator for iPad Control to generate, create QR image in iPad applications. www.OnBarcode.comCode128 Recognizer In None Using Barcode decoder for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comA graphical context is a description of where Quartz will be writing to. This could include a printer, a PDF file, a window, or a bitmap image. On the iPhone, you re only likely to make use of two of these possibilities. Barcode Creator In VS .NET Using Barcode drawer for .NET Control to generate, create Barcode image in .NET applications. www.OnBarcode.comReading UPC-A Supplement 5 In .NET Framework Using Barcode scanner for .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.comGraphics: Quartz, Core Animation, and OpenGL
UCC-128 Generator In VS .NET Using Barcode creation for ASP.NET Control to generate, create GS1-128 image in ASP.NET applications. www.OnBarcode.comGTIN - 128 Recognizer In C# Using Barcode scanner for VS .NET Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.comMost frequently, you ll work with the graphical context that is automatically associated with the CALayer (Core Animation layer) of each UIView. That means that you can use Quartz to draw to most UIKit objects. To do so, you override the drawRect: method and, inside the object in question, you use UIGraphicsGetCurrentContext to retrieve the current context. You might alternatively create a bitmap context in order to create or modify an image that you ll use elsewhere in your program. You do this by using the UIGraphicsBeginImageContext and UIGraphicsEndImageContext functions. EAN13 Printer In None Using Barcode drawer for Online Control to generate, create EAN / UCC - 13 image in Online applications. www.OnBarcode.comCreate Barcode In None Using Barcode generation for Word Control to generate, create Barcode image in Microsoft Word applications. www.OnBarcode.comWarning: inverse coordinate system ahead
By now, you should be familiar with the standard iPhone coordinate system. It has the origin at the top left of the screen, with the main axes running to the right and down. Quartz s default coordinate system is inverted, with the origin at the bottom left of the screen and the main axes running right and up. This won t usually be a problem. The Cocoa Touch methods that you ll be using to create and write to graphical contexts will usually transform Quartz s default coordinates so that they look like iPhone coordinates to you. Once in a while, though, you ll run into a situation where you ll draw to a UI-derived context and find your content flipped upside down (and in the wrong position). This is a result of accessing Quartz in a way that hasn t been transformed. As of this writing, we re aware of two situations where you ll have to correct Quartz s coordinate system by yourself, even when using one of the UI-derived contexts: if you import images using the native Quartz functions (as opposed to the UIImage methods that we saw in the last chapter), and if you write text. We ll talk about each of these when we get to them. Personally, we consider these coordinate inversions bugs, and it s our expectation that they ll eventually be corrected, perhaps even by the time this book is published. If you create a context without using Cocoa Touch, expect everything to be inverted. This is something that we don t expect to change in the future. There are a variety of Core Graphics functions that can be used to access other sorts of contexts types that you won t usually use on an iPhone. The functions required to capture a PDF context are one such example. These have two deficits that you should be aware of: they depend more heavily on the Core Foundation frameworks and they use Quartz s inverted coordinate system. One thing to note about graphical contexts is that they re created in a stack: when you create a new context, it s pushed on top of a stack, and when you re done with it, it s popped off. This means that if you create a new bitmap context, it ll be placed on top of any existing context, such as the one associated with your UIView, and will stay there until you re done with the bitmap.
|
|