They say, that there is a Stack that saves graphic states. Well, I am not sure what they mean by that term. Does the CGContextSaveGState save the current drawing I made, or does it save the drawing settings I currently have, like color, line width, font size, etc.?
views:
116answers:
1
+4
A:
The CGContextSaveGState
documentation explicitly states what is saved in the state.
Each graphics context maintains a stack of graphics states. Note that not all aspects of the current drawing environment are elements of the graphics state. For example, the current path is not considered part of the graphics state and is therefore not saved when you call the CGContextSaveGState function. The graphics state parameters that are saved are:
- CTM (current transformation matrix)
- clip region
- image interpolation quality
- line width
- line join
- miter limit
- line cap
- line dash
- flatness
- should anti-alias
- rendering intent
- fill color space
- stroke color space
- fill color
- stroke color
- alpha value
- font
- font size
- character spacing
- text drawing mode
- shadow parameters
- the pattern phase
- the font smoothing parameter
- blend mode
So no, the drawing you have done is not saved (though it is not cleared, either). Instead, many of the graphics state parameters are saved. You can then restore to the state at which you saved by calling CGContextRestoreGState
.
Sebastian Celis
2009-04-23 15:18:02