Revision: 16323
http://sourceforge.net/p/skim-app/code/16323
Author: hofman
Date: 2026-05-27 16:12:07 +0000 (Wed, 27 May 2026)
Log Message:
-----------
draw binder using double gradient
Modified Paths:
--------------
trunk/SkimQuickLookThumbnails/SKThumbnailProvider.m
Modified: trunk/SkimQuickLookThumbnails/SKThumbnailProvider.m
===================================================================
--- trunk/SkimQuickLookThumbnails/SKThumbnailProvider.m 2026-05-27 14:10:37 UTC
(rev 16322)
+++ trunk/SkimQuickLookThumbnails/SKThumbnailProvider.m 2026-05-27 16:12:07 UTC
(rev 16323)
@@ -107,6 +107,42 @@
CGContextRestoreGState(context);
}
+static void drawPDFPageInContext(CGContextRef context, CGPDFPageRef pdfPage)
+{
+ CGRect pageRect = CGPDFPageGetBoxRect(pdfPage, kCGPDFCropBox);
+ CGRect thumbRect = CGContextGetClipBoundingBox(context);
+ CGAffineTransform t = CGPDFPageGetDrawingTransform(pdfPage, kCGPDFCropBox,
thumbRect, 0, true);
+ CGContextSaveGState(context);
+ CGContextSetGrayFillColor(context, 1, 1);
+ CGContextFillRect(context, pageRect);
+ CGContextConcatCTM(context, t);
+ CGContextClipToRect(context, pageRect);
+ CGContextSetGrayFillColor(context, 1, 1);
+ CGContextFillRect(context, pageRect);
+ CGContextDrawPDFPage(context, pdfPage);
+ CGContextRestoreGState(context);
+
+ CGRect binderRect, ignored;
+ CGRectDivide(thumbRect, &binderRect, &ignored, 0.07 *
fmax(CGRectGetWidth(thumbRect), CGRectGetHeight(thumbRect)), CGRectMinXEdge);
+ CGFloat components1[8] = {0.5, 1.0, 0.0, 1.0};
+ CGFloat components2[8] = {0.8, 0.2, 0.1, 1.0};
+ CGFloat locations[2] = {0.0, 1.0};
+ CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray();
+ CGGradientRef gradient = CGGradientCreateWithColorComponents(colorspace,
components1, locations, 2);
+ CGPoint startPoint = CGPointMake(CGRectGetMinX(binderRect),
CGRectGetMaxY(binderRect));
+ CGPoint endPoint = CGPointMake(CGRectGetMinX(binderRect),
CGRectGetMinY(binderRect));
+ CGContextSaveGState(context);
+ CGContextClipToRect(context, binderRect);
+ CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0);
+ CGGradientRelease(gradient);
+ gradient = CGGradientCreateWithColorComponents(colorspace, components2,
locations, 2);
+ CGColorSpaceRelease(colorspace);
+ endPoint = CGPointMake(CGRectGetMaxX(binderRect),
CGRectGetMaxY(binderRect));
+ CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0);
+ CGGradientRelease(gradient);
+ CGContextRestoreGState(context);
+}
+
@implementation SKThumbnailProvider
- (void)provideThumbnailForFileRequest:(QLFileThumbnailRequest *)request
completionHandler:(void (^)(QLThumbnailReply *, NSError *))handler {
@@ -140,21 +176,8 @@
handler([QLThumbnailReply replyWithContextSize:size
drawingBlock:^BOOL(CGContextRef context) {
- CGRect thumbRect = CGContextGetClipBoundingBox(context);
- CGAffineTransform t =
CGPDFPageGetDrawingTransform(pdfPage, kCGPDFCropBox, thumbRect, 0, true);
- CGContextSaveGState(context);
- CGContextConcatCTM(context, t);
- CGContextClipToRect(context, pageRect);
- CGContextSetGrayFillColor(context, 1, 1);
- CGContextFillRect(context, pageRect);
- CGContextDrawPDFPage(context, pdfPage);
- CGContextRestoreGState(context);
+ drawPDFPageInContext(context, pdfPage);
- CGRect binderRect, ignored;
- CGRectDivide(thumbRect, &binderRect, &ignored, 0.07 *
fmax(CGRectGetWidth(thumbRect), CGRectGetHeight(thumbRect)), CGRectMinXEdge);
- CGContextSetGrayFillColor(context, 0.25, 1);
- CGContextFillRect(context, binderRect);
-
CGPDFDocumentRelease(pdfDoc);
// Return YES if the thumbnail was successfully drawn
inside this block.
@@ -232,21 +255,8 @@
handler([QLThumbnailReply replyWithContextSize:size
drawingBlock:^BOOL(CGContextRef context) {
- CGRect thumbRect =
CGContextGetClipBoundingBox(context);
- CGAffineTransform t =
CGPDFPageGetDrawingTransform(pdfPage, kCGPDFCropBox, thumbRect, 0, true);
- CGContextSaveGState(context);
- CGContextConcatCTM(context, t);
- CGContextClipToRect(context, pageRect);
- CGContextSetGrayFillColor(context, 1, 1);
- CGContextFillRect(context, pageRect);
- CGContextDrawPDFPage(context, pdfPage);
- CGContextRestoreGState(context);
+ drawPDFPageInContext(context, pdfPage);
- CGRect binderRect, ignored;
- CGRectDivide(thumbRect, &binderRect, &ignored,
0.07 * fmax(CGRectGetWidth(thumbRect), CGRectGetHeight(thumbRect)),
CGRectMinXEdge);
- CGContextSetGrayFillColor(context, 0.3, 1);
- CGContextFillRect(context, binderRect);
-
CGPDFDocumentRelease(pdfDoc);
// Return YES if the thumbnail was successfully
drawn inside this block.
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