2010-10-19 24 views
1

我正在使用CATiledLayer进行数据可视化。默认情况下,drawLayer函数获取转置和缩放的上下文,这使得绘图代码可以与缩放级别和请求的图块无关。
但是,我想使用缩放功能来改变数据的水平范围,而无需实际缩放。如何在放大CATiledLayer时绘制未转换的上下文?

到目前为止,我得到这个代码:

(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context { 

    /* retrieve the transformation matrix from the context. */ 
    CGAffineTransform contextTrans = CGContextGetCTM(context); 

    /* Scale the context back, so all items will still have the same size */ 
    CGContextScaleCTM(context, 1.0/contextTrans.a, 1.0/contextTrans.d); 

    <.. loop through all datapoints ..> { 
     /* Transpose the point-centers to the new zoomed context */ 
     xCoord = xCoord * contextTrans.a; 
     yCoord = yCoord * contextTrans.d; 
    } 
    <.. drawing code ..> 
} 

这个方法奏效,但缺点是,在放大时的元素会变模糊(只有1/zoomfactor像素渲染每个屏幕上的像素)。
任何方法来防止这种模糊发生?
或者,有什么办法可以绘制到非转换的上下文,而不是转置的上下文?

回答

相关问题