Revision: 14283
          http://sourceforge.net/p/skim-app/code/14283
Author:   hofman
Date:     2024-05-31 23:10:27 +0000 (Fri, 31 May 2024)
Log Message:
-----------
Round off shadow insets and offset of snapshot thumbnail by pixel rather than 
point

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

Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m  2024-05-31 23:03:17 UTC (rev 14282)
+++ trunk/SKSnapshotWindowController.m  2024-05-31 23:10:27 UTC (rev 14283)
@@ -481,8 +481,9 @@
     NSImage *image;
     
     if (size > 0.0) {
-        shadowBlurRadius = round(size / 32.0);
-        shadowOffset = -ceil(shadowBlurRadius * 0.75);
+        scale = [[[NSScreen screens] 
valueForKeyPath:@"@max.backingScaleFactor"] doubleValue];
+        shadowBlurRadius = round(scale * size / 32.0) / scale;
+        shadowOffset = -ceil(scale * shadowBlurRadius * 0.75) / scale;
         if (NSHeight(bounds) > NSWidth(bounds))
             thumbnailSize = NSMakeSize(round((size - 2.0 * shadowBlurRadius) * 
NSWidth(bounds) / NSHeight(bounds) + 2.0 * shadowBlurRadius), size);
         else
@@ -490,8 +491,8 @@
         [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) {
+        scale = [[self window] backingScaleFactor];
         thumbnailSize = [[self window] frame].size;
-        scale = [[self window] backingScaleFactor];
     }
     
     if (size >= 0.0 && NSEqualPoints(bounds.origin, NSZeroPoint) == NO)
@@ -570,8 +571,9 @@
     CGFloat thumbRatio = thumbSize.height / thumbSize.width;
     CGFloat dockRatio = NSHeight(dockRect) / NSWidth(dockRect);
     CGFloat scaleFactor;
-    CGFloat shadowRadius = round(fmax(thumbSize.width, thumbSize.height) / 
32.0);
-    CGFloat shadowOffset = ceil(0.75 * shadowRadius);
+    CGFloat scale = [[[NSScreen screens] 
valueForKeyPath:@"@max.backingScaleFactor"] doubleValue];
+    CGFloat shadowRadius = round(scale * fmax(thumbSize.width, 
thumbSize.height) / 32.0) / scale;
+    CGFloat shadowOffset = ceil(0.75 * scale * shadowRadius) / scale;
     
     if (thumbRatio > dockRatio) {
         targetRect = NSInsetRect(dockRect, 0.5 * NSWidth(dockRect) * (1.0 - 
dockRatio / thumbRatio), 0.0);

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