Revision: 14588
          http://sourceforge.net/p/skim-app/code/14588
Author:   hofman
Date:     2024-10-27 09:13:13 +0000 (Sun, 27 Oct 2024)
Log Message:
-----------
Flip image when drawing in iOS, as graphics contexts are flipped there

Modified Paths:
--------------
    trunk/SkimNotes/PDFAnnotation_SKNExtensions.m
    trunk/SkimNotes/SKNPDFAnnotationNote.m

Modified: trunk/SkimNotes/PDFAnnotation_SKNExtensions.m
===================================================================
--- trunk/SkimNotes/PDFAnnotation_SKNExtensions.m       2024-10-26 21:43:51 UTC 
(rev 14587)
+++ trunk/SkimNotes/PDFAnnotation_SKNExtensions.m       2024-10-27 09:13:13 UTC 
(rev 14588)
@@ -170,6 +170,8 @@
     UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] 
initWithSize:rect.size];
     UIImage *image = [renderer 
imageWithActions:^(UIGraphicsImageRendererContext *context) {
         CGContextRef *ctxt = [context CGContext];
+        CGContextTranslateCTM(ctxt, 0.0, CGRectGetHeight(bounds));
+        CGContextScaleCTM(ctxt, 1.0, -1.0);
         switch ([page rotation]) {
             case 0:
                 CGContextTranslateCTM(ctxt, CGRectGetMinX(bounds) - 
CGRectGetMinX(rect), CGRectGetMinY(bounds) - CGRectGetMinY(rect));

Modified: trunk/SkimNotes/SKNPDFAnnotationNote.m
===================================================================
--- trunk/SkimNotes/SKNPDFAnnotationNote.m      2024-10-26 21:43:51 UTC (rev 
14587)
+++ trunk/SkimNotes/SKNPDFAnnotationNote.m      2024-10-27 09:13:13 UTC (rev 
14588)
@@ -180,10 +180,14 @@
 
 - (void)drawWithBox:(PDFDisplayBox)box inContext:(CGContextRef)context {
     if ([self drawsImage] && [self hasAppearanceStream] == NO && [self image] 
!= nil) {
+        NSRect bounds = [self bounds];
         CGContextSaveGState(context);
         [[self page] transformContext:context forBox:box];
         UIGraphicsPushContext(context);
-        [[self image] drawInRect:[self bounds]];
+        CGContextTranslateCTM(context, CGRectGetMinX(bounds), 
CGRectGetMaxY(bounds));
+        CGContextScaleCTM(context, 1.0, -1.0);
+        bounds.origin = CGRectZero;
+        [[self image] drawInRect:bounds];
         UIGraphicsPopContext(context);
         CGContextRestoreGState(context);
     } else {

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