Skip to content

Commit c37ffa5

Browse files
committedDec 15, 2014
dxf export: only use palette only for fully opaque colors
1 parent 581cac7 commit c37ffa5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed
 

‎src/core/dxf/qgsdxfexport.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,23 +371,23 @@ void QgsDxfExport::writeGroup( QColor color, int exactMatchCode, int rgbCode, in
371371
int minDistAt = -1;
372372
int minDist = INT_MAX;
373373

374-
for ( int i = 1; i < ( int )( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ); ++i )
374+
for ( int i = 1; i < ( int )( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ) && minDist > 0; ++i )
375375
{
376376
int dist = color_distance( color.rgba(), i );
377-
if ( dist == 0 )
378-
{
379-
writeGroup( exactMatchCode, i );
380-
return;
381-
}
377+
if ( dist >= minDist )
378+
continue;
382379

383-
if ( dist < minDist )
384-
{
385-
minDistAt = i;
386-
minDist = dist;
387-
}
380+
minDistAt = i;
381+
minDist = dist;
388382
}
389383

390384
writeGroup( exactMatchCode, minDistAt );
385+
if ( minDist == 0 && color.alpha() == 255 )
386+
{
387+
// exact full opaque match
388+
return;
389+
}
390+
391391
int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
392392
writeGroup( rgbCode, c );
393393
if ( transparencyCode != -1 && color.alpha() < 255 )

0 commit comments

Comments
 (0)
Please sign in to comment.