public static unsafe SafeProfileHandle CreateProfileFromLogicalColorSpace(BITMAPV5HEADER info) { // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-logcolorspacew var lcs = new LOGCOLORSPACE { lcsCSType = ColorSpaceType.LCS_CALIBRATED_RGB, lcsVersion = 0x400, lcsSignature = 0x50534F43, // 'PSOC' lcsFilename = "\0", lcsIntent = info.bV5Intent, lcsEndpoints_1x = info.bV5Endpoints_1x, lcsEndpoints_1y = info.bV5Endpoints_1y, lcsEndpoints_1z = info.bV5Endpoints_1z, lcsEndpoints_2x = info.bV5Endpoints_2x, lcsEndpoints_2y = info.bV5Endpoints_2y, lcsEndpoints_2z = info.bV5Endpoints_2z, lcsEndpoints_3x = info.bV5Endpoints_3x, lcsEndpoints_3y = info.bV5Endpoints_3y, lcsEndpoints_3z = info.bV5Endpoints_3z, lcsGammaBlue = info.bV5GammaBlue, lcsGammaGreen = info.bV5GammaGreen, lcsGammaRed = info.bV5GammaRed, }; var success = CreateProfileFromLogColorSpace(ref lcs, out var hGlobal); if (!success) { throw new Win32Exception(); } var hsize = GlobalSize(hGlobal); var hptr = GlobalLock(hGlobal); try { return(OpenProfile((void *)hptr, (uint)hsize)); } finally { GlobalUnlock(hGlobal); GlobalFree(hGlobal); } }
private static extern bool CreateProfileFromLogColorSpace(ref LOGCOLORSPACE pLogColorSpace, out IntPtr pProfile);