SVGKImage+CGContext.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. Contains methods for low-level exporting of SVGKImage into CGContext's / OpenGL textures / etc
  3. Process:
  4. 1. Create a CGContextRef; either use your own code (e.g. with OpenGL, you usually want to do this by hand and check PoT),
  5. or use the [self newCGContextAutosizedToFit] method.
  6. 2. Use the renderToContext:::: method (preferred) or the pure, low-level renderInContext: method (not preferred) to
  7. draw into your context
  8. 3. ...do whatever you want with the results (e.g. use one of the Exporters to export it to raw NSData bytes, or similar)
  9. */
  10. #import "SVGKImage.h"
  11. @interface SVGKImage (CGContext)
  12. /** Creates a CGContext with correct pixel size using sizing info from the source SVG (or returns NULL if that's not possible)
  13. */
  14. -(CGContextRef) newCGContextAutosizedToFit;
  15. /**
  16. WARNING: due to bugs in Apple's code (c.f. CALayer.h header file for notes from Apple - they say "use caution"),
  17. this method is NOT a perfect render of CA; it uses Apple's own "approximation", as used in [CALayer renderInContext:],
  18. which ignores e.g. masking and some other CA core features
  19. Generally, for performance and safety, you should use renderToContext:antiAliased:curveFlatnessFactor:interpolationQuality:flipYaxis:
  20. instead of this method (it performs checks and optional performance optimizations)
  21. */
  22. - (void)renderInContext:(CGContextRef)ctx;
  23. /**
  24. The standard basic method used by all the different "export..." methods in this class and others
  25. */
  26. -(void) renderToContext:(CGContextRef) context antiAliased:(BOOL) shouldAntialias curveFlatnessFactor:(CGFloat) multiplyFlatness interpolationQuality:(CGInterpolationQuality) interpolationQuality flipYaxis:(BOOL) flipYaxis;
  27. @end