Re: slaroche - r30846 - abiword/trunk/src/wp/impexp/xp

From: Ingo Brückl <ib_at_wupperonline.de>
Date: Sun Apr 22 2012 - 20:22:04 CEST

> Author: slaroche
> Date: 2012-04-22 19:47:48 +0200 (Sun, 22 Apr 2012)
> New Revision: 30846

> Modified: abiword/trunk/src/wp/impexp/xp/ie_imp_RTFObjectsAndPicts.cpp
> ===================================================================
> +++ abiword/trunk/src/wp/impexp/xp/ie_imp_RTFObjectsAndPicts.cpp
> 2012-04-22 17:47:48 UTC (rev 30846)
> @@ -1180,7 +1180,11 @@
> }
> UT_UTF8String_setProperty(sPropString,sP,sV);
> sP="bgcolor";
> - UT_UTF8String_sprintf(sV, "%06x",frame.m_iBackgroundColor);
> + // RTF uses BGR encoding for colors while Abiword uses RGB
> + UT_sint32 iRGBColor = 0x10000 * (frame.m_iBackgroundColor % 0x100) +
> + 0x100 * ((frame.m_iBackgroundColor/0x100) % 0x100) +
> + ((frame.m_iBackgroundColor/0x10000) % 0x100);

I'd recommend bit shifting here which will save lots of operations and
will be far easier to understand. Something like:

  UT_sint32 iRGBColor = (((frame.m_iBackgroundColor & 0xff0000) >> 16) |
                          (frame.m_iBackgroundColor & 0xff00) |
                         ((frame.m_iBackgroundColor & 0xff) << 16));

Ingo
Received on Sun Apr 22 20:33:55 2012

This archive was generated by hypermail 2.1.8 : Sun Apr 22 2012 - 20:33:55 CEST