1

我正在使用CIContext方法- (void)drawImage:(CIImage *)im inRect:(CGRect)dest fromRect:(CGRect)src将图像绘制到屏幕上。但我需要实现放大/缩小方法。我怎样才能实现它?我认为放大可以实现增加dest矩形,因为苹果文档说:

The image is scaled to fill the destination rectangle.

但是缩小呢?因为如果dest按比例缩小矩形,则图像会以其实际大小绘制,但只有部分图像可见(适合dest矩形的部分)。

你有什么建议?

4

3 回答 3

0

Take a look at this little toy app I made

It's to demonstrate the NSImage version of your CIContext method:

- (void)drawInRect:(NSRect)dstRect 
          fromRect:(NSRect)srcRect 
         operation:(NSCompositingOperation)op 
          fraction:(CGFloat)delta

I did this to find out exactly how the rects relate to each other. It's interactive, you can play with the sliders and move/zoom the images. Not a solution, but it might help you work things out.

于 2013-01-12T22:07:36.853 回答
0

您可以在绘制之前使用 CIFilter 调整 CIImage 的大小。Quartz Composer 提供了一个使用这个过滤器的好例子。只需在 QC 中查找图像调整大小过滤器的描述。

编辑: 另一个很好的缩放过滤器是 CILanczosScaleTransform。有一个片段展示了基本用法。

于 2013-01-12T19:35:29.380 回答
0

您可以尝试使用来调整图像大小(缩放)。希望这对您有所帮助。

于 2013-01-09T09:21:45.020 回答