本文整理汇总了C++中QColor::setRgba方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::setRgba方法的具体用法?C++ QColor::setRgba怎么用?C++ QColor::setRgba使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::setRgba方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseReleaseEvent
void EyedropperTool::mouseReleaseEvent(QMouseEvent *event)
{
Layer* layer = mEditor->layers()->currentLayer();
if (layer == NULL) { return; }
if (event->button() == Qt::LeftButton)
{
if (layer->type() == Layer::BITMAP)
{
BitmapImage* targetImage = ((LayerBitmap *)layer)->getLastBitmapImageAtFrame( mEditor->currentFrame(), 0);
//QColor pickedColour = targetImage->pixel(getLastPoint().x(), getLastPoint().y());
QColor pickedColour;
pickedColour.setRgba( targetImage->pixel( getLastPoint().x(), getLastPoint().y() ) );
int transp = 255 - pickedColour.alpha();
pickedColour.setRed( pickedColour.red() + transp );
pickedColour.setGreen( pickedColour.green() + transp );
pickedColour.setBlue( pickedColour.blue() + transp );
if (pickedColour.alpha() != 0)
{
mEditor->color()->setColor(pickedColour);
}
}
else if (layer->type() == Layer::VECTOR)
{
VectorImage *vectorImage = ((LayerVector *)layer)->getLastVectorImageAtFrame(mEditor->currentFrame(), 0);
int colourNumber = vectorImage->getColourNumber(getLastPoint());
if (colourNumber != -1)
{
mEditor->color()->setColorNumber(colourNumber);
}
}
}
}
示例2: getTileFromScreen
QImage DwarfClipboardPng::getTileFromScreen(DFHack::t_screen screen)
{
QColor foregroundColor = getForegroundColorFromScreen(screen);
QColor backgroundColor = getBackgroundColorFromScreen(screen);
QImage tile = tileSet->copy((screen.symbol % 16)*tileWidth,int(screen.symbol/16)*tileHeight,tileWidth,tileHeight);
QImage resultImage(tileWidth,tileHeight,QImage::Format_ARGB32);
for(int x = 0;x< tile.width();x++){
for(int y =0;y<tile.height();y++){
QColor color;
color.setRgba(tile.pixel(x,y));
if(color == QColor("#FF00FF")){ // FF00FF is magenta
resultImage.setPixel(x,y,backgroundColor.rgb());
}
else{
QColor newColor;
qreal alpha = color.alphaF();
qreal alpha_diff = 1-alpha;
newColor.setRedF((alpha * (color.redF() * foregroundColor.redF() )) + (alpha_diff * backgroundColor.redF()));
newColor.setGreenF((alpha * (color.greenF() * foregroundColor.greenF() )) + (alpha_diff * backgroundColor.greenF()));
newColor.setBlueF((alpha * (color.blueF() * foregroundColor.blueF() )) + (alpha_diff * backgroundColor.blueF()));
resultImage.setPixel(x,y,newColor.rgb());
}
}
}
return(resultImage);
}
示例3: setNamedColor
void tst_QColor::setNamedColor()
{
for (int i = 0; i < rgbTblSize; ++i) {
QColor color;
color.setNamedColor(QLatin1String(rgbTbl[i].name));
QColor expected;
expected.setRgba(rgbTbl[i].value);
QCOMPARE(color, expected);
}
}
示例4: setRgba
void tst_QColor::setRgba()
{
for (int a = 0; a < 255; ++a) {
const QRgb rgba1 = qRgba(a, a, a, a);
QColor color;
color.setRgba(rgba1);
QCOMPARE(color.alpha(), a);
const QRgb rgba2 = color.rgba();
QCOMPARE(rgba2, rgba1);
QCOMPARE(qAlpha(rgba2), a);
}
}
示例5: chooseColor
void ColorButton::chooseColor() {
bool ok;
if (_color == Qt::transparent) {
_color = Qt::black;
}
QRgb rgba = QColorDialog::getRgba(_color.rgba(), &ok, parentWidget());
if (ok) {
QColor color;
color.setRgba(rgba);
setColor(color);
}
}
示例6: on_btnSelectBgColor_clicked
void mW::on_btnSelectBgColor_clicked()
{
int r,g,b;
QColor myColor;
myColor.setRgba(QColorDialog::getRgba(0x00));
myColor.getRgb(&r,&g,&b);
QString bgColorStyleSheet;
char sh[64];
sprintf(sh, "background-color: rgb(%i, %i, %i);", r,g,b);
bgColorStyleSheet=sh;
btnSelectBgColor->setStyleSheet(bgColorStyleSheet);
sprintf(sh, "%02x%02x%02x",r,g,b);
osggBackgroundColor=sh;
}
示例7: mouseMoveEvent
void EyedropperTool::mouseMoveEvent(QMouseEvent *event)
{
Q_UNUSED(event);
Layer* layer = mEditor->layers()->currentLayer();
if (layer == NULL) { return; }
if (layer->type() == Layer::BITMAP)
{
BitmapImage *targetImage = ((LayerBitmap *)layer)->getLastBitmapImageAtFrame(mEditor->currentFrame(), 0);
if (targetImage->contains(getCurrentPoint()))
{
QColor pickedColour;
//pickedColour.setRgba(targetImage->pixel(getCurrentPoint().x(), getCurrentPoint().y()));
pickedColour.setRgba( targetImage->pixel( getCurrentPoint().x(), getCurrentPoint().y() ) );
int transp = 255 - pickedColour.alpha();
pickedColour.setRed( pickedColour.red() + transp );
pickedColour.setGreen( pickedColour.green() + transp );
pickedColour.setBlue( pickedColour.blue() + transp );
if (pickedColour.alpha() != 0)
{
mScribbleArea->setCursor(cursor(pickedColour));
}
else
{
mScribbleArea->setCursor(cursor());
}
}
else
{
mScribbleArea->setCursor(cursor());
}
}
if (layer->type() == Layer::VECTOR)
{
VectorImage *vectorImage = ((LayerVector *)layer)->getLastVectorImageAtFrame(mEditor->currentFrame(), 0);
int colourNumber = vectorImage->getColourNumber(getCurrentPoint());
if (colourNumber != -1)
{
mScribbleArea->setCursor(cursor(mEditor->object()->getColour(colourNumber).colour));
}
else
{
mScribbleArea->setCursor(cursor());
}
}
}
示例8: slotAddColor
void StyleSheetEditorDialog::slotAddColor(const QString &property)
{
bool ok;
QRgb rgba = QColorDialog::getRgba(0xffffffff, &ok, this);
if (!ok)
return;
QColor color;
color.setRgba(rgba);
QString colorStr;
if (color.alpha() == 255) {
colorStr = QString("rgb(%1, %2, %3)").arg(
color.red()).arg(color.green()).arg(color.blue());
} else {
colorStr = QString("rgba(%1, %2, %3, %4)").arg(
color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha());
}
insertCssProperty(property, colorStr);
}
示例9: drawColorBar
/*!
Draw a color bar into a rectangle
\param painter Painter
\param colorMap Color map
\param interval Value range
\param scaleMap Scale map
\param orientation Orientation
\param rect Traget rectangle
*/
void QwtPainter::drawColorBar( QPainter *painter,
const QwtColorMap &colorMap, const QwtInterval &interval,
const QwtScaleMap &scaleMap, Qt::Orientation orientation,
const QRectF &rect )
{
QVector<QRgb> colorTable;
if ( colorMap.format() == QwtColorMap::Indexed )
colorTable = colorMap.colorTable( interval );
QColor c;
const QRect devRect = rect.toAlignedRect();
/*
We paint to a pixmap first to have something scalable for printing
( f.e. in a Pdf document )
*/
QPixmap pixmap( devRect.size() );
QPainter pmPainter( &pixmap );
pmPainter.translate( -devRect.x(), -devRect.y() );
if ( orientation == Qt::Horizontal )
{
QwtScaleMap sMap = scaleMap;
sMap.setPaintInterval( rect.left(), rect.right() );
for ( int x = devRect.left(); x <= devRect.right(); x++ )
{
const double value = sMap.invTransform( x );
if ( colorMap.format() == QwtColorMap::RGB )
c.setRgba( colorMap.rgb( interval, value ) );
else
c = colorTable[colorMap.colorIndex( interval, value )];
pmPainter.setPen( c );
pmPainter.drawLine( x, devRect.top(), x, devRect.bottom() );
}
}
else // Vertical
{
QwtScaleMap sMap = scaleMap;
sMap.setPaintInterval( rect.bottom(), rect.top() );
for ( int y = devRect.top(); y <= devRect.bottom(); y++ )
{
const double value = sMap.invTransform( y );
if ( colorMap.format() == QwtColorMap::RGB )
c.setRgb( colorMap.rgb( interval, value ) );
else
c = colorTable[colorMap.colorIndex( interval, value )];
pmPainter.setPen( c );
pmPainter.drawLine( devRect.left(), y, devRect.right(), y );
}
}
pmPainter.end();
drawPixmap( painter, rect, pixmap );
}