Revision: 14311
          http://sourceforge.net/p/skim-app/code/14311
Author:   hofman
Date:     2024-06-07 14:14:54 +0000 (Fri, 07 Jun 2024)
Log Message:
-----------
Separate method for partial image for snapshot animation

Modified Paths:
--------------
    trunk/SKSnapshotWindowController.m

Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m  2024-06-06 16:26:21 UTC (rev 14310)
+++ trunk/SKSnapshotWindowController.m  2024-06-07 14:14:54 UTC (rev 14311)
@@ -487,18 +487,13 @@
             thumbnailSize = NSMakeSize(size, round((size - 2.0 * 
shadowBlurRadius) * NSHeight(bounds) / NSWidth(bounds) + 2.0 * 
shadowBlurRadius));
         [transform translateXBy:shadowBlurRadius yBy:shadowBlurRadius - 
shadowOffset];
         [transform scaleXBy:(thumbnailSize.width - 2.0 * shadowBlurRadius) / 
NSWidth(bounds) yBy:(thumbnailSize.height - 2.0 * shadowBlurRadius) / 
NSHeight(bounds)];
-    } else if (size < 0.0) {
-        thumbnailSize = [[self window] frame].size;
     }
     
-    if (size >= 0.0 && NSEqualPoints(bounds.origin, NSZeroPoint) == NO)
+    if (NSEqualPoints(bounds.origin, NSZeroPoint) == NO)
         [transform translateXBy:-NSMinX(bounds) yBy:-NSMinY(bounds)];
     
     image = [NSImage bitmapImageWithSize:thumbnailSize scale:scale 
drawingHandler:^(NSRect dstRect){
         
-        if (size < 0.0)
-            [[NSBezierPath bezierPathWithRoundedRect:(NSRect){NSZeroPoint, 
thumbnailSize} xRadius:10.0 yRadius:10.0] addClip];
-        
         [[NSGraphicsContext currentContext] 
setImageInterpolation:NSImageInterpolationHigh];
         [transform concat];
         
@@ -588,6 +583,31 @@
     return NSMakeRect(NSMinX(targetRect) - scaleFactor * NSMinX(sourceRect), 
NSMinY(targetRect) - scaleFactor * NSMinY(sourceRect), scaleFactor * 
windowSize.width, scaleFactor * windowSize.height);
 }
 
+- (NSImage *)contentImage {
+    NSRect rect = [pdfView visibleContentRect];
+    NSRect bounds = [[self window] frame];
+    bounds.origin = NSZeroPoint;
+    NSImage *image = [[NSImage alloc] initWithSize:bounds.size];
+    NSBitmapImageRep *imageRep = [[[[self window] contentView] superview] 
bitmapImageRepForCachingDisplayInRect:bounds];
+    NSGraphicsContext *context = [NSGraphicsContext 
graphicsContextWithBitmapImageRep:imageRep];
+    
+    [NSGraphicsContext saveGraphicsState];
+    [NSGraphicsContext setCurrentContext:context];
+    
+    [[NSBezierPath bezierPathWithRoundedRect:bounds xRadius:10.0 yRadius:10.0] 
addClip];
+    [[NSColor whiteColor] set];
+    NSRectFill(rect);
+    
+    [[NSBezierPath bezierPathWithRect:rect] addClip];
+    [pdfView drawPagesInRect:bounds toContext:[context CGContext]];
+    
+    [NSGraphicsContext restoreGraphicsState];
+    
+    [image addRepresentation:imageRep];
+    
+    return image;
+}
+
 static void roundCornersAndApplyFiltersToImageRep(NSBitmapImageRep *imageRep, 
NSArray *filters, NSRect rect) {
     NSRect bounds = {NSZeroPoint, [imageRep size]};
     NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:bounds 
xRadius:10.0 yRadius:10.0];
@@ -620,7 +640,7 @@
     if ([[self delegate] 
respondsToSelector:@selector(snapshotController:miniaturizedRect:)]) {
         NSWindow *window = [self window];
         NSArray *filters = SKColorEffectFilters();
-        NSImage *contentImage = [self thumbnailWithSize:-1.0 scale:[[self 
window] backingScaleFactor]];
+        NSImage *contentImage = [self contentImage];
         NSImage *windowImage;
         NSRect windowRect = [window frame];
         NSRect dockRect = [[self delegate] snapshotController:self 
miniaturizedRect:miniaturize];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to