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
22 #include "wine/debug.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
;
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.
67 * space [I] Input color space.
68 * dest [I] Color profile of destination device.
69 * target [I] Color profile of target device.
73 * Success: Handle to a transform.
76 HTRANSFORM WINAPI
CreateColorTransformW( LPLOGCOLORSPACEW space
, HPROFILE dest
,
77 HPROFILE target
, DWORD flags
)
79 HTRANSFORM ret
= NULL
;
81 cmsHTRANSFORM cmstransform
;
82 cmsHPROFILE cmsprofiles
[3];
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
);
96 cmsprofiles
[2] = MSCMS_hprofile2cmsprofile( target
);
97 cmstransform
= cmsCreateMultiprofileTransform( cmsprofiles
, 3, TYPE_BGR_8
,
98 TYPE_BGR_8
, intent
, 0 );
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 */
110 /******************************************************************************
111 * CreateMultiProfileTransform [MSCMS.@]
113 * Create a color transform from an array of color profiles.
116 * profiles [I] Array of color profiles.
117 * nprofiles [I] Number of color profiles.
118 * intents [I] Array of rendering intents.
120 * cmm [I] Profile to take the CMM from.
123 * Success: Handle to a transform.
126 HTRANSFORM WINAPI
CreateMultiProfileTransform( PHPROFILE profiles
, DWORD nprofiles
,
127 PDWORD intents
, DWORD nintents
, DWORD flags
, DWORD cmm
)
129 HTRANSFORM ret
= NULL
;
131 cmsHPROFILE
*cmsprofiles
;
132 cmsHTRANSFORM cmstransform
;
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
) );
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 */
157 /******************************************************************************
158 * DeleteColorTransform [MSCMS.@]
160 * Delete a color transform.
163 * transform [I] Handle to a color transform.
169 BOOL WINAPI
DeleteColorTransform( HTRANSFORM transform
)
173 cmsHTRANSFORM cmstransform
;
175 TRACE( "( %p )\n", transform
);
177 cmstransform
= MSCMS_htransform2cmstransform( transform
);
178 cmsDeleteTransform( cmstransform
);
180 MSCMS_destroy_htransform_handle( transform
);
183 #endif /* HAVE_LCMS */
187 /******************************************************************************
188 * TranslateBitmapBits [MSCMS.@]
190 * Perform color translation.
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.
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
)
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
);
225 #endif /* HAVE_LCMS */