瞳距、缩放在新方法中全部实现---平行眼

This commit is contained in:
bluesea 2024-04-26 16:48:35 +08:00
parent 7b6a13e0e3
commit 78368421e8
2 changed files with 25 additions and 9 deletions

View File

@ -148,8 +148,8 @@ class ZZHCustomPlayer: UIView {
avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: Int(playerWidth), height: playerHeight) avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: Int(playerWidth), height: playerHeight)
avPlayerLayer?.videoGravity = .resizeAspectFill avPlayerLayer?.videoGravity = .resizeAspectFill
playerLayerBgView!.layer.addSublayer(avPlayerLayer!) playerLayerBgView!.layer.addSublayer(avPlayerLayer!)
playerLayerBgView?.backgroundColor = UIColor.red // playerLayerBgView?.backgroundColor = UIColor.red
// self.backgroundColor = .orange
// //
let mpBgView = UIView(frame: .zero) let mpBgView = UIView(frame: .zero)
playerLayerBgView?.addSubview(mpBgView) playerLayerBgView?.addSubview(mpBgView)
@ -193,7 +193,7 @@ class ZZHCustomPlayer: UIView {
make.left.equalTo(timeSlider!.snp.right).offset(24) make.left.equalTo(timeSlider!.snp.right).offset(24)
} }
self.backgroundColor = .orange
} }
//timeSlideredBtn,layer //timeSlideredBtn,layer

View File

@ -176,6 +176,19 @@ class PlayByTransferConvertor {
// //
func joinImages( leftImage:CIImage, rightImage:CIImage,scale:CGFloat,ed:Int) -> CIImage { 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 //,0.5
//, 1:2, -30 ~ +30 //, 1:2, -30 ~ +30
let edS = 20 // 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_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) 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_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) // testImageUi(image: ed_left)
let newImageSize = left.size let newImageSize = left.size
UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1); UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1)
if (ed > 0) {//,x0;,x if (ed > 0) {//,x0;,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_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: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_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....") print("ed>>>>> 0....")
} }
else if (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_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:left.size.width*0.5, y:(imageHeight - n_right_size.height) * 0.5, width:last_right_size.width, height:last_right_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....") print("ed < 0....")
} }
else {// else {//
@ -217,6 +232,7 @@ class PlayByTransferConvertor {
ed_left.draw(in:leftRect ) 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 + (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 ) ed_right.draw(in:rightRect )
print("newImageSize:\(newImageSize) \nimageWidth:\(imageWidth) \ned_left.size:\(ed_left.size) \nleftRect:\(leftRect) \nrightRect:\(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) newSize = CGSizeMake(scale*originSize.width, scale*originSize.height)
// newImage = image.imageAtRect(rect: CGRect(origin: .zero, size: image.size))! // newImage = image.imageAtRect(rect: CGRect(origin: .zero, size: image.size))!
} }
testImageUi(image: newImage) // testImageUi(image: newImage)
return (newImage,newSize) return (newImage,newSize)
} }