فهرست منبع

【综合】【注释】添加图片,更改不透明度后旋转图片,不透明度更改无效(已修复)

tangchao 10 ماه پیش
والد
کامیت
1228c6fe0d

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/Signature/CPDFListSignatureAnnotation.swift

@@ -58,7 +58,7 @@ class CPDFListSignatureAnnotation: CPDFSignatureAnnotation {
                 self.bounds = bounds
             }
             
-            let isSignatureAnnotation: Bool = (self.stamp!.isSignatureAnnotation) as Bool
+            let isSignatureAnnotation: Bool = (self.stamp?.isSignatureAnnotation as? Bool) ?? false
             if isSignatureAnnotation {
                 self.updateAppearanceStream(with: self.pImage, rotation: newValue)
             }

+ 27 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.m

@@ -547,6 +547,31 @@ CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
     else NSBeep();
 }
 
+- (void)rotateStampAnnotation:(CPDFListStampAnnotation *)annotation rotateAngle:(NSInteger)angle {
+    if([annotation isKindOfClass:[CPDFListStampAnnotation class]]) {
+        CPDFListStampAnnotation *stampAnnotation = (CPDFListStampAnnotation *)annotation;
+        NSInteger rotation = stampAnnotation.rotation;
+        rotation = rotation - angle;
+        
+        if (rotation < 0) {
+            rotation += 360;
+        } else if (rotation >= 360) {
+            rotation-=360;
+        }
+
+        [annotation setRotation:rotation];
+         rotation = [annotation appearanceStreamRotation];
+
+        NSImage *oldImage = [annotation.pImage copy];
+        NSImage *newImage = [self changeImage:oldImage alphaValue:annotation.opacity];
+        [annotation updateAppearanceStreamWithImage:newImage rotation:annotation.rotation];
+        
+        [self setNeedsDisplayAnnotationViewForPage:annotation.page];
+        
+        [[[self undoManager] prepareWithInvocationTarget:self] rotateStampAnnotation:annotation rotateAngle:-angle];
+    }
+}
+
 - (void)setStampAnnotation:(CPDFListStampAnnotation *)annotation forImageAlpha:(CGFloat)alpha {
     [[[self undoManager] prepareWithInvocationTarget:self] setStampAnnotation:annotation forImageAlpha:annotation.opacity];
 
@@ -555,7 +580,8 @@ CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
     NSImage *oldImage = [annotation.pImage copy];
     NSImage *newImage = [self changeImage:oldImage alphaValue:alpha];
     
-    [annotation updateAppearanceStreamWithImage:newImage];
+//    [annotation updateAppearanceStreamWithImage:newImage];
+    [annotation updateAppearanceStreamWithImage:newImage rotation:annotation.rotation];
     [self setNeedsDisplayAnnotation:annotation];
 }