C++ (Qt)QImage img( "file.png" );QVector< QRgb > ct( img.colorTable () );QRgb fc = QColor( 222, 222, 222 ).toRgb();QRgb tc = QColor( 111, 111, 111 ).toRgb(); for( int i = 0; i < ct.count(); i++ ) if( ct[i] == fc ) { ct[i] = tc; break; }img.setColorTable( ct );
C++ (Qt) QImage img("C:\\hi.jpg"); QRgb fc = qRgb(0,0,0); QRgb tc = qRgb(255,0,255); for (int i = 0; i < img.width(); i++) { for (int j = 0; j < img.height(); j++) { if (img.pixel(i,j) == qRgb(0,0,0)) { img.setPixel(i,j, tc); } } }
QImage img( "file.png" );QVector< QRgb > ct( img.colorTable () );QRgb fc = QColor( 222, 222, 222 ).toRgb();QRgb tc = QColor( 111, 111, 111 ).toRgb(); for( int i = 0; i < ct.count(); i++ ) if( ct[i] == fc ) { ct[i] = tc; break; }img.setColorTable( ct );