dplayx: Code to forward player creation
[wine/gsoc_dplay.git] / dlls / mscms / icc.c
blob67b65ed664371e4faf131d7427757e41ce9cddc5
1 /*
2 * MSCMS - Color Management System for Wine
4 * Copyright 2004, 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
21 #include "config.h"
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "winternl.h"
30 #include "icm.h"
32 #include "mscms_priv.h"
34 #ifdef HAVE_LCMS
36 static inline void MSCMS_adjust_endianess32( ULONG *ptr )
38 #ifndef WORDS_BIGENDIAN
39 *ptr = RtlUlongByteSwap(*ptr);
40 #endif
43 void MSCMS_get_profile_header( const icProfile *iccprofile, PROFILEHEADER *header )
45 unsigned int i;
47 memcpy( header, iccprofile, sizeof(PROFILEHEADER) );
49 /* ICC format is big-endian, swap bytes if necessary */
50 for (i = 0; i < sizeof(PROFILEHEADER) / sizeof(ULONG); i++)
51 MSCMS_adjust_endianess32( (ULONG *)header + i );
54 void MSCMS_set_profile_header( icProfile *iccprofile, const PROFILEHEADER *header )
56 unsigned int i;
57 icHeader *iccheader = (icHeader *)iccprofile;
59 memcpy( iccheader, header, sizeof(icHeader) );
61 /* ICC format is big-endian, swap bytes if necessary */
62 for (i = 0; i < sizeof(icHeader) / sizeof(ULONG); i++)
63 MSCMS_adjust_endianess32( (ULONG *)iccheader + i );
66 DWORD MSCMS_get_tag_count( const icProfile *iccprofile )
68 ULONG count = iccprofile->count;
70 MSCMS_adjust_endianess32( &count );
71 return count;
74 void MSCMS_get_tag_by_index( icProfile *iccprofile, DWORD index, icTag *tag )
76 icTag *tmp = (icTag *)((char *)iccprofile->data + index * sizeof(icTag));
78 tag->sig = tmp->sig;
79 tag->offset = tmp->offset;
80 tag->size = tmp->size;
82 MSCMS_adjust_endianess32( &tag->sig );
83 MSCMS_adjust_endianess32( &tag->offset );
84 MSCMS_adjust_endianess32( &tag->size );
87 void MSCMS_get_tag_data( const icProfile *iccprofile, const icTag *tag, DWORD offset, void *buffer )
89 memcpy( buffer, (const char *)iccprofile + tag->offset + offset, tag->size - offset );
92 void MSCMS_set_tag_data( icProfile *iccprofile, const icTag *tag, DWORD offset, const void *buffer )
94 memcpy( (char *)iccprofile + tag->offset + offset, buffer, tag->size - offset );
97 DWORD MSCMS_get_profile_size( const icProfile *iccprofile )
99 DWORD size = ((const icHeader *)iccprofile)->size;
101 MSCMS_adjust_endianess32( &size );
102 return size;
105 #endif /* HAVE_LCMS */