nil there not here
nil there not here
- Subject: nil there not here
- From: David Blanton <email@hidden>
- Date: Mon, 27 Jul 2009 15:44:37 -0600
I create a CGImageRef and store it
When I get around to using it, it is nil
My code is below ... fire away, please!
#import "MyDocumentView.h"
@interface MyDocument : NSDocument
{
MyDocumentView* _myDocumentView;
}
@end
- (id)init
{
self = [super init];
if (self) {
// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and
return nil.
_myDocumentView = [[MyDocumentView alloc] init];
[_myDocumentView retain];
}
return self;
}
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:
(NSError **)outError
context = CGBitmapContextCreate (bitmap.m_array, bitmap.m_pixelsx,
bitmap.m_pixelsy, 8, bitmap.m_pixelsx * 4, colorSpace,
kCGImageAlphaNoneSkipFirst|kCGBitmapByteOrder32Host);
CGImageRelease(_myDocumentView->_cgImageRef);
_myDocumentView->_cgImageRef = CGBitmapContextCreateImage (context);
CGImageRetain(_myDocumentView->_cgImageRef);
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
at this point _myDocumentView->_cgImageRef is not nil
@interface MyDocumentView : NSView {
@public
CGImageRef _cgImageRef;
}
@end
@implementation MyDocumentView
- (void)drawRect:(NSRect)dirtyRect {
if(_cgImageRef) HERE _cgImageRef is nil
{
NSGraphicsContext *graphicsContext = [NSGraphicsContext
currentContext];
CGContextRef context = (CGContextRef)[graphicsContext graphicsPort];
CGRect r;
r = CGRectMake(dirtyRect.origin.x , dirtyRect.origin.y ,
dirtyRect.size.width, dirtyRect.size.width);
CGContextDrawImage(context, r, _cgImageRef);
}
}
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden