还需要调整瞳距为0时的缩放问题
This commit is contained in:
parent
ec2009dc4a
commit
505aca1ed8
Binary file not shown.
@ -403,8 +403,8 @@
|
||||
filePath = "SwiftProject/Project/Util/ZZHImageExtension.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "89"
|
||||
endingLineNumber = "89"
|
||||
startingLineNumber = "90"
|
||||
endingLineNumber = "90"
|
||||
landmarkName = "getRotateFrom(_:)"
|
||||
landmarkType = "7">
|
||||
<Locations>
|
||||
@ -453,6 +453,21 @@
|
||||
endingLineNumber = "87"
|
||||
offsetFromSymbolStart = "616">
|
||||
</Location>
|
||||
<Location
|
||||
uuid = "742F2A13-D3B1-41EF-8BDA-BE012155DB3C - bb01223bea0e6d8"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
symbolName = "__C.UIImage.getRotateFrom(__C.UIImageOrientation) -> CoreGraphics.CGFloat"
|
||||
moduleName = "SwiftProject"
|
||||
usesParentBreakpointCondition = "Yes"
|
||||
urlString = "file:///Users/aaa/Documents/IOS%20Dev/VR/SwiftProject/SwiftProject/Project/Util/ZZHImageExtension.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "90"
|
||||
endingLineNumber = "90"
|
||||
offsetFromSymbolStart = "616">
|
||||
</Location>
|
||||
</Locations>
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -632,5 +647,21 @@
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "33963580-0C7F-4FE4-AE70-F6DF35741254"
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "SwiftProject/Project/Util/PlayByTransferConvertor.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "256"
|
||||
endingLineNumber = "256"
|
||||
landmarkName = "getImgWithScale(image:scale:)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
|
||||
@ -144,7 +144,7 @@ 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.clear
|
||||
playerLayerBgView?.backgroundColor = UIColor.red
|
||||
|
||||
//添加遮罩视图
|
||||
let mpBgView = UIView(frame: avPlayerLayer!.frame)
|
||||
|
||||
@ -178,7 +178,7 @@ class PlayByTransferConvertor {
|
||||
func joinImages( leftImage:CIImage, rightImage:CIImage,scale:CGFloat,ed:Int) -> CIImage {
|
||||
//缩放参数,此处必须大于0.5
|
||||
//瞳距参数,暂定 瞳距与像素点的比例为1:2,瞳距的值范围为 -30 ~ +30 之间的整数
|
||||
let edS = 15 //比列
|
||||
let edS = 20 //比列
|
||||
|
||||
let left = UIImage(ciImage: leftImage )
|
||||
let right = UIImage(ciImage: rightImage )
|
||||
@ -193,20 +193,21 @@ class PlayByTransferConvertor {
|
||||
//获取调整了瞳距的图片
|
||||
let x_offset = CGFloat(abs(ed) * edS) //关于瞳距的x偏移量
|
||||
let imageWidth = left.size.width*0.5 - x_offset
|
||||
print("imageWidth:\(imageWidth) ,left.size.width*0.5:\(left.size.width*0.5) ")
|
||||
let imageHeight = left.size.height
|
||||
let (ed_left,last_left_size) = getImgWithED(image: n_left, imgWidth: imageWidth,imageRealSize: n_left_size)
|
||||
let (ed_right,last_right_size) = getImgWithED(image: n_right, imgWidth: imageWidth,imageRealSize: n_right_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)
|
||||
print("n_left_size:\(n_left_size)\nlast_left_size\(last_left_size)")
|
||||
// testImageUi(image: ed_left)
|
||||
let newImageSize = left.size
|
||||
UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1);
|
||||
if (ed > 0) {//左视图宽度减小,同时x点的坐标值为0;右视图宽度减小,同时x点的坐标值增加
|
||||
ed_left.draw(in: CGRect(x:0, y:0, width:last_left_size.width, height:last_left_size.height))
|
||||
ed_right.draw(in: CGRect(x:left.size.width/2 + x_offset, y:0, width:last_right_size.width, height:last_right_size.height))
|
||||
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))
|
||||
}
|
||||
else if (ed < 0) {
|
||||
ed_left.draw(in: CGRect(x:x_offset, y:0, width:last_left_size.width, height:last_left_size.height))
|
||||
ed_right.draw(in: CGRect(x:left.size.width*0.5, y:0, width:last_right_size.width, height:last_right_size.height))
|
||||
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))
|
||||
}
|
||||
else {//瞳距没有改变的情况
|
||||
let leftRect = CGRect(x:(imageWidth - n_left_size.width) * 0.5, y:(imageHeight - n_left_size.height) * 0.5 , width:n_left_size.width, height:n_left_size.height)
|
||||
@ -255,18 +256,19 @@ class PlayByTransferConvertor {
|
||||
return (newImage,newSize)
|
||||
}
|
||||
|
||||
//图像瞳距,参数条件必须满足:image能够等比缩放后填充满imageRealSize,即image的真实size与imageRealSize预期size并不要求一致,但要求等比
|
||||
func getImgWithED(image:UIImage,imgWidth:CGFloat,imageRealSize:CGSize) -> (UIImage,CGSize) {
|
||||
if imageRealSize.width <= imgWidth {
|
||||
//图像瞳距,参数条件必须满足:image能够等比缩放后填充满drawSize,即image的真实size与drawSize预期size并不要求一致,但要求等比
|
||||
func getImgWithED(image:UIImage,drawImgWidth:CGFloat,drawSize:CGSize) -> (UIImage,CGSize) {
|
||||
if drawSize.width <= drawImgWidth {
|
||||
|
||||
print("瞳距返回,不用处理")
|
||||
return (image,imageRealSize)
|
||||
return (image,drawSize)
|
||||
}
|
||||
print("瞳距要处理")
|
||||
let s = imageRealSize.height / image.size.height
|
||||
let dRect = CGRectMake((imageRealSize.width - imgWidth) * s * 0.5, 0, imgWidth, image.size.height)
|
||||
// let s = drawSize.height / image.size.height
|
||||
let newImageWidth = drawImgWidth * image.size.height / drawSize.height
|
||||
let dRect = CGRectMake((image.size.width - newImageWidth) * 0.5, 0, newImageWidth, image.size.height)
|
||||
let newImage = image.imageAtRect(rect: dRect)
|
||||
return (newImage!,CGSize(width: imgWidth, height: imageRealSize.height))
|
||||
return (newImage!,CGSize(width: drawImgWidth, height: drawSize.height))
|
||||
}
|
||||
|
||||
func testImageUi(image:UIImage) {
|
||||
|
||||
@ -23,6 +23,7 @@ extension UIImage {
|
||||
let final = EXImageContext.createCGImage(imageRef, from:imageRef.extent)
|
||||
return UIImage(cgImage: final!)
|
||||
}
|
||||
print("cgimage.....>>>>>>>>>>>>>.")
|
||||
let imageRef = cgImage.cropping(to: rect)
|
||||
return imageRef == nil ? nil : UIImage(cgImage: imageRef!)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user