修复fsbs图片在边转边播时出现的多层视图问题

This commit is contained in:
bluesea 2024-03-13 10:35:44 +08:00
parent 51b3cd596f
commit 5b2f052ad3
3 changed files with 27 additions and 8 deletions

View File

@ -268,9 +268,9 @@ class CCSpatialVideoDisplayController: BaseController {
break break
} }
// if let ciImg { if let ciImg {
request.finish(with: ciImg!, context: nil) request.finish(with: ciImg, context: nil)
// } }
} }
return temItem return temItem
} }
@ -466,7 +466,11 @@ class CCSpatialVideoDisplayController: BaseController {
} }
func selectedSpatialType(selectedIndex:Int){ func selectedSpatialType(selectedIndex:Int){
let rsi : SpatialType = SpatialType(rawValue: selectedIndex) ?? .monocular2D var si = selectedIndex
if self.typeData.count == 2 {
si = selectedIndex + 4
}
let rsi : SpatialType = SpatialType(rawValue: si) ?? .monocular2D
// player!.play() // player!.play()
self.selectedIndex = rsi self.selectedIndex = rsi

View File

@ -50,9 +50,9 @@ class PlayByTransferConvertor {
newpb = joinImages_sbs(left: left, right: right, imgWidth: cwidth, imgHeight:cheight ) newpb = joinImages_sbs(left: left, right: right, imgWidth: cwidth, imgHeight:cheight )
break break
case .fsbs: case .fsbs:
cwidth = left.size.width*2 cwidth = left.size.width
cheight = left.size.height cheight = left.size.height
newpb = joinImages_sbs(left: left, right: right, imgWidth: cwidth, imgHeight: cheight) newpb = joinImages_fsbs(left: left, right: right, imgWidth: cwidth, imgHeight: cheight)
break break
case .parallelEyes:// case .parallelEyes://
@ -131,6 +131,21 @@ class PlayByTransferConvertor {
return ci return ci
} }
//FSBS
func joinImages_fsbs( left:UIImage, right:UIImage,imgWidth:CGFloat,imgHeight:CGFloat) -> CIImage {
let newImageSize = CGSize(width:imgWidth, height: imgHeight);//
UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1);
left.draw(in: CGRect(x:0, y:imgHeight/4, width:imgWidth/2, height:imgHeight/2))
right.draw(in: CGRect(x:imgWidth/2, y:imgHeight/4, width:imgWidth/2, height:imgHeight/2))
let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext();
let ci = CIImage(cgImage: image.cgImage!)
return ci
}
// OU // OU
func joinImages_ou( left:UIImage, right:UIImage,imgWidth:CGFloat,imgHeight:CGFloat) -> CIImage { func joinImages_ou( left:UIImage, right:UIImage,imgWidth:CGFloat,imgHeight:CGFloat) -> CIImage {
let newImageSize = CGSize(width:imgWidth, height: imgHeight); let newImageSize = CGSize(width:imgWidth, height: imgHeight);
@ -154,8 +169,8 @@ class PlayByTransferConvertor {
let newImageSize = CGSize(width:imageWidth, height: left.size.height); let newImageSize = CGSize(width:imageWidth, height: left.size.height);
UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1); UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1);
left.draw(in: CGRect(x:0, y:0, width:imageWidth/2, height:imageHeight)) left.draw(in: CGRect(x:0, y:imageHeight/2, width:imageWidth/2, height:imageHeight))
right.draw(in: CGRect(x:imageWidth/2, y:0, width:imageWidth/2, height:imageHeight)) right.draw(in: CGRect(x:imageWidth/2, y:imageHeight/2, width:imageWidth/2, height:imageHeight))
let image = UIGraphicsGetImageFromCurrentImageContext()! let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext(); UIGraphicsEndImageContext();