gpt4 book ai didi

objective-c - 来自两个 NSImage 的 NSImage

转载 作者:行者123 更新时间:2023-12-03 17:41:57 32 4
gpt4 key购买 nike

我有一个矩形 NSImage A,我想缩放以嵌入到方形透明图像 B 中,保持 A 的比例。所以,最后我会得到一个带有矩形的方形图像。

我该如何构图?我的意思是,如何在另一个 NSImage 上绘制一个 NSImage 并保存结果图像?

我一直在阅读有关在 beizer 内剪切 NSImage 的内容,但我需要保持比例而不是填充 beizer 方 block 。

希望你明白我想要的。

谢谢。

最佳答案

“Cocoa 绘图指南”中有一个名为“绘图到图像”的部分。从该文档:

It is possible to create images programmatically by locking focus on an NSImage object and drawing other images or paths into the image context. This technique is most useful for creating images that you intend to render to the screen, although you can also save the resulting image data to a file.

那里有示例代码。

关于objective-c - 来自两个 NSImage 的 NSImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10566544/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com