Re: Using NSImage in a tool
Re: Using NSImage in a tool
- Subject: Re: Using NSImage in a tool
- From: Charles Steinman <email@hidden>
- Date: Mon, 25 Jun 2007 21:30:39 -0700 (PDT)
If you're going to call any AppKit methods from a
non-NSApplication-based program, you'll want to call
NSApplicationLoad() first. I think that will solve
your problem.
Cheers,
Chuck
--- Matt Mashyna <email@hidden> wrote:
> I'm trying to use the IconFamily class from Troy
> Stephens, Thomas
> Schnitzer, David Remahl, Nathan Day and Ben Haller
> in a Foundation
> Tool project. When I use the code in Cocoa
> application, I have an
> NSImageView that I can drop files on to and later
> use the NSImage
> from it to make an icns file. Works fine with the
> GUI. When I try to
> use the same code in a Foundation Tool it crashes.
>
>
> When I use the same code without a GUI (maybe that's
> not really the
> problem) I seem to get a crash from trying to call
> lockFocus even
> though newImage is not nil and appears in the
> debugger to be
> requested size.
>
> newImage = [[NSImage alloc]
> initWithSize:NSMakeSize
> (iconWidth,iconWidth)];
> [newImage lockFocus];
>
> Thread 0 Crashed:
> 0 com.apple.Foundation 0x9282347f _NSRaiseError +
> 227
> 1 com.apple.Foundation 0x9284a23f +[NSException
> raise:format:] + 57
> 2 com.apple.AppKit 0x932c72ae _NXCreateWindow
> + 308
> 3 com.apple.AppKit 0x932c709a
> CreateWindowNamed + 166
> 4 com.apple.AppKit 0x932c6cef
> NewCacheWindowInfo + 76
> 5 com.apple.AppKit 0x932c6847
> _NXAllocateImageCache + 1425
> 6 com.apple.AppKit 0x932c5f8a
> -[NSCachedImageRep
> _initWithSize:depth:separate:alpha:allowDeep:] + 350
> 7 com.apple.AppKit 0x932c5e26
> -[NSCachedImageRep
> initWithSize:depth:separate:alpha:] + 78
> 8 com.apple.AppKit 0x932c5d25 -[NSImage
> lockFocus] + 285
> 9 makeIcon 0x00006239 +[IconFamily
> resampleImage:toIconWidth:usingImageInterpolation:]
> + 770
> 10 makeIcon 0x00006595 -[IconFamily
> initWithThumbnailsOfImage:usingImageInterpolation:]
> + 423
> 11 makeIcon 0x0000407d -[IconFamily
> initWithThumbnailsOfImage:] + 41
> 12 makeIcon 0x00001ea6 makeIcnsFile +
> 104
>
>
> My app is a tool and doesn't have a GUI so it seems
> like a call to
> CreateWindowNamed is probably not a good thing to
> need to call. What
> I am ultimately trying to do is load an NSImage from
> a URL, rescale
> it and get it into a NSBitmapImageRep that I can use
> to make an icon
> with.
>
> While I seem to be able to load an NSImage from an
> image file URL, I
> can't lock focus on an NSImage to change it. I must
> be missing a
> step. Can someone help me out ?
>
>
> Matt
> _______________________________________________
>
> 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
>
____________________________________________________________________________________
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367
_______________________________________________
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