sorry, my code is not correct. As the documentation stipulates, the last argument of setPixel() should be an uint!
Try wether next code do what you want.
QRgba transparentPixel, redPixel;
transparentPixel = QRgba( 0, 0, 0, 0 ); // fully transparency, color doesn´t matter
redPixel = QRgba( 255, 0, 0, 255 ); // red, no transparency
for ( x = 0; x < secondaryImage.width(); ++x )
{
for ( y = 0; y < secondaryImage.height(); ++y )
{
if ( secondaryImage.pixel( x, y ) == Qt::black ) // check wether working right!
secondaryImage.setPixel( x, y, transparentPixel);
else
secondaryImage.setPixel( x, y, redPixel );
}
}
QRgba transparentPixel, redPixel;
transparentPixel = QRgba( 0, 0, 0, 0 ); // fully transparency, color doesn´t matter
redPixel = QRgba( 255, 0, 0, 255 ); // red, no transparency
for ( x = 0; x < secondaryImage.width(); ++x )
{
for ( y = 0; y < secondaryImage.height(); ++y )
{
if ( secondaryImage.pixel( x, y ) == Qt::black ) // check wether working right!
secondaryImage.setPixel( x, y, transparentPixel);
else
secondaryImage.setPixel( x, y, redPixel );
}
}
To copy to clipboard, switch view to plain text mode
sorry, my code is not correct. As the documentation stipulates, the last argument of setPixel() should be an uint!
Try wether next code do what you want.
QRgba transparentPixel, redPixel;
transparentPixel = QRgba( 0, 0, 0, 0 ); // fully transparency, color doesn´t matter
redPixel = QRgba( 255, 0, 0, 255 ); // red, no transparency
for ( x = 0; x < secondaryImage.width(); ++x )
{
for ( y = 0; y < secondaryImage.height(); ++y )
{
if ( secondaryImage.pixel( x, y ) == Qt::black ) // check wether working right!
secondaryImage.setPixel( x, y, transparentPixel);
else
secondaryImage.setPixel( x, y, redPixel );
}
}
QRgba transparentPixel, redPixel;
transparentPixel = QRgba( 0, 0, 0, 0 ); // fully transparency, color doesn´t matter
redPixel = QRgba( 255, 0, 0, 255 ); // red, no transparency
for ( x = 0; x < secondaryImage.width(); ++x )
{
for ( y = 0; y < secondaryImage.height(); ++y )
{
if ( secondaryImage.pixel( x, y ) == Qt::black ) // check wether working right!
secondaryImage.setPixel( x, y, transparentPixel);
else
secondaryImage.setPixel( x, y, redPixel );
}
}
To copy to clipboard, switch view to plain text mode
Added after 27 minutes:
change following line
if ( secondaryImage.pixel( x, y ) == Qt::black )
if ( secondaryImage.pixel( x, y ) == Qt::black )
To copy to clipboard, switch view to plain text mode
to
if ( secondaryImage.pixel( x, y ) == QRgb( #000000 ) // black
if ( secondaryImage.pixel( x, y ) == QRgb( #000000 ) // black
To copy to clipboard, switch view to plain text mode
Bookmarks