【CoreGraphics】CGContext - 图形上下文(

2016-06-13  本文已影响777人  居然是村长

图片

涉及 CGImage的再探究,暂时使用 uiimage.CGImage;


    CGContextDrawImage(context, CGRectMake(100, 100, 100, 100), imageRef);// 适应大小
//    CGContextDrawTiledImage(context, CGRectMake(10, 10, 100, 100), imageRef);// 平铺
    
    CGInterpolationQuality qu = CGContextGetInterpolationQuality(context);
    CGContextSetInterpolationQuality(context, kCGInterpolationDefault);// 质量
 

文本

注:暂时使用,NSString 的 drawInRect 的方法,以下方法对此无效?
 // 设置
    CGContextSetCharacterSpacing(context, 30);// 间距
    CGContextSetTextPosition(context, 200, 200);// 位置
    CGContextSetTextMatrix(context, CGAffineTransformMake(1, 1, 1, 1, 1, 1));// 2d变化
    
    CGContextSetTextDrawingMode(context, kCGTextFillStroke);// 绘制设置
    
    CGContextSetFont(context, fontRef);// 字体
    CGContextSetFontSize(context, 20);// 大小
    
    CGPoint points[] = {CGPointMake(100, 100)};
    CGContextShowGlyphsAtPositions(context, glyphs, points, 2);// 符号
    
    
    // 获取
    CGPoint point =  CGContextGetTextPosition(context);
    CGAffineTransform affine = CGContextGetTextMatrix(context);


    // 字体平滑
    CGContextSetShouldSmoothFonts(context, YES);
    CGContextSetAllowsFontSmoothing(context, YES);
    
    CGContextSetShouldSubpixelPositionFonts(context, YES);
    CGContextSetAllowsFontSubpixelPositioning(context, YES);
    
    CGContextSetShouldSubpixelQuantizeFonts(context, YES);
    CGContextSetAllowsFontSubpixelQuantization(context, YES);


    // 抗锯齿
    CGContextSetShouldAntialias(context, YES);
    CGContextSetAllowsAntialiasing(context, YES);

其他

注:PDF 绘制。。。设计比较多,看不下去了。。。关于CoreGraphics还有一些,暂时没有研究,能力不够了。唉。

 
CG_EXTERN void CGContextReplacePathWithStrokedPath(CGContextRef __nullable c)
    CG_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0);

 
CG_EXTERN void CGContextSetRenderingIntent(CGContextRef __nullable c,
    CGColorRenderingIntent intent)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

 
CG_EXTERN void CGContextDrawPDFPage(CGContextRef __nullable c,
    CGPDFPageRef __nullable page)
    CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0);


CG_EXTERN void CGContextBeginPage(CGContextRef __nullable c,
    const CGRect * __nullable mediaBox)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);


CG_EXTERN void CGContextEndPage(CGContextRef __nullable c)
    CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

 
CG_EXTERN void CGContextBeginTransparencyLayer(CGContextRef __nullable c,
    CFDictionaryRef __nullable auxiliaryInfo)
    CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0);

 
CG_EXTERN void CGContextBeginTransparencyLayerWithRect(
    CGContextRef __nullable c, CGRect rect, CFDictionaryRef __nullable auxInfo)
    CG_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);


CG_EXTERN void CGContextEndTransparencyLayer(CGContextRef __nullable c)
    CG_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0);

 

1

上一篇 下一篇

猜你喜欢

热点阅读