Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Plotting icons into NSImage



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.