瞳距、缩放在新方法中全部实现---平行眼
This commit is contained in:
parent
7b6a13e0e3
commit
78368421e8
@ -148,8 +148,8 @@ class ZZHCustomPlayer: UIView {
|
||||
avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: Int(playerWidth), height: playerHeight)
|
||||
avPlayerLayer?.videoGravity = .resizeAspectFill
|
||||
playerLayerBgView!.layer.addSublayer(avPlayerLayer!)
|
||||
playerLayerBgView?.backgroundColor = UIColor.red
|
||||
|
||||
// playerLayerBgView?.backgroundColor = UIColor.red
|
||||
// self.backgroundColor = .orange
|
||||
//添加遮罩视图
|
||||
let mpBgView = UIView(frame: .zero)
|
||||
playerLayerBgView?.addSubview(mpBgView)
|
||||
@ -193,7 +193,7 @@ class ZZHCustomPlayer: UIView {
|
||||
make.left.equalTo(timeSlider!.snp.right).offset(24)
|
||||
}
|
||||
|
||||
self.backgroundColor = .orange
|
||||
|
||||
}
|
||||
|
||||
//屏幕旋转时自动隐藏timeSlider、edBtn,同时将播放layer设置为全屏
|
||||
|
||||
@ -176,6 +176,19 @@ class PlayByTransferConvertor {
|
||||
|
||||
//将两张图片合成一张图片
|
||||
func joinImages( leftImage:CIImage, rightImage:CIImage,scale:CGFloat,ed:Int) -> CIImage {
|
||||
// let left2 = UIImage(ciImage: leftImage )
|
||||
// let right2 = UIImage(ciImage: rightImage )
|
||||
//
|
||||
// UIGraphicsBeginImageContextWithOptions(left2.size, false, 1);
|
||||
// left2.draw(in: CGRect(x:0, y:0, width:left2.size.width*0.5, height:left2.size.height))
|
||||
// right2.draw(in: CGRect(x:0, y:left2.size.width*0.5, width:left2.size.width*0.5, height:left2.size.height))
|
||||
// let image2 = UIGraphicsGetImageFromCurrentImageContext()!
|
||||
// UIGraphicsEndImageContext();
|
||||
//
|
||||
// let ci2 = CIImage(cgImage: image2.cgImage!)
|
||||
// return ci2
|
||||
//
|
||||
|
||||
//缩放参数,此处必须大于0.5
|
||||
//瞳距参数,暂定 瞳距与像素点的比例为1:2,瞳距的值范围为 -30 ~ +30 之间的整数
|
||||
let edS = 20 //比列
|
||||
@ -198,18 +211,20 @@ class PlayByTransferConvertor {
|
||||
let (ed_left,last_left_size) = getImgWithED(image: n_left, drawImgWidth: imageWidth,drawSize: n_left_size)
|
||||
let (ed_right,last_right_size) = getImgWithED(image: n_right, drawImgWidth: imageWidth,drawSize: n_right_size)
|
||||
print("n_left_size:\(n_left_size)\nlast_left_size\(last_left_size)")
|
||||
print("n_right_size:\(n_right_size)\nlast_right_size\(last_right_size)")
|
||||
// testImageUi(image: ed_left)
|
||||
let newImageSize = left.size
|
||||
UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1);
|
||||
UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1)
|
||||
|
||||
if (ed > 0) {//左视图宽度减小,同时x点的坐标值为0;右视图宽度减小,同时x点的坐标值增加
|
||||
ed_left.draw(in: CGRect(x:0, y:(imageHeight - n_left_size.height) * 0.5, width:last_left_size.width, height:last_left_size.height))
|
||||
ed_right.draw(in: CGRect(x:left.size.width*0.5 + x_offset, y:(imageHeight - n_right_size.height) * 0.5, width:last_right_size.width, height:last_right_size.height))
|
||||
ed_left.draw(in: CGRect(x:0, y:(imageHeight - last_left_size.height) * 0.5, width:last_left_size.width, height:last_left_size.height))
|
||||
ed_right.draw(in: CGRect(x:newImageSize.width - last_right_size.width, y:(imageHeight - last_right_size.height) * 0.5, width:last_right_size.width, height:last_right_size.height))
|
||||
|
||||
print("ed>>>>> 0....")
|
||||
}
|
||||
else if (ed < 0) {
|
||||
ed_left.draw(in: CGRect(x:x_offset, y:(imageHeight - n_left_size.height) * 0.5, width:last_left_size.width, height:last_left_size.height))
|
||||
ed_right.draw(in: CGRect(x:left.size.width*0.5, y:(imageHeight - n_right_size.height) * 0.5, width:last_right_size.width, height:last_right_size.height))
|
||||
ed_left.draw(in: CGRect(x:newImageSize.width*0.5 - last_left_size.width, y:(imageHeight - n_left_size.height) * 0.5, width:last_left_size.width, height:last_left_size.height))
|
||||
ed_right.draw(in: CGRect(x:newImageSize.width*0.5, y:(imageHeight - n_right_size.height) * 0.5, width:last_right_size.width, height:last_right_size.height))
|
||||
print("ed < 0....")
|
||||
}
|
||||
else {//瞳距没有改变的情况
|
||||
@ -217,6 +232,7 @@ class PlayByTransferConvertor {
|
||||
ed_left.draw(in:leftRect )
|
||||
|
||||
let rightRect = CGRect(x:imageWidth + (imageWidth - n_right_size.width) * 0.5 , y:(imageHeight - n_right_size.height) * 0.5, width:n_right_size.width, height:n_right_size.height)
|
||||
// let rightRect = CGRect(x:imageWidth , y:(imageHeight - n_right_size.height) * 0.5, width:n_right_size.width, height:n_right_size.height)
|
||||
ed_right.draw(in:rightRect )
|
||||
|
||||
print("newImageSize:\(newImageSize) \nimageWidth:\(imageWidth) \ned_left.size:\(ed_left.size) \nleftRect:\(leftRect) \nrightRect:\(rightRect)")
|
||||
@ -256,7 +272,7 @@ class PlayByTransferConvertor {
|
||||
newSize = CGSizeMake(scale*originSize.width, scale*originSize.height)
|
||||
// newImage = image.imageAtRect(rect: CGRect(origin: .zero, size: image.size))!
|
||||
}
|
||||
testImageUi(image: newImage)
|
||||
// testImageUi(image: newImage)
|
||||
return (newImage,newSize)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user