Re: Adding text to NSImage using lockFocus/unlockFocus not working
Re: Adding text to NSImage using lockFocus/unlockFocus not working
- Subject: Re: Adding text to NSImage using lockFocus/unlockFocus not working
- From: Graham Cox <email@hidden>
- Date: Wed, 25 Feb 2009 16:35:21 +1100
On 25/02/2009, at 4:04 PM, email@hidden wrote:
Hi Graham,
I tried what you have suggested still only images are shown with
titles.
I'm not clear what the problem is - what did you expect to see?
- (NSString*) imageSubtitle
{
NSDictionary* attribs = [image imageAttributes];
int w, h;
w = [[attribs objectForKey:@"PixelWidth"] intValue];
h = [[attribs objectForKey:@"PixelHeight"] intValue];
return [NSString stringWithFormat:@"%d x %d", w, h];
}
This won't work - NSImage doesn't have a method called -
imageAttributes. In my code the attributes are retrieved using [self
imageAttributes], and that method looks like this:
- (NSDictionary*) imageAttributes
{
// returns the image's attributes dictionary using CGImageSource to
read the file's header. This is fast as the image
// itself isn't loaded.
NSURL* url = [NSURL fileURLWithPath:mPath];
CGImageSourceRef srcRef = CGImageSourceCreateWithURL((CFURLRef) url,
NULL );
NSDictionary* imgProps = (NSDictionary*)
CGImageSourceCopyPropertiesAtIndex( srcRef, 0, NULL);
CFRelease(srcRef);
//NSLog(@"attributes for '%@': %@", mPath, imgProps );
return [imgProps autorelease];
}
I suspect your method is asserting when it's called due to the
unimplemented method and that is stopping the browser view working
properly. Check your console output.
--Graham
_______________________________________________
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