Bug 64241 - XSLF - Wrong scheme colors used when rendering
Summary: XSLF - Wrong scheme colors used when rendering
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2020-03-19 07:51 UTC by wonseok
Modified: 2020-03-22 19:16 UTC (History)
0 users

power point capture & PPT2PNG result (58.83 KB, image/jpeg)
2020-03-19 07:51 UTC, wonseok
sample pptx (29.41 KB, application/vnd.openxmlformats-officedocument.presentationml.presentation)
2020-03-19 08:01 UTC, wonseok
Examping showing the wrong background color / calculation (20.47 KB, application/vnd.openxmlformats-officedocument.presentationml.presentation)
2020-03-21 20:41 UTC, Andreas Beeker

Note You need to log in before you can comment on or make changes to this bug.
Description wonseok 2020-03-19 07:51:42 UTC
Created attachment 37105 [details]
power point capture & PPT2PNG result

I've tried to export PPT as png via PPT2PNG included 4.1.2.

Font color of shape with default color rendered with whited color

here is  theme1.xml of my document.

<a:clrScheme name="Office">
    <a:sysClr lastClr="000000" val="windowText"/>

and clrMap of slideMaster1.xml
<p:clrMap folHlink="folHlink" hlink="hlink" accent6="accent6" accent5="accent5" accent4="accent4" accent3="accent3" accent2="accent2" accent1="accent1" tx2="dk2" bg2="lt2" tx1="dk1" bg1="lt1"/>

and shape's description of slide?.xml

  <a:bodyPr anchor="ctr" rtlCol="0"/>
    <a:pPr algn="ctr"/>
      <a:rPr lang="en-US" dirty="0" altLang="ko-KR">
          <a:schemeClr val="tx1"/>
    <a:endParaRPr lang="ko-KR" dirty="0" altLang="en-US">
        <a:schemeClr val="tx1"/>

theme1.xml define dk1 is system window color. my window color is black and PowerPoint render shape's caption to black.
But PPT2PNG render all shapes which has tx1 clrMap to white color.
Comment 1 wonseok 2020-03-19 08:01:06 UTC
Created attachment 37106 [details]
sample pptx
Comment 2 Andreas Beeker 2020-03-21 18:29:23 UTC
fixed via r1875499

I'll keep the issue open, as I might find the error in our themes.pptx [1] (slide 8/9) rendering too.

Maybe you have an idea, where the wrong background color comes from?

[1] https://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/themes.pptx
Comment 3 Andreas Beeker 2020-03-21 20:41:20 UTC
Created attachment 37114 [details]
Examping showing the wrong background color / calculation

Simplified version which renders too bright - I guess the tint calculation is wrong.

So POI does currently the following:

- get background definition from the master slide: ...
  <p:bg><p:bgRef idx="1001"><a:schemeClr val="bg2"/></p:bgRef></p:bg>

- map the color on the master slide:
  <p:clrMap ... bg2="lt2" />

- get the background definition from the theme:
      <a:schemeClr val="phClr">
         <a:tint val="88000"/>
         <a:satMod val="105000"/>

- get the color from the theme:
  <a:lt2><a:srgbClr val="FBEEC9"/></a:lt2>

- convert the color to HSL (H in [0..360], S in [0..100], L in [0..100]):
  H = 44.39999999999998
  S = 86.20689655172413
  L = 88.6274516582489

- apply the satMod:
  S *= 1.05
  S = 90.51724137931033

- apply the tint:
  // Lum‘ = Lum * (1-tint) + (HLSMAX – HLSMAX * (1-tint)) with HLSMAX = 100
  L = L * (1-0.88) + (100 - 100*(1-0.88))
  L = 98.63529419898987

- and converting it back to RGB

... changing the tint to L=L * 0.88 + 100 - 100*0.88 looks promising
Comment 4 Andreas Beeker 2020-03-22 19:16:33 UTC
Fixed now also the tint/shading issue via r1875522

Tint and shading are based on scRGB opposed to HSL colorspace. [1]

Currently the order of tint/shading/*mod is hard-coded in DrawPaint - this needs probably be adapted [2] - I haven't checked how to handle HSLF records then ... I'll open a separate issue for this, when I'll have validated that really different values will result .. i.e. I assume that office always uses the same order ...

The conversion logic can be also seen in .Net 4.8 code [3]

Libre office calculates the colors slightly different [4] - they use a gamma correction of 2.3 (POI uses 2.4 mostly) and the conversion between rgb <-> scRgb <-> hsl is more likely to be rgb <-> crgb <-> hsl. Hence the colors differs between POI and LO.

[1] https://social.msdn.microsoft.com/Forums/office/en-US/f6d26f2c-114f-4a0d-8bca-a27442aec4d0/tint-and-shade-elements?forum=oxmlsdk

[2] https://social.msdn.microsoft.com/Forums/en-US/f7d46b14-6c7d-460b-96c6-5625724afa27/what-order-does-office-apply-shadetinthuemodsatmodlummod-color-modifiers?forum=os_binaryfile

[3] https://referencesource.microsoft.com/#PresentationCore/Core/CSharp/System/Windows/Media/Color.cs,1048

[4] https://github.com/LibreOffice/core/blob/master/oox/source/drawingml/color.cxx