• 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
Re: Getting iPod icon, was Getting the network Machine Icon
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting iPod icon, was Getting the network Machine Icon


  • Subject: Re: Getting iPod icon, was Getting the network Machine Icon
  • From: Dave <email@hidden>
  • Date: Fri, 23 Jan 2009 16:34:42 +0000

Hi Jean,

On 23 Jan 2009, at 13:56, Jean-Daniel Dupas wrote:
An icns file can be opened using NSImage methods.
Then choose the representation you need and convert it to JPEG as you would do with any image.


If you want to go the "hard" way (that is not that hard):
Use ReadIconFromFSRef() to load the icns file.
Convert it into an FSRef using GetIconRefFromIconFamilyPtr().
And then draw it using PlotIconRefInContext().


Thanks for this. After looking around, I decided to do it the 'hard" way, since I already have most of the wrapper code I can steal from another module.


I have a question on this through. How do I fill in the parameters to the GetIconRefFromIconFamilyPtr() call? This is my code so far:

(There may be a few typeo's in this, but it compiles ok)


CGContextRef myBitMapContextRef; CGBitMapInfo myBitMapInfo; CGColorSpaceRef myColorSpaceRef; CGRect myImageRect; size_t myImageWidth; size_t myImageHeight; size_t myBitsPerComponent; size_t myNumberOfComponents; size_t myRowBytes; char* myImageBufferPtr; RGBColor myLabelRGBColor:

IconFamilyHandle 	myIconFamilyHandle;
IconRef				myIconRef;

// myFSRef is setup ok at this point

myIconFamilyHandle = NULL;
myOSErr = ReadIconFromFSRef(&myFSRef,&myIconFamilyHandle);
if (myOSErr != noErr)
	goto Error;

myOSErr = GetIconRefFromIconFamilyPtr (*myIconFamilyHandle,GetHandleSize(myIconFamilyHandle),&myIconRef);
if (myOSErr != noErr)
goto Error;


myBitMapInfo = kCGImageAlphaPremultipliedLast;
myImageWidth = 64;
myImageHeight = 64;
myBitsPerComponent = 8;
myNumberOfComponents = 4;
myRowBytes = COMPUTE_BEST_BYTES_PER_ROW(myImageWidth * (myBitsPerComponent / 8) * myNumberOfComponents);
myImageBufferPtr = malloc(myImageHeight, myRowBytes);
myColorSpaceRef = GCColorSpaceCreateWithName(kCGColorSpaceGenericRGB);


myBitMapContextRef = CGBitmapContextCreate (myImageBufferPtr,myImageWidth,myImageHeight,myBitsPerComponent,myRowByt es, myColorSpaceRef, myBitMapInfo);

CGContextClearRect(myBitMapContextRef,0,0,myWidth, myImageHeight)

myImageRect.origin.x = 0;
myImageRect.origin.y = 0;
myImageRect.size.width = myImageWidth;
myImageRect.size.height = myImageHeight;

myLabelRGBColor.red = 0;
myLabelRGBColor.green = 0;
myLabelRGBColor.blue = 0;
myOSErr = PlotIconRefInContext (myBitMapContextRef,&myImageRect,kAlignNone,kTransformNone, myLabelRGBColor,kPlotIconRefNormalFlags,myIconRef);


What should "myLabelRGBColor" be set to?

Also at this point, I'd like to get a pointer to the Pixel buffer in the CGContext and return this. The code I already have will write the JPEG file, all I need is a copy of the Pixel Data? Is there a way to do this?

Thanks a lot
All the Best
Dave


_______________________________________________

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


  • Follow-Ups:
    • Re: Getting iPod icon, was Getting the network Machine Icon
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >Getting the network Machine Icon (From: Sandro Noel <email@hidden>)
 >Getting iPod icon, was Getting the network Machine Icon (From: Dave <email@hidden>)
 >Re: Getting iPod icon, was Getting the network Machine Icon (From: Russell Hancox <email@hidden>)
 >Re: Getting iPod icon, was Getting the network Machine Icon (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Getting iPod icon, was Getting the network Machine Icon (From: "email@hidden" <email@hidden>)
 >Re: Getting iPod icon, was Getting the network Machine Icon (From: Dave <email@hidden>)
 >Re: Getting iPod icon, was Getting the network Machine Icon (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Zombies: "Not a Type release"
  • Next by Date: Re: Encryption: Simplest method to encrypt a SQLite DB file...? {iPhone}
  • Previous by thread: Re: Getting iPod icon, was Getting the network Machine Icon
  • Next by thread: Re: Getting iPod icon, was Getting the network Machine Icon
  • Index(es):
    • Date
    • Thread