So am I right in believing that drawRect: should not need to be explicitly called in each subview from within my custom view's drawRect:? In any case, see if you can make sense of this...

// This is in my controller:
- (IBAction) saveAllVisualizations: (id)sender
{
        NSRect pRect = NSMakeRect(0, 0, 480, 640);
        PlantView *pView = [[PlantView alloc] initWithFrame: pRect];
NSManagedObjectContext *context = [[NSApp delegate] managedObjectContext];
        
        NSFetchRequest *fetchAllPersons = [[NSFetchRequest alloc] init];
[fetchAllPersons setEntity: [NSEntityDescription entityForName:@"Person" inManagedObjectContext:context]];
        
for (PersonMO *p in [context executeFetchRequest:fetchAllPersons error:nil])
        {
                [pView save:p];
        }
}

// This is in my custom view:
- (IBAction) save: (id) sender
{       
        NSString *personName = [sender name];

        NSRect pRect = NSMakeRect(0, 0, 480, 640);
        NSBitmapImageRep* offscreenRep = nil;
        offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
                                                                                
                                   pixelsWide:pRect.size.width
                                                                                
                                   pixelsHigh:pRect.size.height
                                                                                
                                bitsPerSample:8
                                                                                
                          samplesPerPixel:4
                                                                                
                                         hasAlpha:YES
                                                                                
                                         isPlanar:NO
                                                                                
                           colorSpaceName:NSCalibratedRGBColorSpace
                                                                                
                                 bitmapFormat:0
                                                                                
                                  bytesPerRow:(4 * pRect.size.width)
                                                                                
                                 bitsPerPixel:32];
        [NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:offscreenRep]];

        [self drawRect:pRect];

NSString *fileName = [NSString stringWithFormat: @"~/Desktop/%...@.jpg", personName];
        NSString *filePath = [fileName stringByExpandingTildeInPath];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithFloat:1.0], NSImageCompressionFactor, nil];
        
NSData *data = [offscreenRep representationUsingType:NSJPEGFileType properties:dict];
        [data writeToFile:filePath atomically:YES];     
        
        [NSGraphicsContext restoreGraphicsState];
}



On Dec 29, 2008, at 4:53 PM, I. Savant wrote:

On Mon, Dec 29, 2008 at 4:41 PM, John Kestner <jkest...@media.mit.edu> wrote:
Yep, they're actual subviews nested in my custom view, double- checked by
going to list view in IB.

 You may need to post your "Save All Visualizations" code. This is
hard to "visualize" without it (pun intended).

_______________________________________________

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 arch...@mail-archive.com

Reply via email to