You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2009/11/24 16:03:08 UTC
DO NOT REPLY [Bug 48274] New: HSSFPalette.findSimilarColor treats 0
and 255 as adjacent
https://issues.apache.org/bugzilla/show_bug.cgi?id=48274
Summary: HSSFPalette.findSimilarColor treats 0 and 255 as
adjacent
Product: POI
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
AssignedTo: dev@poi.apache.org
ReportedBy: jeremys.poibugs@hotmail.com
Created an attachment (id=24605)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=24605)
patch for HSSFPalette.java and TestHSSFPalette.java
HSSFPalette.findSimilarColor considers a color value of 0 to be closer than 255
it is to 127. Thus, for example,
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFPalette palette = workbook.getCustomPalette();
HSSFColor color = palette.findSimilarColor(0,102,255);
short[] rgb = color.getTriplet();
System.out.println(java.util.Arrays.toString(rgb));
prints "[255,102,0]". The input color is not unlike turquoise, but the output
color is a light red!
The reason findSimilarColor behaves this way is because it implements the
Manhattan distance in byte space. byte is signed, and thus 255 is really -1,
which is adjacent to 0.
A patch is enclosed which first converts the bytes to positive integers so that
255 is maximally far from 0. Then the above example returns [0,102,204] which
is much closer to the original [0,102,255]. The patch also includes additional
tests for TestHSSFPalette.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
DO NOT REPLY [Bug 48274] HSSFPalette.findSimilarColor treats 0 and
255 as adjacent
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48274
Nick Burch <ni...@torchbox.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #1 from Nick Burch <ni...@torchbox.com> 2009-11-25 03:46:03 UTC ---
Thanks for this, applied to trunk in r884061, with a few slight tweaks
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org