• 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
Re: Adding text to NSImage using lockFocus/unlockFocus not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • RE: Adding text to NSImage using lockFocus/unlockFocus not working
      • From: "Ashish Tiwari" <email@hidden>
References: 
 >Adding text to NSImage using lockFocus/unlockFocus not working (From: "Ashish Tiwari" <email@hidden>)
 >Re: Adding text to NSImage using lockFocus/unlockFocus not working (From: Graham Cox <email@hidden>)
 >Re: Adding text to NSImage using lockFocus/unlockFocus not working (From: email@hidden)

  • Prev by Date: Re: plug-in
  • Next by Date: Re: Stop edit session with a NSTextField
  • Previous by thread: Re: Adding text to NSImage using lockFocus/unlockFocus not working
  • Next by thread: RE: Adding text to NSImage using lockFocus/unlockFocus not working
  • Index(es):
    • Date
    • Thread