change default iSmCaptionWidth to 12
[wine/kumbayo.git] / dlls / mscms / transform.c
blob0cc45052e8c77cf8eb34b4588cb8c4094757459b
1 /*
2 * MSCMS - Color Management System for Wine
4 * Copyright 2005, 2006 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 #include "mscms_priv.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mscms);
37 /******************************************************************************
38 * CreateColorTransformA [MSCMS.@]
40 * See CreateColorTransformW.
42 HTRANSFORM WINAPI CreateColorTransformA( LPLOGCOLORSPACEA space, HPROFILE dest,
43 HPROFILE target, DWORD flags )
45 LOGCOLORSPACEW spaceW;
46 DWORD len;
48 TRACE( "( %p, %p, %p, 0x%08x )\n", space, dest, target, flags );
50 if (!space || !dest) return FALSE;
52 memcpy( &spaceW, space, FIELD_OFFSET(LOGCOLORSPACEA, lcsFilename) );
53 spaceW.lcsSize = sizeof(LOGCOLORSPACEW);
55 len = MultiByteToWideChar( CP_ACP, 0, space->lcsFilename, -1, NULL, 0 );
56 MultiByteToWideChar( CP_ACP, 0, space->lcsFilename, -1, spaceW.lcsFilename, len );
58 return CreateColorTransformW( &spaceW, dest, target, flags );
61 /******************************************************************************
62 * CreateColorTransformW [MSCMS.@]
64 * Create a color transform.
66 * PARAMS
67 * space [I] Input color space.
68 * dest [I] Color profile of destination device.
69 * target [I] Color profile of target device.
70 * flags [I] Flags.
72 * RETURNS
73 * Success: Handle to a transform.
74 * Failure: NULL
76 HTRANSFORM WINAPI CreateColorTransformW( LPLOGCOLORSPACEW space, HPROFILE dest,
77 HPROFILE target, DWORD flags )
79 HTRANSFORM ret = NULL;
80 #ifdef HAVE_LCMS
81 cmsHTRANSFORM cmstransform;
82 cmsHPROFILE cmsprofiles[3];
83 int intent;
85 TRACE( "( %p, %p, %p, 0x%08x )\n", space, dest, target, flags );
87 if (!space || !dest) return FALSE;
89 intent = space->lcsIntent > 3 ? INTENT_PERCEPTUAL : space->lcsIntent;
91 cmsprofiles[0] = cmsCreate_sRGBProfile(); /* FIXME: create from supplied color space */
92 cmsprofiles[1] = MSCMS_hprofile2cmsprofile( dest );
94 if (target)
96 cmsprofiles[2] = MSCMS_hprofile2cmsprofile( target );
97 cmstransform = cmsCreateMultiprofileTransform( cmsprofiles, 3, TYPE_BGR_8,
98 TYPE_BGR_8, intent, 0 );
100 else
101 cmstransform = cmsCreateTransform( cmsprofiles[0], TYPE_BGR_8, cmsprofiles[1],
102 TYPE_BGR_8, intent, 0 );
104 ret = MSCMS_create_htransform_handle( cmstransform );
106 #endif /* HAVE_LCMS */
107 return ret;
110 /******************************************************************************
111 * CreateMultiProfileTransform [MSCMS.@]
113 * Create a color transform from an array of color profiles.
115 * PARAMS
116 * profiles [I] Array of color profiles.
117 * nprofiles [I] Number of color profiles.
118 * intents [I] Array of rendering intents.
119 * flags [I] Flags.
120 * cmm [I] Profile to take the CMM from.
122 * RETURNS
123 * Success: Handle to a transform.
124 * Failure: NULL
126 HTRANSFORM WINAPI CreateMultiProfileTransform( PHPROFILE profiles, DWORD nprofiles,
127 PDWORD intents, DWORD nintents, DWORD flags, DWORD cmm )
129 HTRANSFORM ret = NULL;
130 #ifdef HAVE_LCMS
131 cmsHPROFILE *cmsprofiles;
132 cmsHTRANSFORM cmstransform;
133 DWORD i;
135 TRACE( "( %p, 0x%08x, %p, 0x%08x, 0x%08x, 0x%08x ) stub\n",
136 profiles, nprofiles, intents, nintents, flags, cmm );
138 if (!profiles || !intents) return NULL;
140 cmsprofiles = HeapAlloc( GetProcessHeap(), 0, nprofiles * sizeof(cmsHPROFILE) );
142 if (cmsprofiles)
144 for (i = 0; i < nprofiles; i++)
145 cmsprofiles[i] = MSCMS_hprofile2cmsprofile( profiles[i] );
148 cmstransform = cmsCreateMultiprofileTransform( cmsprofiles, nprofiles, TYPE_BGR_8,
149 TYPE_BGR_8, *intents, 0 );
150 HeapFree( GetProcessHeap(), 0, cmsprofiles );
151 ret = MSCMS_create_htransform_handle( cmstransform );
153 #endif /* HAVE_LCMS */
154 return ret;
157 /******************************************************************************
158 * DeleteColorTransform [MSCMS.@]
160 * Delete a color transform.
162 * PARAMS
163 * transform [I] Handle to a color transform.
165 * RETURNS
166 * Success: TRUE
167 * Failure: FALSE
169 BOOL WINAPI DeleteColorTransform( HTRANSFORM transform )
171 BOOL ret = FALSE;
172 #ifdef HAVE_LCMS
173 cmsHTRANSFORM cmstransform;
175 TRACE( "( %p )\n", transform );
177 cmstransform = MSCMS_htransform2cmstransform( transform );
178 cmsDeleteTransform( cmstransform );
180 MSCMS_destroy_htransform_handle( transform );
181 ret = TRUE;
183 #endif /* HAVE_LCMS */
184 return ret;
187 /******************************************************************************
188 * TranslateBitmapBits [MSCMS.@]
190 * Perform color translation.
192 * PARAMS
193 * transform [I] Handle to a color transform.
194 * srcbits [I] Source bitmap.
195 * input [I] Format of the source bitmap.
196 * width [I] Width of the source bitmap.
197 * height [I] Height of the source bitmap.
198 * inputstride [I] Number of bytes in one scanline.
199 * destbits [I] Destination bitmap.
200 * output [I] Format of the destination bitmap.
201 * outputstride [I] Number of bytes in one scanline.
202 * callback [I] Callback function.
203 * data [I] Callback data.
205 * RETURNS
206 * Success: TRUE
207 * Failure: FALSE
209 BOOL WINAPI TranslateBitmapBits( HTRANSFORM transform, PVOID srcbits, BMFORMAT input,
210 DWORD width, DWORD height, DWORD inputstride, PVOID destbits, BMFORMAT output,
211 DWORD outputstride, PBMCALLBACKFN callback, ULONG data )
213 BOOL ret = FALSE;
214 #ifdef HAVE_LCMS
215 cmsHTRANSFORM cmstransform;
217 TRACE( "( %p, %p, 0x%08x, 0x%08x, 0x%08x, 0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08x )\n",
218 transform, srcbits, input, width, height, inputstride, destbits, output,
219 outputstride, callback, data );
221 cmstransform = MSCMS_htransform2cmstransform( transform );
222 cmsDoTransform( cmstransform, srcbits, destbits, width * height );
223 ret = TRUE;
225 #endif /* HAVE_LCMS */
226 return ret;