mirror of https://github.com/fltk/fltk
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
This commit is contained in:
parent
a3e48a4afd
commit
491938a4a9
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue