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
34 #include "mscms_priv.h"
38 static inline void MSCMS_adjust_endianess32( ULONG
*ptr
)
40 #ifndef WORDS_BIGENDIAN
41 *ptr
= RtlUlongByteSwap(*ptr
);
45 void MSCMS_get_profile_header( icProfile
*iccprofile
, PROFILEHEADER
*header
)
49 memcpy( header
, iccprofile
, sizeof(PROFILEHEADER
) );
51 /* ICC format is big-endian, swap bytes if necessary */
52 for (i
= 0; i
< sizeof(PROFILEHEADER
) / sizeof(ULONG
); i
++)
53 MSCMS_adjust_endianess32( (ULONG
*)header
+ i
);
56 void MSCMS_set_profile_header( icProfile
*iccprofile
, PROFILEHEADER
*header
)
59 icHeader
*iccheader
= (icHeader
*)iccprofile
;
61 memcpy( iccheader
, header
, sizeof(icHeader
) );
63 /* ICC format is big-endian, swap bytes if necessary */
64 for (i
= 0; i
< sizeof(icHeader
) / sizeof(ULONG
); i
++)
65 MSCMS_adjust_endianess32( (ULONG
*)iccheader
+ i
);
68 DWORD
MSCMS_get_tag_count( icProfile
*iccprofile
)
70 ULONG count
= iccprofile
->count
;
72 MSCMS_adjust_endianess32( &count
);
76 void MSCMS_get_tag_by_index( icProfile
*iccprofile
, DWORD index
, icTag
*tag
)
78 icTag
*tmp
= (icTag
*)((char *)&iccprofile
->data
+ index
* sizeof(icTag
));
81 tag
->offset
= tmp
->offset
;
82 tag
->size
= tmp
->size
;
84 MSCMS_adjust_endianess32( (ULONG
*)&tag
->sig
);
85 MSCMS_adjust_endianess32( (ULONG
*)&tag
->offset
);
86 MSCMS_adjust_endianess32( (ULONG
*)&tag
->size
);
89 void MSCMS_get_tag_data( icProfile
*iccprofile
, icTag
*tag
, DWORD offset
, void *buffer
)
91 memcpy( buffer
, (char *)iccprofile
+ tag
->offset
+ offset
, tag
->size
- offset
);
94 void MSCMS_set_tag_data( icProfile
*iccprofile
, icTag
*tag
, DWORD offset
, void *buffer
)
96 memcpy( (char *)iccprofile
+ tag
->offset
+ offset
, buffer
, tag
->size
- offset
);
99 DWORD
MSCMS_get_profile_size( icProfile
*iccprofile
)
101 DWORD size
= ((icHeader
*)iccprofile
)->size
;
103 MSCMS_adjust_endianess32( (ULONG
*)&size
);
107 #endif /* HAVE_LCMS */