Skip to content

Commit

Permalink
Don't do color box calculations if there are enough colors in the pal…
Browse files Browse the repository at this point in the history
…ette
  • Loading branch information
mhugent authored and Marco Hugentobler committed Oct 2, 2012
1 parent e0ab410 commit 9cd2bb2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/mapserver/qgshttprequesthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9cd2bb2

Please sign in to comment.