gpt4 book ai didi

swift - 以正确尺寸打印 NSImage

转载 作者:行者123 更新时间:2023-12-03 17:33:21 28 4
gpt4 key购买 nike

我正在尝试打印 NSImage,但无法将其调整为正确的尺寸。我希望 NSImage 在任何足够大的纸张上打印为 4"x6"照片。这是我现在的代码。

var printView = NSImageView(frame: NSRect(x: 0, y: 0, width: 72*4, height: 72*6))
var printInfo = NSPrintInfo()

printInfo.paperSize = NSSize(width: 72*4, height: 72*6)
printInfo.bottomMargin = 10
printInfo.topMargin = 10
printInfo.leftMargin = 10
printInfo.rightMargin = 10

printView.image = generateImage()
let printOp = NSPrintOperation(view: printView, printInfo: printInfo)
printOp.run()

最佳答案

这似乎解决了我的问题

var printView = NSImageView(frame: NSRect(x: 0, y: 0, width: 72*4, height: 72*6))
var printInfo = NSPrintInfo()

printInfo.bottomMargin = 0
printInfo.topMargin = 0
printInfo.leftMargin = 0
printInfo.rightMargin = 0

printView.image = generateImage()
let printOp = NSPrintOperation(view: printView, printInfo: printInfo)
printOp.run()

关于swift - 以正确尺寸打印 NSImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50938389/

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