|
@@ -33,30 +33,35 @@ open class PQImageFilter: PQBaseFilter {
|
|
|
|
|
|
init(sticker: PQEditVisionTrackMaterialsModel, isExport: Bool = true, showUISize: CGSize = .zero) {
|
|
|
super.init(fragmentShader: PassthroughFragmentShader, numberOfInputs: 1)
|
|
|
-
|
|
|
mSticker = sticker
|
|
|
stickerInfo = sticker
|
|
|
-
|
|
|
-
|
|
|
- if(sticker.originalData != nil && (sticker.originalData?.count ?? 0) > 0){
|
|
|
- newImage = UIImage.init(data: sticker.originalData!)
|
|
|
- }else{
|
|
|
+ if sticker.originalData != nil, (sticker.originalData?.count ?? 0) > 0 {
|
|
|
+ newImage = UIImage(data: sticker.originalData!)
|
|
|
+ } else {
|
|
|
if mSticker!.locationPath.count == 0 {
|
|
|
FilterLog(2, message: "图片数据为空,创建失败")
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
var imageFilePath = mSticker?.locationPath ?? ""
|
|
|
- if (!imageFilePath.contains("var/mobile/Media")) {
|
|
|
+ if !imageFilePath.contains("var/mobile/Media") {
|
|
|
imageFilePath = documensDirectory + imageFilePath
|
|
|
}
|
|
|
FilterLog(message: "imageFilePath is \(imageFilePath)")
|
|
|
- newImage = UIImage(contentsOfFile:imageFilePath)
|
|
|
+ newImage = UIImage(contentsOfFile: imageFilePath)
|
|
|
}
|
|
|
+ // 保证是正方向
|
|
|
+ UIImage.nx_fixOrientation(newImage, isFront: false).nx_scaleWithMaxLength(maxLength: 1920) { [weak self] outputImage in
|
|
|
+ DispatchQueue.main.async { [weak self] in
|
|
|
+ self?.newImage = outputImage
|
|
|
+ self?.preImagefilter(isExport: isExport, showUISize: showUISize)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ func preImagefilter(isExport: Bool = true, showUISize: CGSize = .zero) {
|
|
|
// try find image file frome in BFFramework bundle
|
|
|
if newImage == nil {
|
|
|
- newImage = UIImage.moduleImage(named: sticker.locationPath, moduleName: "BFFramework", isAssets: false)
|
|
|
+ newImage = UIImage.moduleImage(named: stickerInfo?.locationPath ?? "", moduleName: "BFFramework", isAssets: false)
|
|
|
}
|
|
|
// 如果是预览时 对原图进行缩放处理
|
|
|
if !isExport {
|
|
@@ -68,9 +73,9 @@ open class PQImageFilter: PQBaseFilter {
|
|
|
|
|
|
autoreleasepool {
|
|
|
if newImage == nil {
|
|
|
- //有可能是webp数据 ,使用 webp 加载
|
|
|
+ // 有可能是webp数据 ,使用 webp 加载
|
|
|
var imageFilePath = mSticker?.locationPath ?? ""
|
|
|
- if (!imageFilePath.contains("var/mobile/Media")) {
|
|
|
+ if !imageFilePath.contains("var/mobile/Media") {
|
|
|
imageFilePath = documensDirectory + imageFilePath
|
|
|
}
|
|
|
FilterLog(message: "imageFilePath is \(imageFilePath)")
|