Make functions static.
[wine] / dlls / mscms / icc.c
1 /*
2  * MSCMS - Color Management System for Wine
3  *
4  * Copyright 2004, 2005 Hans Leidekker
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22 #include "wine/debug.h"
23
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winnls.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winreg.h"
32 #include "winternl.h"
33 #include "icm.h"
34
35 #define LCMS_API_FUNCTION(f) extern typeof(f) * p##f;
36 #include "lcms_api.h"
37 #undef LCMS_API_FUNCTION
38
39 WINE_DEFAULT_DEBUG_CHANNEL(mscms);
40
41 #ifdef HAVE_LCMS_H
42
43 static inline void MSCMS_adjust_endianess32( ULONG *ptr )
44 {
45 #ifndef WORDS_BIGENDIAN
46     *ptr = RtlUlongByteSwap(*ptr);
47 #endif
48 }
49
50 void MSCMS_get_profile_header( icProfile *iccprofile, PROFILEHEADER *header )
51 {
52     unsigned int i;
53
54     memcpy( header, iccprofile, sizeof(PROFILEHEADER) );
55
56     /* ICC format is big-endian, swap bytes if necessary */
57     for (i = 0; i < sizeof(PROFILEHEADER) / sizeof(ULONG); i++)
58         MSCMS_adjust_endianess32( (ULONG *)header + i );
59 }
60
61 void MSCMS_set_profile_header( icProfile *iccprofile, PROFILEHEADER *header )
62 {
63     unsigned int i;
64     icHeader *iccheader = (icHeader *)iccprofile;
65
66     memcpy( iccheader, header, sizeof(icHeader) );
67
68     /* ICC format is big-endian, swap bytes if necessary */
69     for (i = 0; i < sizeof(icHeader) / sizeof(ULONG); i++)
70         MSCMS_adjust_endianess32( (ULONG *)iccheader + i );
71 }
72
73 DWORD MSCMS_get_tag_count( icProfile *iccprofile )
74 {
75     ULONG count = iccprofile->count;
76
77     MSCMS_adjust_endianess32( &count );
78     return count;
79 }
80
81 void MSCMS_get_tag_by_index( icProfile *iccprofile, DWORD index, icTag *tag )
82 {
83     icTag *tmp = (icTag *)((char *)&iccprofile->data + index * sizeof(icTag));
84
85     tag->sig = tmp->sig;
86     tag->offset = tmp->offset;
87     tag->size = tmp->size;
88
89     MSCMS_adjust_endianess32( (ULONG *)&tag->sig );
90     MSCMS_adjust_endianess32( (ULONG *)&tag->offset );
91     MSCMS_adjust_endianess32( (ULONG *)&tag->size );
92 }
93
94 void MSCMS_get_tag_data( icProfile *iccprofile, icTag *tag, DWORD offset, void *buffer )
95 {
96     memcpy( buffer, (char *)iccprofile + tag->offset + offset, tag->size - offset );
97 }
98
99 void MSCMS_set_tag_data( icProfile *iccprofile, icTag *tag, DWORD offset, void *buffer )
100 {
101     memcpy( (char *)iccprofile + tag->offset + offset, buffer, tag->size - offset );
102 }
103
104 DWORD MSCMS_get_profile_size( icProfile *iccprofile )
105 {
106     DWORD size = ((icHeader *)iccprofile)->size;
107
108     MSCMS_adjust_endianess32( (ULONG *)&size );
109     return size;
110 }
111
112 #endif /* HAVE_LCMS_H */