Hi everyone.
I am ordered to save a NSView hosting the arbitrary number of core animation layers. Although there are many tutorials about how to save the content of a NSView, I can find nothing about saving the content of the layer embedded in a NSVIew.

First I tried to use the following code to save the content of the NSVIew. In my opinion, if the content is saved, the layers in the NSView may be saved as well.

NSView* _tempView = [_window contentView];
        NSRect _tempRect = [[_window contentView] frame];
if ([[_tempView dataWithPDFInsideRect:_tempRect ] writeToFile:resultString atomically:YES] ) {
                printf("Image Saved\n");
        }
Yes, the result of the above code is "Image Saved". However, the result image is valueless --- it is blank... :-(
Then I tried another method:
NSImage* intermediateImage = [[NSImage alloc] initWithSize:
                NSMakeSize([[_window contentView] frame].size.width,
[[_window contentView] frame].size.height)];
[intermediateImage addRepresentation:
         [[_window contentView] bitmapImageRepForCachingDisplayInRect:
         [[_window contentView] frame]]
         ];
        
        NSData* _imageData = [intermediateImage TIFFRepresentation];
if ([_imageData writeToFile:resultString atomically:YES] ) {
                printf("Image Saved\n");
}



I got a failed result too... The saved image is a blank file.
Can anyone here give me a help to solve this issue? Thank you very much for any help.

Have a good day. :-)

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to