1.修复串流时,顶部按钮提示文体类型不匹配问题;

2.添加hsbs的缩放功能
This commit is contained in:
bluesea 2024-04-28 18:13:42 +08:00
parent 97819eac37
commit 03ae208bd7
2 changed files with 45 additions and 10 deletions

View File

@ -26,8 +26,8 @@ enum SpatialType : Int {
case redBlueSolid = 2
case crossedEyes = 3
//使
case hsbs = 4
case fsbs = 5
case hsbs = 5
case fsbs = 4
}
class CCSpatialVideoDisplayController: BaseController {

View File

@ -56,7 +56,7 @@ class PlayByTransferConvertor {
case .hsbs:
cwidth = left.size.width
cheight = left.size.height
newpb = joinImages_sbs(left: left, right: right, imgWidth: cwidth, imgHeight:cheight )
newpb = joinImages_sbs(left: left, right: right, imgWidth: cwidth, imgHeight:cheight,scale: scale)
break
case .fsbs:
// cwidth = left.size.width
@ -167,20 +167,55 @@ class PlayByTransferConvertor {
}
// SBS
func joinImages_sbs( 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:0, width:imgWidth/2, height:imgHeight))
right.draw(in: CGRect(x:imgWidth/2, y:0, width:imgWidth/2, height:imgHeight))
// HSBS ,
func joinImages_sbs( left:UIImage, right:UIImage,imgWidth:CGFloat,imgHeight:CGFloat,scale:CGFloat) -> CIImage {
//
let drawSize = CGSize(width:imgWidth, height: imgHeight);
//size
let (scale_left,scale_left_size) = getHSBS_ImgWithScale(image: left, scale: scale)
//size
let (scale_right,scale_right_size) = getHSBS_ImgWithScale(image: right, scale: scale)
//
let perImgWidth = drawSize.width*0.5
UIGraphicsBeginImageContextWithOptions(drawSize, false, 1);
//
let left_draw_rect = CGRectMake((perImgWidth - scale_left_size.width)*0.5, (drawSize.height - scale_left_size.height)*0.5, scale_left_size.width, scale_left_size.height)
scale_left.draw(in: left_draw_rect)
//
let right_draw_rect = CGRectMake((perImgWidth - scale_left_size.width)*0.5 + perImgWidth, (drawSize.height - scale_right_size.height)*0.5, scale_right_size.width, scale_right_size.height)
scale_right.draw(in: right_draw_rect)
let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext();
let ci = CIImage(cgImage: image.cgImage!)
return ci
}
// scale,1
func getHSBS_ImgWithScale(image:UIImage,scale:CGFloat) -> (UIImage,CGSize) {
//rect
let originSize = CGSize(width: image.size.width*0.5, height: image.size.height)
var newImage = image
var newSize = originSize//
if scale > 1 {
let scalSize = CGSizeMake((2-scale)*image.size.width, (2-scale)*image.size.height)
let scalRect = CGRect(origin: CGPoint(x: (image.size.width - scalSize.width)*0.5, y: (image.size.height - scalSize.height)*0.5), size: scalSize)
newImage = image.imageAtRect(rect: scalRect)!
}
else if scale < 1 {//,size
//size
newSize = CGSizeMake(scale*originSize.width, scale*originSize.height)
}
return (newImage,newSize)
}
//FSBS
func joinImages_fsbs( left:UIImage, right:UIImage,imgWidth:CGFloat,imgHeight:CGFloat) -> CIImage {
let newImageSize = CGSize(width:imgWidth, height: imgHeight);//