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 2006/03/10 16:48:54 UTC

DO NOT REPLY [Bug 38921] New: - findSimilarColor is don't working

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38921>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38921

           Summary: findSimilarColor is don't  working
           Product: POI
           Version: 2.5
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: critical
          Priority: P2
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: victornie2002@yahoo.com
                CC: victornie2002@yahoo.com


The method always return the last Color of the palette because the variable
minDistance is not updated and the Color distance shoul be in absolute value.
Regards

The resolution is 

public HSSFColor findSimilarColor(byte red, byte green, byte blue)
{
    HSSFColor result = null;
    int minColorDistance = Integer.MAX_VALUE;
    byte[] b = palette.getColor(PaletteRecord.FIRST_COLOR_INDEX);
    for (short i = (short) PaletteRecord.FIRST_COLOR_INDEX; b != null;
       b = palette.getColor(++i))
    {
       int colorDistance = Math.abs(red - b[0] + green - b[1] + blue - b[2]);
       if (colorDistance < minColorDistance)
        {
          minColorDistance = colorDistance;  
          result = getColor(i);
        }
    }
    return result;
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


DO NOT REPLY [Bug 38921] - findSimilarColor is isn't working

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38921>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38921


nick@torchbox.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From nick@torchbox.com  2008-02-21 03:35 -------
I've applied N�stor's suggested fix to svn trunk. I've also written some tests,
which show that it is now working as one would expect it to.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 38921] - findSimilarColor is don't working

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38921>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38921





------- Additional Comments From thenestruo@gmail.com  2006-03-22 11:31 -------
That resolution wouldn't work properly, as long as distance isn't being
calculated properly:
If the desired color is 254,0,0:
- The color 0,254,0 will have colorDistance==0, but colors are really different.
- The color 255,0,0, although is really similar (colorDistance==1), won't be
chosen because there is another color (the previous one) with less colorDistance.

In my opinion, a better way for calculating the colorDistance would be:
int colorDistance = Math.abs(r - comp[0]) + Math.abs(g - comp[1]) + Math.abs(b -
comp[2])

Once the colorDistance is calculated properly, a breaking condition can be added
before the comparision (colorDistance < minColorDistance) when the exact color
is found:
if (colorDistance==0) {
    return getColor(i);
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


DO NOT REPLY [Bug 38921] - findSimilarColor is isn't working

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38921>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38921


acoliver@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|findSimilarColor is don't   |findSimilarColor is isn't
                   |working                     |working




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


DO NOT REPLY [Bug 38921] - findSimilarColor is isn't working

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38921>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38921





------- Additional Comments From superpalhares@gmail.com  2008-02-20 11:58 -------
I agree with N�stor.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org