Menu

#2 256 and 512 sizes not working

open
nobody
None
7
2010-01-24
2010-01-24
Anonymous
No

Hi,
Whenever I try to use kIconServices512PixelDataARGB and kIconServices256PixelDataARGB on the newest (0.9.4) version with the method:
- (NSBitmapImageRep*) bitmapImageRepWithAlphaForIconFamilyElement:(OSType)elementType

It returns nothing. Could you please verify and get back to me?

Discussion

  • Troy Stephens

    Troy Stephens - 2010-02-03

    Hi Alex,

    Mac OS X 10.6 introduced a regression in the GetIconFamilyData() function on which this method depends, that causes fetches of kIconServices512PixelDataARGB and kIconServices256PixelDataARGB IconFamily elements to fail. (See http://www.openradar.appspot.com/7177295 )

    A little bird has informed me that the next 10.6 Software Update is likely to fix this regression.

    In the meantime, a possible workaround, as mentioned at the bug report link above, is to draw the IconFamily into a bitmapped graphics context. If you need exact pixel value fidelity in the result, you may need to take care to use the correct color space when creating the destination bitmap (I'm not sure offhand what that colorspace would be when dealing with Icon Services data -- possibly NSDeviceRGBColorSpace?).

    I may attempt such a workaround in the trunk sources if I can find time to, but my workload might prevent me from doing so soon. If I do, I'll post an update here; meanwhile, I hope the above workaround suggestion will help you if you need an immediate fix.

    Essentially it would look like:
    1. Create an NSBitmapImageRep the pixel dimensions of the element you want (256x256 or 512x512), in a bitmapcontext-compatible format (32-bit ARGB should do)
    2. Create a bitmap context using [NSGraphicsContext graphicsContextWithBitmapImageRep:theBitmap]]
    3. Draw the icon into the context. PlotIconRefInContext() is probably what you want, and (CGContextRef)[theBitmapContext graphicsPort is the CGContextRef you'd pass to it. You'll probably need to obtain an IconRef from the IconFamilyHandle -- I'm not sure if there's API for this somewhere?

    The NSBitmapImageRep should then hold a copy of the desired IconFamily element.

    Hopefully the GetIconFamilyData() fix will be out in an SU soon. Meanwhile, I hope this info helps.

    Regards & sorry about the confusion,
    Troy

     

Log in to post a comment.

MongoDB Logo MongoDB