NSImage的Drawing方法与Compositing方法的对比

NSImage的Drawing方法与Compositing方法的对比,第1张

概述Drawing Versus Compositing The NSImage class offers different groups of methods to facilitate drawing your images to the current context. The two main groups of methods can be generally categorized as Drawing Versus Compositing

The NSImage class offers different groups of methods to facilitate drawing your images to the current context. The two main groups of methods can be generally categorized as the “drawing” versus “compositing” methods. There are three “drawing” methods of NSImage:

drawAtPoint:fromRect:operation:fraction:

drawInRect:fromRect:operation:fraction:

drawRepresentation:inRect:

The drawing methods are among the most commonly-used methods of NSImage because of their basic safety. Images are typically rendered in offscreen windows and then copIEd to the screen as needed. In some cases,several images may be composited into the same window for efficIEncy reasons. The draw methods use extra safety checking to ensure that only the contents of the current image are ever drawn in one of your vIEws. The same is not true of compositing methods,of which there are the following:

compositeToPoint:operation:

compositeToPoint:fromRect:operation:

compositeToPoint:fromRect:operation:fraction:

compositeToPoint:operation:fraction:

These methods can be more efficIEnt than the drawing methods because they perform fewer checks on the image bounds. These methods do have other behaviors that you need to understand,however. The most important behavior is that the compositing methods undo any scale or rotation factors (but not translation factors) applIEd to the CTM prior to drawing. If you are drawing in a flipped vIEw or manually applIEd scaling or rotation values to the current context,these methods will ignore those transformations. Although this might seem like a problem,it actually can be a very useful tool. For example,if your program is scaling a graphic element,you might want to add a scale value to your transform to do the scaling (at least temporarily). If your element uses image-based selection handles,you Could use the compositing methods to prevent those handles from being scaled along with the rest of your graphic element.

The other thing to remember about the compositing methods is that none of them allow you to scale your image to a target rectangle. Cocoa composites the entire image (or designated portion thereof) bit-for-bit to the specifIEd location. This is in contrast to the drawInRect:fromrect:operation:fraction: method,which lets you scale all or part of your image to the designated target rectangle in your vIEw.

Note: The dissolvetoPoint:fraction: and dissolvetoPoint:fromrect:fraction: methods behave in a similar manner as the corresponding compositing methods. Their use is generally more limited though and better support for dissolving images is available through Core Image.

总结

以上是内存溢出为你收集整理的NSImage的Drawing方法与Compositing方法的对比全部内容,希望文章能够帮你解决NSImage的Drawing方法与Compositing方法的对比所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1065661.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存