Skip to content

Instantly share code, notes, and snippets.

View sandymc's full-sized avatar

Sandy McGuffog sandymc

View GitHub Profile
@sandymc
sandymc / CreateTransform.m
Last active September 3, 2020 23:25
This code snippet shows how to convert an image buffer between color spaces (e.g., transform from ProPhoto to sRGB or whatever) using Apple's new (and entirely undocumented) ColorSyncTransformConvert function. Firstly, a transform is created, then that transform is used to convert an image buffer.
const void *keys[] = {kColorSyncProfile, kColorSyncRenderingIntent, kColorSyncTransformTag};
const void *srcVals[] = {[srcProfile ref], kColorSyncRenderingIntentUseProfileHeader, kColorSyncTransformDeviceToPCS};
const void *dstVals[] = {[destProfile ref], kColorSyncRenderingIntentUseProfileHeader, kColorSyncTransformPCSToDevice};
CFDictionaryRef srcDict = CFDictionaryCreate (
NULL,
(const void **)keys,
(const void **)srcVals,
3,