Skip to content

Commit 9cd2bb2

Browse files
mhugentMarco Hugentobler
authored andcommittedOct 2, 2012
Don't do color box calculations if there are enough colors in the palette
1 parent e0ab410 commit 9cd2bb2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎src/mapserver/qgshttprequesthandler.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,19 @@ void QgsHttpRequestHandler::medianCut( QVector<QRgb>& colorTable, int nColors, c
477477
QHash<QRgb, int> inputColors;
478478
imageColors( inputColors, inputImage );
479479

480+
if ( inputColors.size() <= nColors ) //all the colors in the image can be mapped to one palette color
481+
{
482+
colorTable.resize( inputColors.size() );
483+
int index = 0;
484+
QHash<QRgb, int>::const_iterator inputColorIt = inputColors.constBegin();
485+
for ( ; inputColorIt != inputColors.constEnd(); ++inputColorIt )
486+
{
487+
colorTable[index] = inputColorIt.key();
488+
++index;
489+
}
490+
return;
491+
}
492+
480493
//create first box
481494
QgsColorBox firstBox; //QList< QPair<QRgb, int> >
482495
int firstBoxPixelSum = 0;

0 commit comments

Comments
 (0)
Please sign in to comment.