• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Plotting icons into NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: bindings, nested arrays and validation
  • Next by Date: Re: adjusting subviews : NSTextView in NSScrollView in NSTabViewItem
  • Previous by thread: Mac Developers needed for UK Ireland & Belgium
  • Next by thread: Bindings behavior when both NSValueTransformerNameBindingOption and NSValueTransformerBindingOption are present?
  • Index(es):
    • Date
    • Thread