Prechádzať zdrojové kódy

设置原有纹理大小

jsonwang 3 rokov pred
rodič
commit
2e626cc646

+ 12 - 2
BFFramework/Classes/PQGPUImage/akfilters/PQImageFilter.swift

@@ -130,7 +130,7 @@ open class PQImageFilter: PQBaseFilter {
 //        if currTime >= mSticker!.timelineIn && currTime <= mSticker!.timelineOut {
         FilterLog(message: " 显示图片当前时间: \(currTime) 开始时间:\(mSticker!.timelineIn) 结束时间:\(mSticker!.timelineOut)  \(String(describing: newImage?.size))")
         // 取纹理坐标
-        let textureCoordinates = PQGPUImageTools.getTextureCoordinates(sticker: mSticker!, textureSize: newImage!.size, cannvasSize: inputSize)
+        var textureCoordinates = PQGPUImageTools.getTextureCoordinates(sticker: mSticker!, textureSize: newImage!.size, cannvasSize: inputSize)
 
         FilterLog(message: "textureCoordinates is \(textureCoordinates)")
 
@@ -141,13 +141,23 @@ open class PQImageFilter: PQBaseFilter {
         }
 
         
+        //如果设置过大小位置,使用设置值,比如水印
+        if(stickerInfo?.materialPosition?.width != 0){
+           textureCoordinates = [
+                0.0, 0.0, // 1 bottom left
+                1.0, 0.0, // 2 bottom right
+                0.0, 1.0, // 3 top left
+                1.0, 1.0, // 4 top right
+            ]
+        }
+        
         let texturePropertiesimagetwo = InputTextureProperties(textureCoordinates: textureCoordinates, texture: imageTexture)
 
         var verticesPoint: [GLfloat] = PQGPUImageTools.getVerticesPoint(sticker: mSticker!, textureSize: newImage!.size, cannvasSize: inputSize)
         
         //如果设置过大小位置,使用设置值,比如水印
         if(stickerInfo?.materialPosition?.width != 0){
-            verticesPoint = PQGPUImageTools.computeVertices(viewSize: CGSize.init(width: CGFloat(inputSize.width), height: CGFloat(inputSize.height)), _bounds: CGRect.init(x: 0, y: 0, width: stickerInfo?.materialPosition?.width ?? 0, height: stickerInfo?.materialPosition?.height ?? 0))
+            verticesPoint = PQGPUImageTools.computeVertices(viewSize: CGSize.init(width: CGFloat(inputSize.width), height: CGFloat(inputSize.height)), _bounds: CGRect.init(x: stickerInfo?.materialPosition?.x ?? 0, y:  stickerInfo?.materialPosition?.y ?? 0, width: stickerInfo?.materialPosition?.width ?? 0, height: stickerInfo?.materialPosition?.height ?? 0))
         }
         
         // 设置融合模式支持 alpha