2004-12-07 15:42:47 +01:00
|
|
|
/*
|
|
|
|
* MSCMS - Color Management System for Wine
|
|
|
|
*
|
2005-02-14 21:53:59 +01:00
|
|
|
* Copyright 2004, 2005 Hans Leidekker
|
2004-12-07 15:42:47 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-12-07 15:42:47 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winternl.h"
|
|
|
|
#include "icm.h"
|
|
|
|
|
2005-07-15 12:09:43 +02:00
|
|
|
#include "mscms_priv.h"
|
2004-12-07 15:42:47 +01:00
|
|
|
|
2005-07-18 17:10:36 +02:00
|
|
|
#ifdef HAVE_LCMS
|
2004-12-07 15:42:47 +01:00
|
|
|
|
|
|
|
static inline void MSCMS_adjust_endianess32( ULONG *ptr )
|
|
|
|
{
|
|
|
|
#ifndef WORDS_BIGENDIAN
|
|
|
|
*ptr = RtlUlongByteSwap(*ptr);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-05-28 19:11:29 +02:00
|
|
|
void MSCMS_get_profile_header( const icProfile *iccprofile, PROFILEHEADER *header )
|
2004-12-07 15:42:47 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
memcpy( header, iccprofile, sizeof(PROFILEHEADER) );
|
|
|
|
|
|
|
|
/* ICC format is big-endian, swap bytes if necessary */
|
|
|
|
for (i = 0; i < sizeof(PROFILEHEADER) / sizeof(ULONG); i++)
|
|
|
|
MSCMS_adjust_endianess32( (ULONG *)header + i );
|
|
|
|
}
|
|
|
|
|
2007-05-28 19:11:29 +02:00
|
|
|
void MSCMS_set_profile_header( icProfile *iccprofile, const PROFILEHEADER *header )
|
2004-12-07 15:42:47 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
icHeader *iccheader = (icHeader *)iccprofile;
|
|
|
|
|
|
|
|
memcpy( iccheader, header, sizeof(icHeader) );
|
|
|
|
|
|
|
|
/* ICC format is big-endian, swap bytes if necessary */
|
|
|
|
for (i = 0; i < sizeof(icHeader) / sizeof(ULONG); i++)
|
|
|
|
MSCMS_adjust_endianess32( (ULONG *)iccheader + i );
|
|
|
|
}
|
|
|
|
|
2007-05-28 19:11:29 +02:00
|
|
|
DWORD MSCMS_get_tag_count( const icProfile *iccprofile )
|
2004-12-07 15:42:47 +01:00
|
|
|
{
|
|
|
|
ULONG count = iccprofile->count;
|
|
|
|
|
|
|
|
MSCMS_adjust_endianess32( &count );
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MSCMS_get_tag_by_index( icProfile *iccprofile, DWORD index, icTag *tag )
|
|
|
|
{
|
2008-07-11 11:41:36 +02:00
|
|
|
icTag *tmp = (icTag *)((char *)iccprofile->data + index * sizeof(icTag));
|
2004-12-07 15:42:47 +01:00
|
|
|
|
|
|
|
tag->sig = tmp->sig;
|
|
|
|
tag->offset = tmp->offset;
|
|
|
|
tag->size = tmp->size;
|
|
|
|
|
|
|
|
MSCMS_adjust_endianess32( (ULONG *)&tag->sig );
|
2008-01-10 23:11:24 +01:00
|
|
|
MSCMS_adjust_endianess32( &tag->offset );
|
|
|
|
MSCMS_adjust_endianess32( &tag->size );
|
2004-12-07 15:42:47 +01:00
|
|
|
}
|
|
|
|
|
2007-05-28 19:11:29 +02:00
|
|
|
void MSCMS_get_tag_data( const icProfile *iccprofile, const icTag *tag, DWORD offset, void *buffer )
|
2004-12-07 15:42:47 +01:00
|
|
|
{
|
2007-05-28 19:11:29 +02:00
|
|
|
memcpy( buffer, (const char *)iccprofile + tag->offset + offset, tag->size - offset );
|
2004-12-07 15:42:47 +01:00
|
|
|
}
|
2004-12-13 14:23:17 +01:00
|
|
|
|
2007-05-28 19:11:29 +02:00
|
|
|
void MSCMS_set_tag_data( icProfile *iccprofile, const icTag *tag, DWORD offset, const void *buffer )
|
2004-12-13 14:23:17 +01:00
|
|
|
{
|
|
|
|
memcpy( (char *)iccprofile + tag->offset + offset, buffer, tag->size - offset );
|
|
|
|
}
|
|
|
|
|
2007-05-28 19:11:29 +02:00
|
|
|
DWORD MSCMS_get_profile_size( const icProfile *iccprofile )
|
2005-02-14 21:53:59 +01:00
|
|
|
{
|
2007-05-28 19:11:29 +02:00
|
|
|
DWORD size = ((const icHeader *)iccprofile)->size;
|
2005-02-14 21:53:59 +01:00
|
|
|
|
2008-01-10 23:11:24 +01:00
|
|
|
MSCMS_adjust_endianess32( &size );
|
2005-02-14 21:53:59 +01:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2005-07-18 17:10:36 +02:00
|
|
|
#endif /* HAVE_LCMS */
|