根据参考图像和参考徽标尺寸计算徽标尺寸

时间:2020-05-12 12:55:17

标签: swift macos nsimage

我正在NSImage上绘制徽标。我想在整个尺寸不同的图像上实现统一的外观,因此我使用以下代码根据参考图像和参考来计算新徽标的宽度和高度,以更改图像尺寸徽标

                let xratio1 = referenceimagesize!.width/reflogosize!.width
                let xratio2 = referenceimagesize!.height/reflogosize!.height

                let width = image.size.width/xratio1
                let height = image.size.height/xratio2

                logo = logoimage?.resizeTo(width:width,height:height) 

但这会在较大的图像中产生较小的徽标。这是一个示例

参考

enter image description here

输出

enter image description here

0 个答案:

没有答案