FROM : Daniel Dalquen
DATE : Mon Apr 30 18:55:52 2007
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
DATE : Mon Apr 30 18:55:52 2007
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
| Related mails | Author | Date |
|---|---|---|
| Daniel Dalquen | Apr 30, 18:55 | |
| Uli Kusterer | May 2, 21:54 | |
| Daniel Dalquen | May 2, 23:06 | |
| Matt Neuburg | May 4, 20:04 |






Cocoa mail archive

