gdi32: Move GetICMProfile to the driver.

This commit is contained in:
Hans Leidekker 2008-03-05 15:57:21 +01:00 committed by Alexandre Julliard
parent 459b92a009
commit 81e9b43fb2
7 changed files with 71 additions and 40 deletions

View File

@ -116,6 +116,7 @@ static struct graphics_driver *create_driver( HMODULE module )
GET_FUNC(GetDIBits); GET_FUNC(GetDIBits);
GET_FUNC(GetDeviceCaps); GET_FUNC(GetDeviceCaps);
GET_FUNC(GetDeviceGammaRamp); GET_FUNC(GetDeviceGammaRamp);
GET_FUNC(GetICMProfile);
GET_FUNC(GetNearestColor); GET_FUNC(GetNearestColor);
GET_FUNC(GetPixel); GET_FUNC(GetPixel);
GET_FUNC(GetPixelFormat); GET_FUNC(GetPixelFormat);

View File

@ -75,6 +75,7 @@ static const DC_FUNCTIONS EMFDRV_Funcs =
NULL, /* pGetDIBits */ NULL, /* pGetDIBits */
EMFDRV_GetDeviceCaps, /* pGetDeviceCaps */ EMFDRV_GetDeviceCaps, /* pGetDeviceCaps */
NULL, /* pGetDeviceGammaRamp */ NULL, /* pGetDeviceGammaRamp */
NULL, /* pGetICMProfile */
NULL, /* pGetNearestColor */ NULL, /* pGetNearestColor */
NULL, /* pGetPixel */ NULL, /* pGetPixel */
NULL, /* pGetPixelFormat */ NULL, /* pGetPixelFormat */

View File

