本文整理汇总了C++中QColor::rgba方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::rgba方法的具体用法?C++ QColor::rgba怎么用?C++ QColor::rgba使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::rgba方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: devectorizeARGB
static void devectorizeARGB(const ImageContainer& srcImages, const QVector<Vec<16>>& vectors, const VectorQuantizer<16>& vq, int format, QVector<QImage>& indexedImages, QVector<quint64>& codebook) {
int vindex = 0;
for (int i=0; i<srcImages.imageCount(); i++) {
const QSize size = srcImages.getByIndex(i).size();
if (size.width() == 1 || size.height() == 1)
continue;
QImage img(size.width()/2, size.height()/2, QImage::Format_Indexed8);
img.setColorCount(256);
for (int y=0; y<img.height(); y++) {
for (int x=0; x<img.width(); x++) {
const Vec<16>& vec = vectors[vindex];
int codeIndex = vq.findClosest(vec);
img.setPixel(x, y, codeIndex);
vindex++;
}
}
indexedImages.push_back(img);
}
for (int i=0; i<vq.codeCount(); i++) {
const Vec<16>& vec = vq.codeVector(i);
QColor tl = QColor::fromRgbF(vec[1], vec[2], vec[3], vec[0]);
QColor tr = QColor::fromRgbF(vec[5], vec[6], vec[7], vec[4]);
QColor bl = QColor::fromRgbF(vec[9], vec[10], vec[11], vec[8]);
QColor br = QColor::fromRgbF(vec[13], vec[14], vec[15], vec[12]);
quint64 quad = packQuad(tl.rgba(), tr.rgba(), bl.rgba(), br.rgba(), format);
codebook.push_back(quad);
}
}
示例2:
BitmapImage::BitmapImage(const QRect& rectangle, const QColor& colour)
{
mBounds = rectangle;
mImage = std::make_shared<QImage>(mBounds.size(), QImage::Format_ARGB32_Premultiplied);
mImage->fill(colour.rgba());
mMinBound = false;
}
示例3: drawComponent
QImage HistogramGenerator::drawComponent(const int *y, const QSize &size, const float &scaling, const QColor &color,
const bool &unscaled, const uint &max) const
{
QImage component(max, size.height(), QImage::Format_ARGB32);
component.fill(qRgba(0, 0, 0, 0));
Q_ASSERT(scaling != INFINITY);
const int partH = size.height();
int partY;
for (uint x = 0; x < max; x++) {
// Calculate the height of the curve at position x
partY = scaling*y[x];
// Invert the y axis
if (partY > partH-1) { partY = partH-1; }
partY = partH-1 - partY;
for (int k = partH-1; k >= partY; k--) {
component.setPixel(x, k, color.rgba());
}
}
if (unscaled && size.width() >= component.width()) {
return component;
} else {
return component.scaled(size, Qt::IgnoreAspectRatio, Qt::FastTransformation);
}
}
示例4: setBrush
void QPdfEngine::setBrush()
{
Q_D(QPdfEngine);
Qt::BrushStyle style = d->brush.style();
if (style == Qt::NoBrush)
return;
bool specifyColor;
int gStateObject = 0;
int patternObject = d->addBrushPattern(d->stroker.matrix, &specifyColor, &gStateObject);
*d->currentPage << (patternObject ? "/PCSp cs " : "/CSp cs ");
if (specifyColor) {
QColor rgba = d->brush.color();
if (d->colorMode == QPrinter::GrayScale) {
qreal gray = qGray(rgba.rgba())/255.;
*d->currentPage << gray << gray << gray;
} else {
*d->currentPage << rgba.redF()
<< rgba.greenF()
<< rgba.blueF();
}
}
if (patternObject)
*d->currentPage << "/Pat" << patternObject;
*d->currentPage << "scn\n";
if (gStateObject)
*d->currentPage << "/GState" << gStateObject << "gs\n";
else
*d->currentPage << "/GSa gs\n";
}
示例5: solidFill
void KermitScreen::solidFill(const QColor &color, const QRegion ®ion)
{
//qDebug("KermitScreen::solidFill ");
if (depth() != 8)
{
qWarning("Fallback to QScreen as the depth is not 8 %d", depth());
QScreen::solidFill(color, region);
return;
}
unsigned char *base = QScreen::data;
if (base == 0)
{
qWarning("Framebuffer is empty.");
return;
}
unsigned char gray = (qGray(color.rgba()) & 0xff);
const QVector<QRect> rects = region.rects();
for (int i = 0; i < rects.size(); ++i)
{
const QRect r = rects.at(i);
for(int y = r.top(); y < r.top() + r.height(); ++y)
{
unsigned char *p = base + y * QScreen::w + r.left();
memset(p, r.width(), gray);
}
}
// qDebug("KermitScreen::solidFill done");
}
示例6: pixel
uint QColormap::pixel(const QColor &color) const
{
QRgb rgb = color.rgba();
if (d->mode == QColormap::Direct) {
switch(d->depth) {
case 16:
return qt_convRgbTo16(rgb);
case 24:
case 32:
{
const int r = qRed(rgb);
const int g = qGreen(rgb);
const int b = qBlue(rgb);
const int red_shift = 16;
const int green_shift = 8;
const int red_mask = 0xff0000;
const int green_mask = 0x00ff00;
const int blue_mask = 0x0000ff;
const int tg = g << green_shift;
#ifdef QT_QWS_DEPTH_32_BGR
if (qt_screen->pixelType() == QScreen::BGRPixel) {
const int tb = b << red_shift;
return 0xff000000 | (r & blue_mask) | (tg & green_mask) | (tb & red_mask);
}
#endif
const int tr = r << red_shift;
return 0xff000000 | (b & blue_mask) | (tg & green_mask) | (tr & red_mask);
}
}
}
return qt_screen->alloc(qRed(rgb), qGreen(rgb), qBlue(rgb));
}
示例7: apply
void RedEyeReductionImageOperation::apply(QImage* img, const QRectF& rectF)
{
const QRect rect = PaintUtils::containingRect(rectF);
const qreal radius = rectF.width() / 2;
const qreal centerX = rectF.x() + radius;
const qreal centerY = rectF.y() + radius;
const Ramp radiusRamp(qMin(double(radius * 0.7), double(radius - 1)), radius, 1., 0.);
uchar* line = img->scanLine(rect.top()) + rect.left() * 4;
for (int y = rect.top(); y < rect.bottom(); ++y, line += img->bytesPerLine()) {
QRgb* ptr = (QRgb*)line;
for (int x = rect.left(); x < rect.right(); ++x, ++ptr) {
const qreal currentRadius = sqrt(pow(y - centerY, 2) + pow(x - centerX, 2));
qreal alpha = radiusRamp(currentRadius);
if (qFuzzyCompare(alpha, 0)) {
continue;
}
const QColor src(*ptr);
alpha *= computeRedEyeAlpha(src);
int r = src.red();
int g = src.green();
int b = src.blue();
QColor dst;
// Replace red with green, and blend according to alpha
dst.setRed(int((1 - alpha) * r + alpha * g));
dst.setGreen(int((1 - alpha) * g + alpha * g));
dst.setBlue(int((1 - alpha) * b + alpha * b));
*ptr = dst.rgba();
}
}
}
示例8: setColorKey
void QGstreamerVideoWindow::setColorKey(const QColor &color)
{
m_colorKey = color;
if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "colorkey"))
g_object_set(G_OBJECT(m_videoSink), "colorkey", color.rgba(), NULL);
}
示例9: fillColor
void Tile::fillColor(const QColor& color)
{
const quint32 c = color.rgba();
quint32 *ptr = getOrCreateUninitializedData();
for(int i=0;i<LENGTH;++i)
*(ptr++) = c;
}
示例10: composite
/**
* @param values array of alpha values
* @param color composite color
* @param x offset in the tile
* @param y offset in the tile
* @param w values in tile (must be < SIZE)
* @param h values in tile (must be < SIZE)
* @param skip values to skip to reach the next line
*/
void Tile::composite(int mode, const uchar *values, const QColor& color, int x, int y, int w, int h, int skip)
{
Q_ASSERT(x>=0 && x<SIZE && y>=0 && y<SIZE);
Q_ASSERT((x+w)<=SIZE && (y+h)<=SIZE);
compositeMask(mode, getOrCreateData() + y * SIZE + x,
color.rgba(), values, w, h, skip, SIZE-w);
}
示例11: smoothImage
QImage edge_detector::smoothImage(const QImage image)
{
QImage destImage = QImage( image);
QColor qc;
int Gauss[5][5] = {{2, 4, 5, 4, 2}, {4, 9, 12, 9, 4}, {5, 12, 15, 12, 5},
{4, 9, 12, 9, 4}, {2, 4, 5, 4, 2}};
int **G = new int*[5];
for (int i=0; i<5; i++)
{
G[i] = new int[5];
for(int j=0; j<5; j++)
G[i][j] = Gauss[i][j];
}
int H = image.height();
int W = image.width();
int* destData= (int *)destImage.bits();
int **a, smooth;
for (int y=2; y<H-2; y++)
{
for (int x=2; x<W-2; x++)
{
a = get_neighbor_pixels(image, x, y, 2);
smooth = convolve(a, G, 5) / 159.f;
deleteArray(a, 5); //2*2+1
qc.setRgb(smooth, smooth, smooth);
destData[x + y*W] = qc.rgba();
}
}
return destImage;
}
示例12: fill
void QBlittablePlatformPixmap::fill(const QColor &color)
{
if (blittable()->capabilities() & QBlittable::AlphaFillRectCapability) {
blittable()->unlock();
blittable()->alphaFillRect(QRectF(0,0,w,h),color,QPainter::CompositionMode_Source);
} else if (color.alpha() == 255 && blittable()->capabilities() & QBlittable::SolidRectCapability) {
blittable()->unlock();
blittable()->fillRect(QRectF(0,0,w,h),color);
} else {
// Need to be backed with an alpha channel now. It would be nice
// if we could just change the format, e.g. when going from
// RGB32 -> ARGB8888.
if (color.alpha() != 255 && !hasAlphaChannel()) {
m_blittable.reset(0);
m_engine.reset(0);
m_alpha = true;
}
uint pixel = PREMUL(color.rgba());
const QPixelLayout *layout = &qPixelLayouts[blittable()->lock()->format()];
Q_ASSERT(layout->convertFromARGB32PM);
layout->convertFromARGB32PM(&pixel, &pixel, 1, layout, 0);
//so premultiplied formats are supported and ARGB32 and RGB32
blittable()->lock()->fill(pixel);
}
}
示例13: QImage
BitmapImage::BitmapImage(QRect rectangle, QColor colour)
{
mBounds = rectangle;
mImage = new QImage( mBounds.size(), QImage::Format_ARGB32_Premultiplied);
mImage->fill(colour.rgba());
mExtendable = true;
}
示例14: qt_plastique_draw_handle
static void qt_plastique_draw_handle(QPainter *painter, const QStyleOption *option,
const QRect &rect, Qt::Orientation orientation,
const QWidget *widget)
{
QColor borderColor = option->palette.background().color().darker(178);
QColor alphaCornerColor;
if (widget) {
// ### backgroundrole/foregroundrole should be part of the style option
alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor);
} else {
alphaCornerColor = mergedColors(option->palette.background().color(), borderColor);
}
QImage handle(qt_simple_toolbarhandle);
handle.setColor(1, alphaCornerColor.rgba());
handle.setColor(2, mergedColors(alphaCornerColor, option->palette.base().color()).rgba());
handle.setColor(3, option->palette.base().color().rgba());
const int spacing = 2;
if (orientation == Qt::Vertical) {
int nchunks = rect.width() / (handle.width() + spacing);
for (int i = 0; i < nchunks; ++i)
painter->drawImage(QPoint(rect.left() + i * (handle.width() + spacing), rect.top()), handle);
} else {
int nchunks = rect.height() / (handle.height() + spacing);
for (int i = 0; i < nchunks; ++i)
painter->drawImage(QPoint(rect.left(), rect.top() + i * (handle.height() + spacing)), handle);
}
}
示例15: solidFill
void QAhiScreen::solidFill(const QColor &color, const QRegion ®)
{
AhiSts_t status = AhiStsOk;
switch (pixelFormat()) {
case QImage::Format_ARGB32_Premultiplied:
case QImage::Format_ARGB32:
case QImage::Format_RGB32:
status = AhiDrawBrushFgColorSet(d_ptr->context, color.rgba());
break;
case QImage::Format_RGB16:
status = AhiDrawBrushFgColorSet(d_ptr->context, qt_convRgbTo16(color.rgb()));
break;
default:
qFatal("QAhiScreen::solidFill(): Not implemented for pixel format %d",
int(pixelFormat()));
break;
}
if (status != AhiStsOk) {
qWarning("QAhiScreen::solidFill(): AhiDrawBrushFgColorSet failed: %x",
status);
return;
}
status = AhiDrawBrushSet(d_ptr->context, 0, 0, 0, AHIFLAG_BRUSHSOLID);
if (status != AhiStsOk) {
qWarning("QAhiScreen::solidFill(): AhiDrawBrushSet failed: %x",
status);
return;
}
status = AhiDrawRopSet(d_ptr->context, AHIMAKEROP3(AHIROPPATCOPY));
if (status != AhiStsOk) {
qWarning("QAhiScreen::solidFill(): AhiDrawRopSet failed: %x", status);
return;
}
status = AhiDrawSurfDstSet(d_ptr->context, d_ptr->surface, 0);
if (status != AhiStsOk) {
qWarning("QAhiScreen::solidFill(): AhiDrawSurfDst failed: %x", status);
return;
}
const QVector<QRect> rects = (reg & region()).rects();
QVarLengthArray<AhiRect_t> ahiRects(rects.size());
for (int i = 0; i < rects.size(); ++i) {
const QRect rect = rects.at(i);
ahiRects[i].left = rect.left();
ahiRects[i].top = rect.top();
ahiRects[i].right = rect.x() + rect.width();
ahiRects[i].bottom = rect.y() + rect.height();
}
status = AhiDrawBitBltMulti(d_ptr->context, ahiRects.data(),
0, ahiRects.size());
if (status != AhiStsOk)
qWarning("QAhiScreen::solidFill(): AhiDrawBitBlt failed: %x", status);
}