Jump To:
Leopard Reference Library: Cocoa
Cocoa provides classes for custom drawing based on Quartz graphics, and utility functions for common graphics tasks such as copying and drawing bitmap data. To go beyond what Cocoa provides, developers can use the graphics and imaging frameworks in Mac OS X. Cocoa applications have access to a wide variety of graphics technologies including Quartz 2D, Quartz Services, OpenGL, QuickTime, and the Mac OS X printing system.

View all Graphics & Imaging Reference Library.
Document Descriptions
On Off
Display

Sort by
Title
Sorted by
Resource Type
Sort by
Date
MyCustomColorPicker (HTML) (DMG) (ZIP)
Shows how to write a custom color picker using Cocoa.
Sample Code 2006-10-09
CarbonQuartzComposer_TV (HTML) (DMG) (ZIP)
Demonstrates how to integrate Cocoa based QuartzComposer window into a Carbon based application
Sample Code 2006-10-02
ImageBackground (HTML) (DMG) (ZIP)
Shows how to draw an image in the background of an NSOutlineView and NSTableView.
Sample Code 2006-10-02
Quartz2DBasics (HTML) (DMG) (ZIP)
Carbon and Cocoa sample code demonstrating some basic usage of the Quartz 2D API
Sample Code 2006-09-11
QCFundamentals (HTML) (DMG) (ZIP)
Demonstrates Coordinate, Interpolation, and Iterative systems in Quartz Composer with an amusing animation
Sample Code 2006-08-07
QCGalaxy (HTML) (DMG) (ZIP)
Demonstrates use of Particle Systems and Core Image Filters in Quartz Composer
Sample Code 2006-08-07
LiveVideoMixer3 (HTML) (DMG) (ZIP)
LiveVideoMixer3 is extended to support Video In via QTKit
Sample Code 2006-08-01
PDF Annotation Editor (HTML) (DMG) (ZIP)
Demonstrates how to use PDF Kit to examine, edit, and create PDF annotations.
Sample Code 2006-07-31
PDF Calendar (HTML) (DMG) (ZIP)
Demonstrates how to use PDF Kit to create PDF content.
Sample Code 2006-07-31
CarbonCocoaCoreImageTab (HTML) (DMG) (ZIP)
Carbon-based application creates a Cocoa-based web window which used CoreImage filters to transition between tabbed WebViews
Sample Code 2006-07-25
GLSLShowpiece (HTML) (DMG) (ZIP)
GLSLShowpiece demonstrates several Vertex and Fragment shaders
Sample Code 2006-07-17
DragItemAround (HTML) (DMG) (ZIP)
Illustrates creating a custom subclass of NSView.
Sample Code 2006-03-16
PDFKitLinker2 (HTML) (DMG) (ZIP)
Demonstrates many aspects of PDFKit including navigation, display modes, searching, and PDFView subclassing.
Sample Code 2005-08-10
CIAnnotation (HTML) (DMG) (ZIP)
Image annotation application using Core Image Filters. Demonstrates creation and usage of Image Units.
Sample Code 2005-08-01
VideoViewer (HTML) (DMG) (ZIP)
Simple example of video rendering using QuickTime visual contexts, OpenGL, Core Video and Core Image.
Sample Code 2005-08-01
QTCoreImage101 (HTML) (DMG) (ZIP)
Demonstrates how to render a QuickTime Movie using Core Image filters and the new video pipeline.
Sample Code 2005-07-19
Quartz Composer QCTV (HTML) (DMG) (ZIP)
Shows how to build a fake TV system using Quartz Composer as the foundation motion graphics.
Sample Code 2005-07-06
Reducer (HTML) (DMG) (ZIP)
Simple utility for rescaling bitmapped images. Demonstrates use of Core Image, NSAnimation, view drawing redirection.
Sample Code 2005-06-06
UnsharpMask (HTML) (DMG) (ZIP)
Demonstrates how to build Automator actions using Cocoa frameworks.
Sample Code 2005-06-06
Link Snoop (HTML) (DMG) (ZIP)
Shows how to use PDFKit to scan for and highlight link annotations in PDFs.
Sample Code 2005-06-01
Quartz Composer Live DV (HTML) (DMG) (ZIP)
Shows how to export a Quartz Composer composition as a real-time DV stream on the FireWire port.
Sample Code 2005-06-01
Quartz Composer Matrix (HTML) (DMG) (ZIP)
Shows how to use Quartz Composer to display a QuickTime movie as a series of frames in a 3D world.
Sample Code 2005-06-01
Quartz Composer Offline Rendering (HTML) (DMG) (ZIP)
Shows how to render a Quartz Composer composition as a series of images using an OpenGL pBuffer.
Sample Code 2005-06-01
Quartz Composer Texture (HTML) (DMG) (ZIP)
Shows how to use a Quartz Composer composition as an OpenGL texture.
Sample Code 2005-06-01
Quartz Composer WWDC 2005 Composition (HTML) (DMG) (ZIP)
Shows how to build a parameterized motion graphics composition with Quartz Composer.
Sample Code 2005-06-01
Quartz Composer WWDC 2005 TextEdit (HTML) (DMG) (ZIP)
Demonstrate how to modify TextEdit's about dialog to display a Quartz Composer composition.
Sample Code 2005-06-01
QuartzLines (HTML) (DMG) (ZIP)
Drawing Lines using Quartz's CGPath & CGContextStrokeLineSegments functions.
Sample Code 2005-06-01
TexturePerformanceDemo (HTML) (DMG) (ZIP)
OpenGL texture optimization demo for WWDC Session 214
Sample Code 2005-06-01
VertexPerformanceDemo (HTML) (DMG) (ZIP)
Vertex optimization demo for WWDC Session 214
Sample Code 2005-06-01
Worm (HTML) (DMG) (ZIP)
NSView performance demonstration. Uses a periodic timer to get best performance with Coalesced Update feature.
Sample Code 2005-06-01
NSGLImage (HTML) (DMG) (ZIP)
Deprecated - Demonstrates how to texture in OpenGL with an NSImage and/or NSBitmapImageRep
Sample Code 2004-12-01
Video Hardware Info (HTML) (DMG) (ZIP)
Sample demonstrates how to query the video hardware for useful information.
Sample Code 2004-02-12
NSOpenGL Fullscreen (HTML) (DMG) (ZIP)
Demonstrates how to create and switch between windowed and fullscreen OpenGL contexts using NSOpenGL.
Sample Code 2004-02-11
ColorMatching (HTML) (DMG) (ZIP)
Performs simple color matching of images using ColorSync or the QuickTime 6.4 Graphics Importers.
Sample Code 2003-12-18
OpenGL Screensaver (HTML) (DMG) (ZIP)
Demonstrates how to integrate OpenGL drawing into a standard Cocoa screen saver on Mac OS X.
Sample Code 2003-12-10
RGB ValueTransformers (HTML) (DMG) (ZIP)
Supersedes the "RGB Image sample". Sample now uses bindings. Color separation now done in an NSValueTransformer subclass.
Sample Code 2003-11-18
FancyAbout (HTML) (DMG) (ZIP)
Demonstrates several visual effects for "About..." panels such as scrolling text, window without a title bar, and ways to dismiss the window.
Sample Code 2003-10-27
Cocoa CG aliasing demo (HTML) (DMG) (ZIP)
Shows how to draw both aliased and anti-aliased text and graphics using Quartz and Cocoa.
Sample Code 2003-07-17
Cocoa CG arc demo (HTML) (DMG) (ZIP)
Shows how to draw both aliased and anti-aliased arcs using Quartz and Cocoa.
Sample Code 2003-07-17
Monochrome Image (HTML) (DMG) (ZIP)
Applies the NTSC color weighting formula to an image to generate a monochrome version of the image.
Sample Code 2003-07-16
VBL (HTML) (DMG) (ZIP)
A simple example of how to create an OpenGLView in AppKit.
Sample Code 2003-07-07
FunkyOverlayWindow (HTML) (DMG) (ZIP)
Demonstrates several window layering, transparency and widget interaction techniques in Cocoa.
Sample Code 2003-05-08
CubePuzzle (HTML) (DMG) (ZIP)
Models a Rubik's Cube using Cocoa and OpenGL
Sample Code 2003-04-21
GLChildWindowDemo (HTML) (DMG) (ZIP)
Shows using Cocoa's child windows and Quartz Extreme to provide 2D/3D overlays above 3D content.
Sample Code 2003-04-21
OpenGLCompositorLab (HTML) (DMG) (ZIP)
Demonstrates using OpenGL to composite multiple sources in hardware. Requires NVIDIA GeForce 4 Ti hardware.
Sample Code 2003-04-21
Image Difference (HTML) (DMG) (ZIP)
Demonstrates a way to use Quartz's compositing capability to find the difference between two images.
Sample Code 2003-01-30
PDFView (HTML) (DMG) (ZIP)
Shows how to display or print a multi-page PDF document and scroll an NSscrollview's contents by dragging.
Sample Code 2003-01-23
CGDrawPicture (HTML) (DMG) (ZIP)
Deprecated - Shows how to use the QDPictDrawToCGContext API.
Sample Code 2003-01-14
Color Sampler (HTML) (DMG) (ZIP)
Demonstrates one way to sample the color at a given point in an NSView.
Sample Code 2003-01-14
ColorBars (HTML) (DMG) (ZIP)
Shows how to enumerate, select, capture, manipulate, draw to, and release displays using the CGDirectDisplay API.
Sample Code 2003-01-14
ColorSyncDevices-Cocoa (HTML) (DMG) (ZIP)
Demonstrates how to use the new ColorSync Device Manager routines in the Cocoa environment.
Sample Code 2003-01-14
Cropped Image (HTML) (DMG) (ZIP)
Demonstrates how to extract a sub-image from another image, and some ways of indicating a selection.
Sample Code 2003-01-14
CTMClip (HTML) (DMG) (ZIP)
Deprecated - Shows how to manipulate the Quartz 2D Current Transform Matrix (CTM) for image drawing with clipping.
Sample Code 2003-01-14
CTMDemo (HTML) (DMG) (ZIP)
Deprecated - Shows how to manipulate the Quartz 2D Current Transform Matrix (CTM) for image drawing without clipping.
Sample Code 2003-01-14
Polygons (HTML) (DMG) (ZIP)
Demonstrates the NSBezierPath class, as well as the manipulation of NSView's coordinate space for convenience.
Sample Code 2003-01-14
QTtoCG (HTML) (DMG) (ZIP)
Shows how to create a CGImageRef with the proper ColorSync profile from a QuickTime image on disk.
Sample Code 2003-01-14
Quartz EB (HTML) (DMG) (ZIP)
WWDC 2001 Early Bird Quartz 2D tutorial of vector drawing and PDF import/export.
Sample Code 2003-01-14
RGB Image (HTML) (DMG) (ZIP)
Demonstrates compositing to separate an NSimage into its RGB components, and how to recombine those components.
Sample Code 2003-01-14
RoundTransparentWindow (HTML) (DMG) (ZIP)
Creating (in Cocoa) custom-shaped windows and transparent window content; plus changing the shape of windows dynamically.
Sample Code 2003-01-14
SimpleCocoaJavaMovieCocoa (HTML) (DMG) (ZIP)
Deprecated - Shows how to use the NSMovieView and NSMovie Cocoa Java AppKit classes.
Sample Code 2003-01-14
SonOfSillyBalls (HTML) (DMG) (ZIP)
Draws a bunch of randomly colored, randomly placed, silly balls in a window on the screen.
Sample Code 2003-01-14
Tinted Image (HTML) (DMG) (ZIP)
Demonstrates the use of an NSImage as an off-screen drawing destination.
Sample Code 2003-01-14
Transformed Image (HTML) (DMG) (ZIP)
Shows the effects of a rendering an NSImage in a transformed coordinate space.
Sample Code 2003-01-14
Working Around Incorrect -needsToDrawRect: Behavior in Custom View Classes (HTML)
TN2107: Describes how to work around a bug in NSView's -needsToDrawRect: method.
Technical Notes 2007-01-22
Making the most of Cocoa bindings in Quartz Composer (HTML)
TN2146: Describes how to best use Cocoa bindings with Quartz Composer.
Technical Notes 2006-03-03
Getting images in and out from Quartz Composer compositions (HTML)
TN2143: Describes how to efficiently pass images into and out of Quartz Composer
Technical Notes 2005-10-04
OpenGL Release Highlights - Mac OS X 10.3 Panther (HTML)
TN2131: Contains a list of bugs along with a short description on a release-by-release basis
Technical Notes 2005-02-04
Understanding and Detecting OpenGL Functionality (HTML)
TN2080: Discusses OpenGL API design, and how to access the full power of hardware and software renderers.
Technical Notes 2003-12-29
Driving OpenGL Rendering Loops (HTML)
QA1385: Using Core Video display links (CVDisplayLink) or Cocoa timers (NSTimer) to drive an OpenGL rendering loop
Technical Q&As 2009-05-01
Core Animation properties and Reference Counting (HTML)
QA1565: Describes a discrepancy between the property declarations in Core Animation and the actual behavior.
Technical Q&As 2008-11-24
Animating the frame of a CALayer. (HTML)
QA1620: Explains how the frame property of a layer interacts with animations.
Technical Q&As 2008-10-24
Getting the pixel data from a CGImage object (HTML)
QA1509: Describes how to access the pixel data of a CGImage object
Technical Q&As 2008-08-27
Requirements for Quartz GL (HTML)
QA1536: Describes the requirements for enabling Quartz GL.
Technical Q&As 2008-08-08
How do I get the hexadecimal value of an NSColor object? (HTML)
QA1576: Describes how to convert an NSColor object to its Hexadecimal value.
Technical Q&As 2007-12-19
How to measure CG text (HTML)
QA1051: Explains how to measure Core Graphics text.
Technical Q&As 2007-08-02
CGBitmapContextCreate Supported Color Spaces (HTML)
QA1037: Lists the color space and alpha info combinations currently supported by CGBitmapContextCreate.
Technical Q&As 2007-07-18
Using UTIs to Identify Image Files (HTML)
QA1518: Explains how to use Uniform Type Identifiers to identify what files can be opened at images.
Technical Q&As 2007-05-11
Debugging Graphics with QuartzDebug (HTML) (日本語 HTML)
QA1236: Explains how to use QuartzDebug to debug graphics issues.
Technical Q&As 2006-01-12
How can I optimize a Quartz Composer composition depending on the hardware it runs on? (HTML)
QA1433: Explains how to design compositions that adapt to the hardware limitations.
Technical Q&As 2005-06-01
Finding an NSView's current magnification. (HTML)
QA1346: How to discover the current magnification (zoom level) of any NSView.
Technical Q&As 2005-03-08
NSOpenGLView redraw problems after a window is closed and re-opened. (HTML)
QA1353: Workaround for NSOpenGLView failure to draw after its window is closed and re-opened.
Technical Q&As 2004-12-03
Using Interface Builder's NSOpenGLView or Custom View objects for an OpenGL application (HTML)
QA1167: Describes usage cases for both NSOpenGLViews and Custom Views for Cocoa OpenGL applications
Technical Q&As 2004-10-28
How do I determine how much VRAM is available on my video card? (HTML)
QA1168: Using Core Graphics and IOKit to find the physical size of VRAM on installed hardware.
Technical Q&As 2004-10-11
Setting the ColorSync profile for a NSBitmapImageRep object (HTML)
QA1369: Setting the ColorSync profile for a NSBitmapImageRep object
Technical Q&As 2004-09-08
Shearing a Coordinate Space with NSAffineTransform (HTML) (日本語 HTML)
QA1332: Describes a simple way to shear coordinate spaces by adding a few methods to the NSAffineTransform class.
Technical Q&As 2004-01-29
CGImageRef contents are immutable (HTML) (日本語 HTML)
QA1276: Explains that CGImageRef contents are considered immutable once created.
Technical Q&As 2003-07-17
Is ColorSync thread safe? (HTML) (日本語 HTML)
QA1261: Discusses ColorSync thread-safety issues.
Technical Q&As 2003-04-17
Quartz 2D Thread Safety (HTML) (日本語 HTML)
QA1238: Explains the thread-safety issues for the Quartz 2D API.
Technical Q&As 2003-02-25
How do I tell if a particular display is being hardware accelerated by Quartz Extreme? (HTML) (日本語 HTML)
QA1218: Describes how to use CGDisplayUsesOpenGLAcceleration to see if a display is accelerated or not.
Technical Q&As 2002-12-04
How can I programmatically determine the DPI of the current video mode? (HTML) (日本語 HTML)
QA1217: Describes how to compute the DPI for a given display in a given mode using Core Graphics.
Technical Q&As 2002-12-02
Quartz 2D Interpolation (HTML) (日本語 HTML)
QA1186: Explains how to control Quartz 2D's image interpolation.
Technical Q&As 2002-10-29
CGContextClosePath (HTML)
QA1046: Explains when you should call CGContextClosePath.
Technical Q&As 2001-10-02
Saving the current Core Graphics Path (HTML)
QA1056: Explains that the Core Graphics save and restore GState APIs do not affect the path.
Technical Q&As 2001-10-02
CGContext Bounds (HTML)
QA1048: Explains how to determine the bounds of a CGContext.
Technical Q&As 2001-07-02
CGContextAddLineToPoint, CGContextAddCurveToPoint, et. al. (HTML)
QA1049: Explains why the CGContextAddXYZ APIs don't draw anything immediately.
Technical Q&As 2001-07-02
Drawing a Path Multiple Times (HTML)
QA1047: Explains that path drawing operations consume the path.
Technical Q&As 2001-07-02
Turning Off Core Graphics Clipping (HTML)
QA1050: Explains how to clear the clipping path for a CGContext.
Technical Q&As 2001-07-02
Unexpected CG state changes (HTML)
QA1045: Explains why the Core Graphics drawing state sometimes changes for no apparent reason.
Technical Q&As 2001-07-02