Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to grab IconRef from a .tiff file.



On 8/20/03 7:38 PM, Mike Kluev didst favor us with:

> On 20/08/2003 01:45, "Jiang, Juwan" <email@hidden> wrote:
>
>> I want to use ImageWell to show a Image.
>> I want to grab the IconRef from a .tiff file and show it into ImageWell.
>>
>> I do not let user select the file, but bundle the .tiff file into resource.
>> Then I can call CFBundleCopyResourceURL to get the URL of the file.
>> So what I want to know is how to get the IconRef from the the file.
>
> You may try the fragment below (untested). Basically it does
> (tries to do):
>
> FSRef-> FSSpec-> GraphicsImportComponent-> PicHandle->
> -> IconFamilyHandle-> IconRef
>
> // add error checking
> IconRef FileToIconRef(FSRef *fsRef)
> {
> GraphicsImportComponent component;
> OSStatus err;
> FSSpec fsSpec;
> PicHandle pict;
> IconFamilyHandle iconFamily;
> IconRef iconRef;
> const OSType kFakeCreator = '#%$^', kFakeType = '#$&$';

Hey, that's my creator signature! Okay, not really. ;-)
>
> err = FSGetCatalogInfo(fsRef, kFSCatInfoNone, NULL,
> NULL, &fsSpec, NULL);
>
> err = GetGraphicsImporterForFile(&fsSpec, &component);
> err = GraphicsImportSetGraphicsMode(component,
> graphicsModeStraightAlpha, NULL);

What does this line do? In my tests, this has no effect on the resulting
icon. For me, SetIconFamilyData always creates a solid black mask no matter
what I do. Am I missing something?

Larry

> err = GraphicsImportGetAsPicture(component, &pict);
> CloseComponent(component);
>
> iconFamily = (IconFamilyHandle)NewHandle(0);
> err = SetIconFamilyData(iconFamily, 'PICT', (Handle)pict);
> KillPicture(pict);
> err = RegisterIconRefFromIconFamily(kFakeCreator, kFakeType,
> iconFamily, &iconRef);
> DisposeHandle((Handle)iconFamily);
> err = AcquireIconRef(iconRef);
> err = UnregisterIconRef(kFakeCreator, kFakeType);
> return iconRef;
> }
>
> Mike
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: How to grab IconRef from a .tiff file. (From: Mike Kluev <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.