我想从单个图像制作帧图像。下面是我正在使用的代码
td {
max-width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
border: 1px solid #000;
background-color: #fff;
}
td:focus {
white-space: normal;
border-color: #333;
position: absolute;
max-width: 100%;
}
上述功能可拍摄一张图像,并通过以特定角度旋转单个图像并合并它们以形成帧图像来创建四个不同的图像。我面临的问题是保持图像比例。例如:如果创建尺寸为320 * 120的最终图像,它将水平压缩图像。附加输出的屏幕截图。我想使用ARkit在墙上显示这张新生成的图像。
最终框架图片
提供图片
func createFrameFromImage(image:UIImage , size :CGSize) -> UIImage
{
let imageSize = CGSize.init(width: size.width , height: size.height)
UIGraphicsBeginImageContext(imageSize)
let width = imageSize.width
let height = imageSize.height
var letTop = image
let rightTop = rotateImageByAngles(image: &letTop, angles: .pi/2) // correct
let rightBottom = rotateImageByAngles(image: &letTop, angles: -.pi) // correct
let leftBottom = rotateImageByAngles(image: &letTop, angles: -.pi/2) // correct
letTop.draw(in: CGRect(x: 0, y: 0, width: width/2, height: height/2))
rightTop.draw(in: CGRect(x: (width/2) , y: 0, width: width/2, height: height/2))
leftBottom.draw(in: CGRect(x: 0, y: height/2, width: width/2, height: height/2))
rightBottom.draw(in: CGRect(x: (width/2) , y: (height/2), width: width/2, height: height/2))
guard let finalImage = UIGraphicsGetImageFromCurrentImageContext() else { return rightTop }
UIGraphicsEndImageContext()
return finalImage
}
真的会有帮助吗?