Implement NtAccessCheck.
[wine/gsoc-2012-control.git] / dlls / mscms / transform.c
blobab928172f96e6d59b855364d8a98b4b399dbd3ef
1 /*
2 * MSCMS - Color Management System for Wine
4 * Copyright 2005 Hans Leidekker
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/debug.h"
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winnls.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "icm.h"
33 #define LCMS_API_FUNCTION(f) extern typeof(f) * p##f;
34 #include "lcms_api.h"
35 #undef LCMS_API_FUNCTION
37 WINE_DEFAULT_DEBUG_CHANNEL(mscms);
39 HTRANSFORM WINAPI CreateColorTransformA( LPLOGCOLORSPACEA space, HPROFILE dest,
40 HPROFILE target, DWORD flags )
42 LOGCOLORSPACEW spaceW;
43 DWORD len;
45 TRACE( "( %p, %p, %p, 0x%08lx )\n", space, dest, target, flags );
47 if (!space || !dest) return FALSE;
49 memcpy( &spaceW, space, FIELD_OFFSET(LOGCOLORSPACEA, lcsFilename) );
50 spaceW.lcsSize = sizeof(LOGCOLORSPACEW);
52 len = MultiByteToWideChar( CP_ACP, 0, space->lcsFilename, -1, NULL, 0 );
53 MultiByteToWideChar( CP_ACP, 0, space->lcsFilename, -1, spaceW.lcsFilename, len );
55 return CreateColorTransformW( &spaceW, dest, target, flags );
58 HTRANSFORM WINAPI CreateColorTransformW( LPLOGCOLORSPACEW space, HPROFILE dest,
59 HPROFILE target, DWORD flags )
61 HTRANSFORM ret = NULL;
62 #ifdef HAVE_LCMS_H
63 cmsHTRANSFORM cmstransform;
64 cmsHPROFILE cmsprofiles[3];
65 int intent;
67 TRACE( "( %p, %p, %p, 0x%08lx )\n", space, dest, target, flags );
69 if (!space || !dest) return FALSE;
71 intent = space->lcsIntent > 3 ? INTENT_PERCEPTUAL : space->lcsIntent;
73 cmsprofiles[0] = cmsCreate_sRGBProfile(); /* FIXME: create from supplied color space */
74 cmsprofiles[1] = MSCMS_hprofile2cmsprofile( dest );
76 if (target)
78 cmsprofiles[2] = MSCMS_hprofile2cmsprofile( target );
79 cmstransform = cmsCreateMultiprofileTransform( cmsprofiles, 3, TYPE_BGR_8,
80 TYPE_BGR_8, intent, 0 );
82 else
84 cmstransform = cmsCreateTransform( cmsprofiles[0], TYPE_BGR_8, cmsprofiles[1],
85 TYPE_BGR_8, intent, 0 );
87 ret = MSCMS_create_htransform_handle( cmstransform );
89 #endif /* HAVE_LCMS_H */
90 return ret;
93 HTRANSFORM WINAPI CreateMultiProfileTransform( PHPROFILE profiles, DWORD nprofiles,
94 PDWORD intents, DWORD nintents, DWORD flags, DWORD cmm )
96 HTRANSFORM ret = NULL;
97 #ifdef HAVE_LCMS_H
98 cmsHPROFILE *cmsprofiles;
99 cmsHTRANSFORM cmstransform;
100 DWORD i;
102 TRACE( "( %p, 0x%08lx, %p, 0x%08lx, 0x%08lx, 0x%08lx ) stub\n",
103 profiles, nprofiles, intents, nintents, flags, cmm );
105 if (!profiles || !intents) return NULL;
107 cmsprofiles = HeapAlloc( GetProcessHeap(), 0, nprofiles * sizeof(cmsHPROFILE) );
109 if (cmsprofiles)
111 for (i = 0; i < nprofiles; i++)
112 cmsprofiles[i] = MSCMS_hprofile2cmsprofile( profiles[i] );
115 cmstransform = cmsCreateMultiprofileTransform( cmsprofiles, nprofiles, TYPE_BGR_8,
116 TYPE_BGR_8, *intents, 0 );
117 HeapFree( GetProcessHeap(), 0, cmsprofiles );
118 ret = MSCMS_create_htransform_handle( cmstransform );
120 #endif /* HAVE_LCMS_H */
121 return ret;
124 BOOL WINAPI DeleteColorTransform( HTRANSFORM transform )
126 BOOL ret = FALSE;
127 #ifdef HAVE_LCMS_H
128 cmsHTRANSFORM cmstransform;
130 TRACE( "( %p )\n", transform );
132 cmstransform = MSCMS_htransform2cmstransform( transform );
133 cmsDeleteTransform( cmstransform );
135 MSCMS_destroy_htransform_handle( transform );
136 ret = TRUE;
138 #endif /* HAVE_LCMS_H */
139 return ret;
142 BOOL WINAPI TranslateBitmapBits( HTRANSFORM transform, PVOID srcbits, BMFORMAT input,
143 DWORD width, DWORD height, DWORD inputstride, PVOID destbits, BMFORMAT output,
144 DWORD outputstride, PBMCALLBACKFN callback, ULONG data )
146 BOOL ret = FALSE;
147 #ifdef HAVE_LCMS_H
148 cmsHTRANSFORM cmstransform;
150 TRACE( "( %p, %p, 0x%08x, 0x%08lx, 0x%08lx, 0x%08lx, %p, 0x%08x, 0x%08lx, %p, 0x%08lx )\n",
151 transform, srcbits, input, width, height, inputstride, destbits, output,
152 outputstride, callback, data );
154 cmstransform = MSCMS_htransform2cmstransform( transform );
156 cmsDoTransform( cmstransform, srcbits, destbits, width * height );
157 ret = TRUE;
159 #endif /* HAVE_LCMS_H */
160 return ret;