0

Can any body explain me what is a Context and how can i use it? There is also Graphics Context (CGContextRef).Is there any relation between Context and Graphics Context?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
raaz
  • 12,410
  • 22
  • 64
  • 81

2 Answers2

1

"Context" almost always refers to a graphics context in Cocoa.

One exception is that various methods take a "context" argument, which is usually of type id. This is generally just a spare argument for passing any data that you would like passed along to your callback(s).

Tom
  • 3,831
  • 1
  • 22
  • 24
0

Likely you're talking about the same thing in both cases. From the Quartz 2D Programming Guide:

A graphics context is an opaque data type (CGContextRef) that encapsulates the information Quartz uses to draw images to an output device, such as a PDF file, a bitmap, or a window on a display. The information inside a graphics context includes graphics drawing parameters and a device-specific representation of the paint on the page. All objects in Quartz are drawn to, or contained by, a graphics context.

You can think of a graphics context as a drawing destination, as shown in Figure 1-2. When you draw with Quartz, all device-specific characteristics are contained within the specific type of graphics context you use. In other words, you can draw the same image to a different device simply by providing a different graphics context to the same sequence of Quartz drawing routines. You do not need to perform any device-specific calculations; Quartz does it for you.

There is another definition for the word context in CS, but I think the above definition is what you're looking for.

Community
  • 1
  • 1
Shaggy Frog
  • 27,575
  • 16
  • 91
  • 128