Add SDL_GetWindowICCProfile(). (#4314)

* Add SDL_GetWindowICCProfile

* Add new SDL display events

* Implement ICC profile change event for macOS

* Implement ICC profile notification for Windows

* Fix SDL_GetWindowICCProfile() for X11

* Fix compile errors
This commit is contained in:
Cacodemon345
2021-10-22 06:37:20 +06:00
committed by GitHub
parent a34fe8161f
commit 19dee1cd16
18 changed files with 261 additions and 1 deletions

View File

@@ -725,6 +725,32 @@ WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
return succeeded ? 0 : -1;
}
void*
WIN_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size)
{
SDL_VideoDisplay* display = SDL_GetDisplayForWindow(window);
SDL_DisplayData* data = (SDL_DisplayData*)display->driverdata;
HDC hdc;
BOOL succeeded = FALSE;
WCHAR filename[MAX_PATH];
DWORD fileNameSize = MAX_PATH;
void* iccProfileData = NULL;
hdc = CreateDCW(data->DeviceName, NULL, NULL, NULL);
if (hdc) {
succeeded = GetICMProfileW(hdc, &fileNameSize, filename);
DeleteDC(hdc);
}
if (succeeded) {
iccProfileData = SDL_LoadFile(WIN_StringToUTF8(filename), size);
if (!iccProfileData)
SDL_SetError("Could not open ICC profile");
}
return iccProfileData;
}
int
WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
{