{Solved]: Adding text to NSImage using lockFocus/unlockFocus not working
{Solved]: Adding text to NSImage using lockFocus/unlockFocus not working
- Subject: {Solved]: Adding text to NSImage using lockFocus/unlockFocus not working
- From: "Ashish Tiwari" <email@hidden>
- Date: Wed, 25 Feb 2009 13:50:24 +0530
I just figured it out, everything was ok with code the problem was at
Interface Builder. I had not checked title and subtitle properties of
IKImageBrowserView at Interface builder. Once I did so all methods that were
not being called got called and image with title appeared at
ImageBrowserView.
Thanks a lot Graham,
Ashish
-----Original Message-----
From: Ashish Tiwari
Sent: Wednesday, February 25, 2009 1:29 PM
I am sorry for typo, actually only images are shown *without titles. I want
to see image as well as their title.
Mean while I added your imageAttributes in IKBrowserItem.m with no luck.
I put various NSLog and looked in console to find out that
imageTitle, imageSubtitle, imageAttributes are not getting called. Just
imageUID, imageRepresentation and imageRepresentationType methods are being
called.
Is this correct behavior.
Ashish
-----Original Message-----
From: Graham Cox
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