2004-12-07 14:42:47 +00:00
|
|
|
/*
|
|
|
|
* MSCMS - Color Management System for Wine
|
|
|
|
*
|
2005-02-14 20:53:59 +00:00
|
|
|
* Copyright 2004, 2005 Hans Leidekker
|
2004-12-07 14:42:47 +00: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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-12-07 14:42:47 +00: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 10:09:43 +00:00
|
|
|
#include "mscms_priv.h"
|
2004-12-07 14:42:47 +00:00
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2004-12-07 14:42:47 +00:00
|
|
|
|
|
|
|
static inline void MSCMS_adjust_endianess32( ULONG *ptr )
|
|
|
|
{
|
|
|
|
#ifndef WORDS_BIGENDIAN
|
|
|
|
*ptr = RtlUlongByteSwap(*ptr);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-05-28 17:11:29 +00:00
|
|
|
void MSCMS_get_profile_header( const icProfile *iccprofile, PROFILEHEADER *header )
|
2004-12-07 14:42:47 +00: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 17:11:29 +00:00
|
|
|
void MSCMS_set_profile_header( icProfile *iccprofile, const PROFILEHEADER *header )
|
2004-12-07 14:42:47 +00: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 17:11:29 +00:00
|
|
|
DWORD MSCMS_get_tag_count( const icProfile *iccprofile )
|
2004-12-07 14:42:47 +00: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 09:41:36 +00:00
|
|
|
icTag *tmp = (icTag *)((char *)iccprofile->data + index * sizeof(icTag));
|
2004-12-07 14:42:47 +00:00
|
|
|
|
|
|
|
tag->sig = tmp->sig;
|
|
|
|
tag->offset = tmp->offset;
|
|
|
|
tag->size = tmp->size;
|
|
|
|
|
2009-01-17 21:55:25 +00:00
|
|
|
MSCMS_adjust_endianess32( &tag->sig );
|
2008-01-10 22:11:24 +00:00
|
|
|
MSCMS_adjust_endianess32( &tag->offset );
|
|
|
|
MSCMS_adjust_endianess32( &tag->size );
|
2004-12-07 14:42:47 +00:00
|
|
|
}
|
|
|
|
|
2007-05-28 17:11:29 +00:00
|
|
|
void MSCMS_get_tag_data( const icProfile *iccprofile, const icTag *tag, DWORD offset, void *buffer )
|
2004-12-07 14:42:47 +00:00
|
|
|
{
|
2007-05-28 17:11:29 +00:00
|
|
|
memcpy( buffer, (const char *)iccprofile + tag->offset + offset, tag->size - offset );
|
2004-12-07 14:42:47 +00:00
|
|
|
}
|
2004-12-13 13:23:17 +00:00
|
|
|
|
2007-05-28 17:11:29 +00:00
|
|
|
void MSCMS_set_tag_data( icProfile *iccprofile, const icTag *tag, DWORD offset, const void *buffer )
|
2004-12-13 13:23:17 +00:00
|
|
|
{
|
|
|
|
memcpy( (char *)iccprofile + tag->offset + offset, buffer, tag->size - offset );
|
|
|
|
}
|
|
|
|
|
2007-05-28 17:11:29 +00:00
|
|
|
DWORD MSCMS_get_profile_size( const icProfile *iccprofile )
|
2005-02-14 20:53:59 +00:00
|
|
|
{
|
2007-05-28 17:11:29 +00:00
|
|
|
DWORD size = ((const icHeader *)iccprofile)->size;
|
2005-02-14 20:53:59 +00:00
|
|
|
|
2008-01-10 22:11:24 +00:00
|
|
|
MSCMS_adjust_endianess32( &size );
|
2005-02-14 20:53:59 +00:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|