初步实现瞳距调节逻辑
This commit is contained in:
parent
e43bd28aaa
commit
9c3ec43bb4
@ -1048,7 +1048,7 @@
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1.1;
|
||||
CURRENT_PROJECT_VERSION = 1.3;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = 8DQD6BV6H9;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
@ -1101,7 +1101,7 @@
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1.1;
|
||||
CURRENT_PROJECT_VERSION = 1.3;
|
||||
DEVELOPMENT_TEAM = 8DQD6BV6H9;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
|
||||
Binary file not shown.
@ -16,7 +16,7 @@ class UserInfo: NSObject {
|
||||
var paymentProductIdentifier:String? //表示已购买的产品id
|
||||
var isMemberShip:Bool {
|
||||
get {
|
||||
return true
|
||||
// return true
|
||||
return paymentState
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,22 +176,43 @@ class PlayByTransferConvertor {
|
||||
|
||||
//将两张图片合成一张图片
|
||||
func joinImages( leftImage:CIImage, rightImage:CIImage) -> CIImage {
|
||||
let scale = 0.7//此处必须大于0.5
|
||||
let scale = 1.0 //缩放参数,此处必须大于0.5
|
||||
let ed = 5 //瞳距参数,暂定 瞳距与像素点的比例为1:2,瞳距的值范围为 -30 ~ +30 之间的整数
|
||||
let edS = 30 //比列
|
||||
|
||||
let left = UIImage(ciImage: leftImage )
|
||||
let right = UIImage(ciImage: rightImage )
|
||||
|
||||
let imageWidth = left.size.width/2
|
||||
let imageHeight = left.size.height
|
||||
|
||||
|
||||
//获取缩放图片
|
||||
let n_left = getImgWithScale(image: left, scale: scale - 0.5)
|
||||
let n_right = getImgWithScale(image: right, scale: scale - 0.5)
|
||||
|
||||
//获取调整了瞳距的图片
|
||||
let x_offset = CGFloat(abs(ed) * edS) //关于瞳距的x偏移量
|
||||
let imageWidth = left.size.width/2 - x_offset
|
||||
let imageHeight = left.size.height
|
||||
let ed_left = getImgWithED(image: n_left, imgWidth: imageWidth)
|
||||
let ed_right = getImgWithED(image: n_right, imgWidth: imageWidth)
|
||||
|
||||
let newImageSize = left.size //CGSize(width:imageWidth, height: left.size.height);
|
||||
|
||||
let newImageSize = left.size
|
||||
UIGraphicsBeginImageContextWithOptions(newImageSize, false, 1);
|
||||
n_left.draw(in: CGRect(x:0, y:0, width:imageWidth, height:imageHeight))
|
||||
n_right.draw(in: CGRect(x:imageWidth, y:0, width:imageWidth, height:imageHeight))
|
||||
if (ed > 0) {//左视图宽度减小,同时x点的坐标值为0;右视图宽度减小,同时x点的坐标值增加
|
||||
ed_left.draw(in: CGRect(x:0, y:0, width:imageWidth, height:imageHeight))
|
||||
ed_right.draw(in: CGRect(x:left.size.width/2 + x_offset, y:0, width:imageWidth, height:imageHeight))
|
||||
}
|
||||
else if (ed < 0) {
|
||||
ed_left.draw(in: CGRect(x:x_offset, y:0, width:imageWidth, height:imageHeight))
|
||||
ed_right.draw(in: CGRect(x:imageWidth, y:0, width:imageWidth, height:imageHeight))
|
||||
}
|
||||
else {//瞳距没有改变的情况
|
||||
ed_left.draw(in: CGRect(x:0, y:0, width:imageWidth, height:imageHeight))
|
||||
ed_right.draw(in: CGRect(x:imageWidth, y:0, width:imageWidth, height:imageHeight))
|
||||
}
|
||||
|
||||
|
||||
let image = UIGraphicsGetImageFromCurrentImageContext()!
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
@ -199,6 +220,7 @@ class PlayByTransferConvertor {
|
||||
return ci
|
||||
}
|
||||
|
||||
//图像缩放
|
||||
func getImgWithScale(image:UIImage,scale:CGFloat) -> UIImage {
|
||||
let dRect = CGSizeMake(image.size.width*0.5, image.size.height)
|
||||
let imgWidth = image.size.width*scale
|
||||
@ -210,6 +232,16 @@ class PlayByTransferConvertor {
|
||||
return newImage
|
||||
}
|
||||
|
||||
//图像瞳距
|
||||
func getImgWithED(image:UIImage,imgWidth:CGFloat) -> UIImage {
|
||||
let dRect = CGSizeMake(imgWidth, image.size.height)
|
||||
UIGraphicsBeginImageContextWithOptions(dRect, false, 1);
|
||||
image.draw(in: CGRectMake((dRect.width - imgWidth)*0.5, 0, imgWidth, dRect.height))
|
||||
let newImage = UIGraphicsGetImageFromCurrentImageContext()!
|
||||
UIGraphicsEndImageContext();
|
||||
return newImage
|
||||
}
|
||||
|
||||
func joinImages_backup( leftImage:CIImage, rightImage:CIImage) -> CIImage {
|
||||
let left = UIImage(ciImage: leftImage )
|
||||
let right = UIImage(ciImage: rightImage )
|
||||
|
||||
Loading…
Reference in New Issue
Block a user