I'm trying to capture the icon information for the current keyboard
input source, using the following code:
IconRef keyboardIcon =
TISGetInputSourceProperty(currentInputSource, kTISPropertyIconRef);
if (keyboardIcon != NULL) {
NSImage *iconImage = [[NSImage alloc]
initWithIconRef:keyboardIcon];
NSArray *iconImageReps = [iconImage representations];
NSInteger iconImageCount = [iconImageReps count];
iconData = [NSMutableData data];
CGImageDestinationRef imageDestination =
CGImageDestinationCreateWithData((__bridge CFMutableDataRef)iconData,
kUTTypeAppleICNS, iconImageCount, nil);
for (NSImageRep *imageRep in iconImageReps) {
NSSize imageSize = [imageRep size];
NSRect imageRect = NSMakeRect(0, 0, imageSize.width,
imageSize.height);
CGImageRef imageRef = [imageRep
CGImageForProposedRect:&imageRect context:nil hints:nil];
CGImageDestinationAddImage(imageDestination, imageRef,
nil);
}
CGImageDestinationFinalize(imageDestination);
CFRelease(imageDestination);
}
However, I'm getting 15 images in the iconImageReps array, and
CGImageDestinationCreateWithData complains that an internal routine can
only handle 10 images. I suspect I haven't seen this before as this is
the first time I've run the code on a retina display Mac.
Should I be trying an alternate strategy? If so, what?
John
--
John Brownie, [email protected] or [email protected]
Summer Institute of Linguistics | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]