1.修复串流时,顶部按钮提示文体类型不匹配问题;
2.添加hsbs的缩放功能
This commit is contained in:
parent
97819eac37
commit
03ae208bd7
@ -26,8 +26,8 @@ enum SpatialType : Int {
|
|||||||
case redBlueSolid = 2
|
case redBlueSolid = 2
|
||||||
case crossedEyes = 3
|
case crossedEyes = 3
|
||||||
//以下两种标记:外部串流时使用
|
//以下两种标记:外部串流时使用
|
||||||
case hsbs = 4
|
case hsbs = 5
|
||||||
case fsbs = 5
|
case fsbs = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
class CCSpatialVideoDisplayController: BaseController {
|
class CCSpatialVideoDisplayController: BaseController {
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class PlayByTransferConvertor {
|
|||||||
case .hsbs:
|
case .hsbs:
|
||||||
cwidth = left.size.width
|
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_sbs(left: left, right: right, imgWidth: cwidth, imgHeight:cheight,scale: scale)
|
||||||
break
|
break
|
||||||
case .fsbs:
|
case .fsbs:
|
||||||
// cwidth = left.size.width
|
// cwidth = left.size.width
|
||||||
@ -167,12 +167,25 @@ class PlayByTransferConvertor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//将两张图片合成一张图片 SBS
|
//将两张图片合成一张图片 HSBS 高度不变,宽度减半
|
||||||
func joinImages_sbs( left:UIImage, right:UIImage,imgWidth:CGFloat,imgHeight:CGFloat) -> CIImage {
|
func joinImages_sbs( left:UIImage, right:UIImage,imgWidth:CGFloat,imgHeight:CGFloat,scale:CGFloat) -> CIImage {
|
||||||
let newImageSize = CGSize(width:imgWidth, height: imgHeight);
|
//画布区域
|
||||||
UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1);
|
let drawSize = CGSize(width:imgWidth, height: imgHeight);
|
||||||
left.draw(in: CGRect(x:0, y:0, width:imgWidth/2, height:imgHeight))
|
//获取左边调整后的视图和作画size
|
||||||
right.draw(in: CGRect(x:imgWidth/2, y:0, width:imgWidth/2, height:imgHeight))
|
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()!
|
let image = UIGraphicsGetImageFromCurrentImageContext()!
|
||||||
UIGraphicsEndImageContext();
|
UIGraphicsEndImageContext();
|
||||||
|
|
||||||
@ -181,6 +194,28 @@ class PlayByTransferConvertor {
|
|||||||
return ci
|
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
|
//FSBS
|
||||||
func joinImages_fsbs( left:UIImage, right:UIImage,imgWidth:CGFloat,imgHeight:CGFloat) -> CIImage {
|
func joinImages_fsbs( left:UIImage, right:UIImage,imgWidth:CGFloat,imgHeight:CGFloat) -> CIImage {
|
||||||
let newImageSize = CGSize(width:imgWidth, height: imgHeight);//在播放过程中,务必保证宽、高尺寸不变
|
let newImageSize = CGSize(width:imgWidth, height: imgHeight);//在播放过程中,务必保证宽、高尺寸不变
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user