* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "include/core/SkStream.h"
#if defined(SK_BUILD_FOR_MAC)
#include <ApplicationServices/ApplicationServices.h>
#elif defined(SK_BUILD_FOR_WIN)
#include <windows.h>
#endif
int main(int argc, char** argv) {
#if defined(SK_BUILD_FOR_MAC)
CGColorSpaceRef cs = CGDisplayCopyColorSpace(CGMainDisplayID());
CFDataRef dataRef = CGColorSpaceCopyICCProfile(cs);
const uint8_t* data = CFDataGetBytePtr(dataRef);
size_t size = CFDataGetLength(dataRef);
SkFILEWStream file("monitor_0.icc");
file.write(data, size);
CFRelease(cs);
CFRelease(dataRef);
return 0;
#elif defined(SK_BUILD_FOR_WIN)
DISPLAY_DEVICE dd = { sizeof(DISPLAY_DEVICE) };
SkString outputFilename;
for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) {
if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) {
HDC dc = CreateDC(NULL, dd.DeviceName, NULL, NULL);
if (dc) {
char icmPath[MAX_PATH + 1];
DWORD pathLength = MAX_PATH;
if (GetICMProfile(dc, &pathLength, icmPath)) {
outputFilename = SkStringPrintf("monitor_%d.icc", i);
CopyFile(icmPath, outputFilename.c_str(), FALSE);
}
DeleteDC(dc);
}
}
}
return 0;
#else
SkDebugf("ERROR: Unsupported platform\n");
return 1;
#endif
}