@ -140,6 +140,7 @@ typedef struct tagDC_FUNCS
INT (*pGetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPVOID,BITMAPINFO*,UINT); INT (*pGetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPVOID,BITMAPINFO*,UINT);
INT (*pGetDeviceCaps)(PHYSDEV,INT); INT (*pGetDeviceCaps)(PHYSDEV,INT);
BOOL (*pGetDeviceGammaRamp)(PHYSDEV,LPVOID); BOOL (*pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
BOOL (*pGetICMProfile)(PHYSDEV,LPDWORD,LPWSTR);
COLORREF (*pGetNearestColor)(PHYSDEV,COLORREF); COLORREF (*pGetNearestColor)(PHYSDEV,COLORREF);
COLORREF (*pGetPixel)(PHYSDEV,INT,INT); COLORREF (*pGetPixel)(PHYSDEV,INT,INT);
INT (*pGetPixelFormat)(PHYSDEV); INT (*pGetPixelFormat)(PHYSDEV);

View File

@ -30,6 +30,8 @@
#include "winnls.h" #include "winnls.h"
#include "winreg.h" #include "winreg.h"
#include "gdi_private.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"
@ -97,51 +99,18 @@ BOOL WINAPI GetICMProfileA(HDC hdc, LPDWORD size, LPSTR filename)
*/ */
BOOL WINAPI GetICMProfileW(HDC hdc, LPDWORD size, LPWSTR filename) BOOL WINAPI GetICMProfileW(HDC hdc, LPDWORD size, LPWSTR filename)
{ {
HKEY hkey; BOOL ret = FALSE;
DWORD required; DC *dc = get_dc_ptr(hdc);
WCHAR profile[MAX_PATH], fullname[MAX_PATH];
static const WCHAR path[] =
{'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s',
'\\','c','o','l','o','r','\\',0};
static const WCHAR srgb[] =
{'s','R','G','B',' ','C','o','l','o','r',' ','S','p','a','c','e',' ',
'P','r','o','f','i','l','e','.','i','c','m',0};
static const WCHAR mntr[] =
{'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t',
'V','e','r','s','i','o','n','\\','I','C','M','\\','m','n','t','r',0};
TRACE("%p, %p, %p\n", hdc, size, filename); TRACE("%p, %p, %p\n", hdc, size, filename);
if (!hdc || !size) return FALSE; if (dc)
strcpyW(profile, srgb);
if (!RegCreateKeyExW(HKEY_LOCAL_MACHINE, mntr, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL))
{ {
DWORD size = sizeof(profile) / sizeof(WCHAR); if (dc->funcs->pGetICMProfile)
/* FIXME handle multiple values */ ret = dc->funcs->pGetICMProfile(dc->physDev, size, filename);
RegEnumValueW(hkey, 0, profile, &size, NULL, NULL, NULL, NULL); release_dc_ptr(dc);
RegCloseKey(hkey);
} }
GetSystemDirectoryW(fullname, MAX_PATH); return ret;
strcatW(fullname, path);
strcatW(fullname, profile);
required = strlenW(fullname) + 1;
if (*size < required)
{
*size = required;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
if (filename)
{
strcpyW(filename, fullname);
if (GetFileAttributesW(filename) == INVALID_FILE_ATTRIBUTES)
WARN("color profile not found\n");
}
*size = required;
return TRUE;
} }
/********************************************************************** /**********************************************************************

View File

@ -75,6 +75,7 @@ static const DC_FUNCTIONS MFDRV_Funcs =
NULL, /* pGetDIBits */ NULL, /* pGetDIBits */
MFDRV_GetDeviceCaps, /* pGetDeviceCaps */ MFDRV_GetDeviceCaps, /* pGetDeviceCaps */
NULL, /* pGetDeviceGammaRamp */ NULL, /* pGetDeviceGammaRamp */
NULL, /* pGetICMProfile */
NULL, /* pGetNearestColor */ NULL, /* pGetNearestColor */
NULL, /* pGetPixel */ NULL, /* pGetPixel */
NULL, /* pGetPixelFormat */ NULL, /* pGetPixelFormat */

View File

@ -25,6 +25,7 @@
#include "config.h" #include "config.h"
#include <stdarg.h>
#include <math.h> #include <math.h>
#ifdef HAVE_FLOAT_H #ifdef HAVE_FLOAT_H
# include <float.h> # include <float.h>
@ -35,9 +36,14 @@
#endif #endif
#include <string.h> #include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "x11drv.h" #include "x11drv.h"
#include "x11font.h" #include "x11font.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(graphics); WINE_DEFAULT_DEBUG_CHANNEL(graphics);
@ -1374,3 +1380,54 @@ DWORD X11DRV_SetDCOrg( X11DRV_PDEVICE *physDev, INT x, INT y )
physDev->dc_rect.top = y - physDev->drawable_rect.top; physDev->dc_rect.top = y - physDev->drawable_rect.top;
return ret; return ret;
} }
/***********************************************************************
* GetICMProfile (X11DRV.@)
*/
BOOL X11DRV_GetICMProfile( X11DRV_PDEVICE *physDev, LPDWORD size, LPWSTR filename )
{
static const WCHAR path[] =
{'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s',
'\\','c','o','l','o','r','\\',0};
static const WCHAR srgb[] =
{'s','R','G','B',' ','C','o','l','o','r',' ','S','p','a','c','e',' ',
'P','r','o','f','i','l','e','.','i','c','m',0};
static const WCHAR mntr[] =
{'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t',
'V','e','r','s','i','o','n','\\','I','C','M','\\','m','n','t','r',0};
HKEY hkey;
DWORD required;
WCHAR profile[MAX_PATH], fullname[MAX_PATH];
if (!size) return FALSE;
strcpyW( profile, srgb );
if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, mntr, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL ))
{
DWORD len = sizeof(profile)/sizeof(WCHAR);
/* FIXME handle multiple values */
RegEnumValueW( hkey, 0, profile, &len, NULL, NULL, NULL, NULL );
RegCloseKey( hkey );
}
GetSystemDirectoryW( fullname, MAX_PATH );
strcatW( fullname, path );
strcatW( fullname, profile );
required = strlenW( fullname ) + 1;
if (*size < required)
{
*size = required;
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return FALSE;
}
if (filename)
{
strcpyW( filename, fullname );
if (GetFileAttributesW( filename ) == INVALID_FILE_ATTRIBUTES)
WARN( "color profile not found\n" );
}
*size = required;
return TRUE;
}

View File

@ -22,6 +22,7 @@
@ cdecl GetDIBits(ptr long long long ptr ptr long) X11DRV_GetDIBits @ cdecl GetDIBits(ptr long long long ptr ptr long) X11DRV_GetDIBits
@ cdecl GetDeviceCaps(ptr long) X11DRV_GetDeviceCaps @ cdecl GetDeviceCaps(ptr long) X11DRV_GetDeviceCaps
@ cdecl GetDeviceGammaRamp(ptr ptr) X11DRV_GetDeviceGammaRamp @ cdecl GetDeviceGammaRamp(ptr ptr) X11DRV_GetDeviceGammaRamp
@ cdecl GetICMProfile(ptr ptr ptr) X11DRV_GetICMProfile
@ cdecl GetNearestColor(ptr long) X11DRV_GetNearestColor @ cdecl GetNearestColor(ptr long) X11DRV_GetNearestColor
@ cdecl GetPixel(ptr long long) X11DRV_GetPixel @ cdecl GetPixel(ptr long long) X11DRV_GetPixel
@ cdecl GetPixelFormat(ptr) X11DRV_GetPixelFormat @ cdecl GetPixelFormat(ptr) X11DRV_GetPixelFormat