https://issues.apache.org/ooo/show_bug.cgi?id=121870

            Bug ID: 121870
        Issue Type: DEFECT
           Summary: Different darkness threshold: doc/docx auto font color
                    inverted
    Classification: Application
           Product: Writer
           Version: AOO 3.4.1
          Hardware: All
                OS: All
            Status: CONFIRMED
          Severity: normal
          Priority: P3
         Component: code
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Created attachment 80384
  --> https://issues.apache.org/ooo/attachment.cgi?id=80384&action=edit
Test document: text should appear white.

Apparently OOo and MS-office have a different threshold to determine what
should be considered dark.
As mentioned in a LibreOffice list:

Neither the OpenDocument spec nor the Office Open XML spec define
what background colour should be considered "dark", leaving it up to the
implementation.

OpenDocument v1.2 section 20.385:
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1420234_253892949

Luke Deller made an interesting analysis which I will quote here:
___
Word 2010 appears to treat a background colour as "dark" if:

130*red + 255*green * 51*blue < 105*255

Where red, green, blue are the RGB components of the background colour as 8-bit
integers (ie in the range 0 to 255).

(I arrived at this formula by:
- collecting some data points by experimentation with Word 2010
- guessing the form of this formula
- using linear algebra with the data points to work out the coefficients
- double-checking using more data points)

the LibreOffice formula (from code) is:

77*red + 151*green + 28*blue <= 38*256

I notice that both Word and LibreOffice formulae use weights proportional to
the "Rec. 601" coefficients for Luma shown here:
http://en.wikipedia.org/wiki/Luma_%28video%29
ie Luma = 0.299 R' + 0.587 G' + 0.114 B'

(Actually LibreOffice would match these coefficients more accurately if it used
 76*red + 151*green + 29*blue)

Anyway the main difference is that LibreOffice considers Luma <= 38 (out of
255) to be dark, whereas Word considers Luma < about 61 (out of 255) to be
dark.
______

The proposed change in LibreOffice is to change slightly the coefficients in
tools/inc/tools/color.hxx Color::GetLuminance()
change 28 --> 29, 77 -->76
tools/source/generic/color.cxx Color::IsDark()
Change the threshold from 38 --> 60 (or maybe just 50?)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.

Reply via email to