From 491938a4a94ba38c6ee26cdbeca0e90562496e42 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sat, 25 Jul 2015 08:02:03 +0000 Subject: 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 --- src/Fl_cocoa.mm | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src') 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]; } -- cgit v1.2.3