Q:
I have a number of image files which contain embedded ICC
profiles. I'm using the QuickTime Graphics Importer/Exporter
routines to import and manipulate the images, then export
them into different formats. However, once I export the images
I notice the ICC profiles are lost. What can I do to preserve
the profiles?
A: You'll need to first save-off the embedded profile using
the GraphicsImportGetColorSyncProfile function when the image is imported,
then embed this same profile in the image using the GraphicsExportSetColorSyncProfile
function when the export operation is performed. Listing 1 shows how
this is done.
OSErr err;
FSSpec importFile, outputFile;
GraphicsImportComponent importer;
GraphicsExportComponent exporter;
Handle profHandle = NULL;
unsigned long actualSizeWritten;
err = GetGraphicsImporterForFile(&importFile, &importer);
if (err == noErr)
{
/* save the embedded profile */
err = GraphicsImportGetColorSyncProfile(importer, &profHandle);
/* get an exporter, then perform our image manipulations */
err = OpenADefaultComponent(GraphicsExporterComponentType,
kQTFileTypeTIFF, &exporter);
if (err == noErr)
{
err = GraphicsExportSetInputGraphicsImporter(exporter, importer);
err = GraphicsExportSetDepth (exporter, 24);
.
.
.
if (profHandle)
{
/* now restore the profile before
performing the export */
err = GraphicsExportSetColorSyncProfile(exporter, profHandle);
}
/* perform the export operation */
err = GraphicsExportSetOutputFile(exporter, &outputFile);
err = GraphicsExportDoExport(exporter, &actualSizeWritten);
}
.
.
.
if (profHandle)
{
DisposeHandle(profHandle);
}
}
|
Listing 1. Code showing how to preserve the ICC profile embedded in
a document when using the QuickTime Graphics Importer/Exporter
routines
|
[Sep 04 2002]
|