• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
nil there not here
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: nil there not here
      • From: David Duncan <email@hidden>
    • Re: nil there not here
      • From: Dave Carrigan <email@hidden>
    • Re: nil there not here More Info
      • From: David Blanton <email@hidden>
  • Prev by Date: NSXMLDocument and schema validation (Not finding schema document?)
  • Next by Date: Re: How to set the string and integer value of an NSButtonCell using NSOutilneView
  • Previous by thread: NSXMLDocument and schema validation (Not finding schema document?)
  • Next by thread: Re: nil there not here More Info
  • Index(es):
    • Date
    • Thread