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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.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;
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;
61 cmsHTRANSFORM cmstransform;
62 cmsHPROFILE cmsprofiles[3];
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 );
76 cmsprofiles[2] = MSCMS_hprofile2cmsprofile( target );
77 cmstransform = cmsCreateMultiprofileTransform( cmsprofiles, 3, TYPE_BGR_8,
78 TYPE_BGR_8, intent, 0 );
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 */
91 HTRANSFORM WINAPI CreateMultiProfileTransform( PHPROFILE profiles, DWORD nprofiles,
92 PDWORD intents, DWORD nintents, DWORD flags, DWORD cmm )
94 HTRANSFORM ret = NULL;
96 cmsHPROFILE *cmsprofiles;
97 cmsHTRANSFORM cmstransform;
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) );
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 */
122 BOOL WINAPI DeleteColorTransform( HTRANSFORM transform )
126 cmsHTRANSFORM cmstransform;
128 TRACE( "( %p )\n", transform );
130 cmstransform = MSCMS_htransform2cmstransform( transform );
131 cmsDeleteTransform( cmstransform );
133 MSCMS_destroy_htransform_handle( transform );
136 #endif /* HAVE_LCMS */
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 )
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 );
157 #endif /* HAVE_LCMS */