Skip to content
Permalink
Browse files

Don't do color box calculations if there are enough colors in the pal…

…ette
  • Loading branch information
mhugent authored and Marco Hugentobler committed Oct 2, 2012
1 parent e0ab410 commit 9cd2bb2b3b9b67078b9f25f8aceff844e83c01fd
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/mapserver/qgshttprequesthandler.cpp
@@ -477,6 +477,19 @@ void QgsHttpRequestHandler::medianCut( QVector<QRgb>& colorTable, int nColors, c
QHash<QRgb, int> inputColors;
imageColors( inputColors, inputImage );

if ( inputColors.size() <= nColors ) //all the colors in the image can be mapped to one palette color
{
colorTable.resize( inputColors.size() );
int index = 0;
QHash<QRgb, int>::const_iterator inputColorIt = inputColors.constBegin();
for ( ; inputColorIt != inputColors.constEnd(); ++inputColorIt )
{
colorTable[index] = inputColorIt.key();
++index;
}
return;
}

//create first box
QgsColorBox firstBox; //QList< QPair<QRgb, int> >
int firstBoxPixelSum = 0;

0 comments on commit 9cd2bb2

Please sign in to comment.
You can’t perform that action at this time.