summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2015-07-25 08:02:03 +0000
committerManolo Gouy <Manolo>2015-07-25 08:02:03 +0000
commit491938a4a94ba38c6ee26cdbeca0e90562496e42 (patch)
tree82fcdd0e6b74b7b80b8492e4e270560a58396583
parenta3e48a4afd6e0749da300b4a1728dd79b4627b84 (diff)
Make Fl_Copy_Surface work on Mac OS 10.3:
use different pasteboard data type names according to running OS. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10817 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl_cocoa.mm34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index bf8d5fdf8..436815476 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -3372,31 +3372,33 @@ void Fl_Copy_Surface::complete_copy_pdf_and_tiff()
CGContextRestoreGState(gc);
CGContextEndPage(gc);
CGContextRelease(gc);
+ static NSString *TIFFpname = (fl_mac_os_version >= 100600 ? @"public.tiff" : NSTIFFPboardType);
+ static NSString *PDFpname = (fl_mac_os_version >= 100600 ? @"com.adobe.pdf" : NSPDFPboardType);
NSPasteboard *clip = [NSPasteboard generalPasteboard];
- [clip declareTypes:[NSArray arrayWithObjects:@"com.adobe.pdf", @"public.tiff", nil] owner:nil];
- [clip setData:(NSData*)pdfdata forType:@"com.adobe.pdf"];
+ [clip declareTypes:[NSArray arrayWithObjects:PDFpname, TIFFpname, nil] owner:nil];
+ [clip setData:(NSData*)pdfdata forType:PDFpname];
//second, transform this PDF to a bitmap image and put it as tiff in clipboard
NSPDFImageRep *vectorial = [[NSPDFImageRep alloc] initWithData:(NSData*)pdfdata];
CFRelease(pdfdata);
- NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
- pixelsWide:width
- pixelsHigh:height
- bitsPerSample:8
- samplesPerPixel:3
- hasAlpha:NO
- isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bytesPerRow:width*4
- bitsPerPixel:32];
+ NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
+ pixelsWide:width
+ pixelsHigh:height
+ bitsPerSample:8
+ samplesPerPixel:3
+ hasAlpha:NO
+ isPlanar:NO
+ colorSpaceName:NSDeviceRGBColorSpace
+ bytesPerRow:width*4
+ bitsPerPixel:32];
memset([bitmap bitmapData], -1, [bitmap bytesPerRow] * [bitmap pixelsHigh]);
NSDictionary *dict = [NSDictionary dictionaryWithObject:bitmap
forKey:NSGraphicsContextDestinationAttributeName];
- NSGraphicsContext *oldgc = [NSGraphicsContext currentContext];
+ NSGraphicsContext *oldgc = [NSGraphicsContext currentContext];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithAttributes:dict]];
- [vectorial draw];
+ [vectorial draw];
[vectorial release];
- [NSGraphicsContext setCurrentContext:oldgc];
- [clip setData:[bitmap TIFFRepresentation] forType:@"public.tiff"];
+ [NSGraphicsContext setCurrentContext:oldgc];
+ [clip setData:[bitmap TIFFRepresentation] forType:TIFFpname];
[bitmap release];
}