Bug 44664 - poi does not find Similar Color
Summary: poi does not find Similar Color
Status: RESOLVED DUPLICATE of bug 38921
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-03-23 19:07 UTC by namsu
Modified: 2008-03-24 10:14 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description namsu 2008-03-23 19:07:36 UTC

I found some problem at the method 
HSSFPalette.findSimilarColor(byte red, byte green, byte blue)

This does not return similar color.

When I input Color A I get the Color B from this method.
Color A -> red:120 green:114 blue:4
Color B -> red:51 green:51 blue:51 ColorIndex:63

But this is not proper color value.

When I use this edited method I can get the proper color value.

    public HSSFColor findSimilarColor(byte red, byte green, byte blue)

      //int colorDistance = red - b[0] + green - b[1] + blue - b[2];
      int colorDistance = Math.abs(((int) red & 0xff) - ((int) b[0] & 0xff))
      + Math.abs(((int) green & 0xff) - ((int) b[1] & 0xff))
      + Math.abs(((int) blue & 0xff) - ((int) b[2] & 0xff));


Color A -> red:120 green:114 blue:4
Color B -> red:-128 green:-128 blue:0 ColorIndex:19
Comment 1 Nick Burch 2008-03-24 10:14:22 UTC
I believe this was fixed after bug #38921

Have you tried with svn trunk

*** This bug has been marked as a duplicate of bug 38921 ***