Modify VarDiv() and VarSub() to use the existing VarDecSub() and
[wine/wine64.git] / dlls / mscms / transform.c
blob6ef7de21fa1b2b8283830ed07661f91293a93375
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 #include "mscms_priv.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mscms);
37 HTRANSFORM WINAPI CreateColorTransformA( LPLOGCOLORSPACEA space, HPROFILE dest,
38 HPROFILE target, DWORD flags )
40 LOGCOLORSPACEW spaceW;
41 DWORD len;
43 TRACE( "( %p, %p, %p, 0x%08lx )\n", space, dest, target, flags );
45 if (!space || !dest) return FALSE;
47 memcpy( &spaceW, space, FIELD_OFFSET(LOGCOLORSPACEA, lcsFilename) );
48 spaceW.lcsSize = sizeof(LOGCOLORSPACEW);
50 len = MultiByteToWideChar( CP_ACP, 0, space->lcsFilename, -1, NULL, 0 );
51 MultiByteToWideChar( CP_ACP, 0, space->lcsFilename, -1, spaceW.lcsFilename, len );
53 return CreateColorTransformW( &spaceW, dest, target, flags );
56 HTRANSFORM WINAPI CreateColorTransformW( LPLOGCOLORSPACEW space, HPROFILE dest,
57 HPROFILE target, DWORD flags )
59 HTRANSFORM ret = NULL;
60 #ifdef HAVE_LCMS
61 cmsHTRANSFORM cmstransform;
62 cmsHPROFILE cmsprofiles[3];
63 int intent;
65 TRACE( "( %p, %p, %p, 0x%08lx )\n", space, dest, target, flags );
67 if (!space || !dest) return FALSE;
69 intent = space->lcsIntent > 3 ? INTENT_PERCEPTUAL : space->lcsIntent;
71 cmsprofiles[0] = cmsCreate_sRGBProfile(); /* FIXME: create from supplied color space */
72 cmsprofiles[1] = MSCMS_hprofile2cmsprofile( dest );
74 if (target)
76 cmsprofiles[2] = MSCMS_hprofile2cmsprofile( target );
77 cmstransform = cmsCreateMultiprofileTransform( cmsprofiles, 3, TYPE_BGR_8,
78 TYPE_BGR_8, intent, 0 );
80 else
82 cmstransform = cmsCreateTransform( cmsprofiles[0], TYPE_BGR_8, cmsprofiles[1],
83 TYPE_BGR_8, intent, 0 );
85 ret = MSCMS_create_htransform_handle( cmstransform );
87 #endif /* HAVE_LCMS */
88 return ret;
91 HTRANSFORM WINAPI CreateMultiProfileTransform( PHPROFILE profiles, DWORD nprofiles,
92 PDWORD intents, DWORD nintents, DWORD flags, DWORD cmm )
94 HTRANSFORM ret = NULL;
95 #ifdef HAVE_LCMS
96 cmsHPROFILE *cmsprofiles;
97 cmsHTRANSFORM cmstransform;
98 DWORD i;
100 TRACE( "( %p, 0x%08lx, %p, 0x%08lx, 0x%08lx, 0x%08lx ) stub\n",
101 profiles, nprofiles, intents, nintents, flags, cmm );
103 if (!profiles || !intents) return NULL;
105 cmsprofiles = HeapAlloc( GetProcessHeap(), 0, nprofiles * sizeof(cmsHPROFILE) );
107 if (cmsprofiles)
109 for (i = 0; i < nprofiles; i++)
110 cmsprofiles[i] = MSCMS_hprofile2cmsprofile( profiles[i] );
113 cmstransform = cmsCreateMultiprofileTransform( cmsprofiles, nprofiles, TYPE_BGR_8,
114 TYPE_BGR_8, *intents, 0 );
115 HeapFree( GetProcessHeap(), 0, cmsprofiles );
116 ret = MSCMS_create_htransform_handle( cmstransform );
118 #endif /* HAVE_LCMS */
119 return ret;
122 BOOL WINAPI DeleteColorTransform( HTRANSFORM transform )
124 BOOL ret = FALSE;
125 #ifdef HAVE_LCMS
126 cmsHTRANSFORM cmstransform;
128 TRACE( "( %p )\n", transform );
130 cmstransform = MSCMS_htransform2cmstransform( transform );
131 cmsDeleteTransform( cmstransform );
133 MSCMS_destroy_htransform_handle( transform );
134 ret = TRUE;
136 #endif /* HAVE_LCMS */
137 return ret;
140 BOOL WINAPI TranslateBitmapBits( HTRANSFORM transform, PVOID srcbits, BMFORMAT input,
141 DWORD width, DWORD height, DWORD inputstride, PVOID destbits, BMFORMAT output,
142 DWORD outputstride, PBMCALLBACKFN callback, ULONG data )
144 BOOL ret = FALSE;
145 #ifdef HAVE_LCMS
146 cmsHTRANSFORM cmstransform;
148 TRACE( "( %p, %p, 0x%08x, 0x%08lx, 0x%08lx, 0x%08lx, %p, 0x%08x, 0x%08lx, %p, 0x%08lx )\n",
149 transform, srcbits, input, width, height, inputstride, destbits, output,
150 outputstride, callback, data );
152 cmstransform = MSCMS_htransform2cmstransform( transform );
154 cmsDoTransform( cmstransform, srcbits, destbits, width * height );
155 ret = TRUE;
157 #endif /* HAVE_LCMS */
158 return ret;