Plotting icons into NSImage
Plotting icons into NSImage
- Subject: Plotting icons into NSImage
- From: Daniel Dalquen <email@hidden>
- Date: Mon, 30 Apr 2007 18:55:52 +0200
Hello everybody!
I am running into problems when plotting an IconRef into an NSImage.
Here is the piece of code I am using:
IconRef ref;
err = GetIconRefFromFileInfo (&fsref, fname.length, fname.unicode,
kIconServicesCatalogInfoMask, &catinfo,
kIconServicesNormalUsageFlag, &ref, &label);
if (err == noErr)
{
CGRect myRect = CGRectMake(0,0,128,128);
NSImage* image = [[NSImage alloc] initWithSize:NSMakeSize
(128,128)];
[image lockFocus];
PlotIconRefInContext((CGContextRef)[[NSGraphicsContext
currentContext]
graphicsPort],&myRect,kAlignNone,kTransformNone,NULL,kPlotIconRefNormalF
lags,ref);
[image unlockFocus];
NSData * imageData = [image TIFFRepresentation];
[imageData writeToFile:@"/Users/daniel/Desktop/myicon.tif"
atomically:YES];
When I open myicon.tif in Preview, the icon is on top of a black
background. I thought it might be the alpha channel, but then Preview
should be able to deal with transparency... What is it that goes wrong?
Cheers,
Daniel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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