Generated by GPT-5-mini| Apple Core Graphics | |
|---|---|
| Name | Core Graphics |
| Developer | Apple Inc. |
| Released | 2001 |
| Operating system | macOS, iOS, iPadOS, tvOS, watchOS |
| License | Proprietary |
Apple Core Graphics is a low-level, C-based graphics API introduced by Apple Inc. and used in macOS, iOS, iPadOS, tvOS, and watchOS for 2D rendering. It interoperates with higher-level frameworks such as Cocoa, Quartz Composer, UIKit, Core Animation, and Metal while supporting standards and formats familiar to developers working with PostScript, PDF, SVG, OpenGL, and DirectX. Core Graphics underpins many system components including Finder (macOS), Safari (web browser), Photos (Apple), and third-party apps from companies like Adobe Systems, Microsoft, and Autodesk.
Core Graphics provides primitives for drawing shapes, images, and text and for handling bitmap contexts, vector paths, gradients, and compositing used across macOS Big Sur, iOS 14, iPadOS 14, and later releases. The framework's APIs are exposed to developers working in Objective-C, Swift (programming language), and bridging layers used by projects such as React Native, Flutter (software), and Xamarin. Core Graphics originated from Apple's acquisition and integration of technologies related to Display PostScript, PDF (file format), and the Quartz rendering model that appeared in Mac OS X 10.0 (Cheetah).
Core Graphics is organized around contexts, paths, color spaces, images, fonts, and devices that map to display hardware, printers, and PDF output. Key types include CGContext, CGPath, CGImage, CGColorSpace, CGFont, and CGPattern; these integrate with system services like Core Text, Image I/O, Core Animation, and AVFoundation. The framework interacts with lower-level drivers and kernel services such as the XNU kernel, I/O Kit, and graphics drivers used by vendors like Intel, AMD, and NVIDIA in Macs, and with Apple silicon families including Apple M1 and Apple M2. PDF rendering components share lineage with PDFium concepts and cooperate with document workflows used by Preview (macOS), Adobe Acrobat, and enterprise systems from Eastman Kodak and print vendors.
Core Graphics employs a stateful drawing model that uses a drawing state stack and affine transforms to map user coordinates to device space, concepts familiar from PostScript and PDF. Compositing and blending modes are influenced by standards including Porter–Duff operations and are comparable to features in SVG and Canvas (HTML) implementations in WebKit. Rendering pipelines integrate antialiasing, alpha blending, and device-dependent color management via profiles from vendors like International Color Consortium and systems that tie into ColorSync on macOS and Display P3 workflows used by iPhone hardware.
Core Graphics provides CGImage and CGBitmapContext for pixel buffers, supporting formats such as ARGB, RGBA, grayscale, and indexed palettes encountered in workflows with JPEG, PNG, TIFF, and HEIF files. Image I/O integration enables metadata handling from EXIF, XMP, and interoperability with frameworks like Photos (Apple), ImageMagick, and libjpeg. It supports drawing, scaling, sampling, and interpolation techniques comparable to those in GDI+ and Cairo (graphics) while enabling export to PDF (file format) and printing pipelines used by CUPS and enterprise print managers.
Path construction with CGPath and stroking/filling operations mirror paradigms found in PostScript and SVG Path. Color handling uses CGColor and CGColorSpace with profile management via ColorSync and support for spaces like sRGB, Display P3, and device-specific profiles used by vendors such as Epson and Canon. Text drawing leverages integration with Core Text and CGGlyph-based APIs; higher-level text layout features are provided by NSTextView and UILabel while font management cooperates with Font Book and font formats including TrueType and OpenType used by Adobe Fonts and Google Fonts.
Core Graphics offloads rasterization and compositing where possible to GPUs via drivers and technologies such as Metal, OpenGL, and historically Quartz Extreme and Quartz 2D Extreme. Optimizations include tiling, lazy rendering, raster caches, and integration with Core Animation layers for compositing scenes seen in apps like Final Cut Pro and Logic Pro. Power and thermal considerations tie into system-level schedulers in iOS and macOS power management, especially on Apple silicon families starting with Apple M1 where GPU hierarchies and unified memory influence performance.
Developers access Core Graphics via headers in Xcode SDKs and use profiling tools such as Instruments (macOS), Activity Monitor, and leaks and Time Profiler instruments to diagnose rendering costs. It interoperates with higher-level frameworks including UIKit, AppKit, SwiftUI, and cross-platform toolchains like Electron, Qt (software), and GTK via bridging layers. Documentation and sample code have been distributed by Apple Developer resources, WWDC sessions, and third-party books and tutorials from publishers such as O'Reilly Media and Apress.
Category:Apple frameworks