V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
changx
V2EX  ›  iDev

[CALayer renderInContext:] 之后 CGBitmapContextCreateImage() ,图片质量变差,方法不对还是什么原因?

  •  
  •   changx · 2012-03-14 18:51:53 +08:00 · 6628 次点击
    这是一个创建于 4397 天前的主题,其中的信息可能已经有所发展或是发生改变。
    - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
    {
    UIGraphicsBeginImageContext(layer.bounds.size);
    CGContextRef _ctx = UIGraphicsGetCurrentContext();
    [self.view.layer renderInContext:_ctx];
    CGImageRef image = CGBitmapContextCreateImage(_ctx);
    UIGraphicsEndImageContext();

    CGImageRef flipImage = CGImageCreateWithImageInRect(image, layer.bounds);

    CGContextSaveGState(ctx);
    CGContextTranslateCTM(ctx, 0, layer.bounds.size.height);
    CGContextScaleCTM(ctx, 1.0f, -1.0f);
    CGContextDrawImage(ctx, layer.bounds, flipImage);
    CGContextRestoreGState(ctx);
    LogMessage(@"drawLayer", 1, @"draw layer content");
    }


    上面这番处理之后,图像中的一些线条边缘出现锯齿。
    1 条回复    1970-01-01 08:00:00 +08:00
    changx
        1
    changx  
    OP
       2012-03-14 19:02:06 +08:00
    补充一个我做过的尝试

    CGContextSetShouldAntialias(ctx, YES);
    CGContextSetAllowAntialiasing(ctx, YES);
    CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh);
    CGContextDrawImage(ctx, layer.bounds, flipImage);

    仍然有轻微锯齿,达不到原屏幕显示质量。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   960 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:45 · PVG 05:45 · LAX 14:45 · JFK 17:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.