本文整理汇总了C++中qAlpha函数的典型用法代码示例。如果您正苦于以下问题:C++ qAlpha函数的具体用法?C++ qAlpha怎么用?C++ qAlpha使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qAlpha函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qAlpha
int MetavoxelSystem::SimulateVisitor::visit(MetavoxelInfo& info) {
SpannerVisitor::visit(info);
if (!info.isLeaf) {
return _order;
}
QRgb color = info.inputValues.at(0).getInlineValue<QRgb>();
QRgb normal = info.inputValues.at(1).getInlineValue<QRgb>();
int alpha = qAlpha(color);
if (alpha > 0) {
Point point = { glm::vec4(info.minimum + glm::vec3(info.size, info.size, info.size) * 0.5f, info.size),
{ qRed(color), qGreen(color), qBlue(color), alpha }, { qRed(normal), qGreen(normal), qBlue(normal) } };
_points.append(point);
}
return STOP_RECURSION;
}
示例2: qRed
void FilterOp::filterHorizontally(QImage &src, QRgb *trg, const QRgb *rgba)
{
const uchar* pixels = src.constScanLine(0);
int sourcePitch = src.bytesPerLine();
for (int k = 0; k < srcHeight; ++k)
{
int destOfsY = dstWidth * k;
for (int i = dstWidth - 1; i >= 0 ; --i)
{
float red = 0;
float green = 0;
float blue = 0;
float alpha = 0;
int max = horizontalSubsamplingData.numberOfSamples[i];
int index = i * horizontalSubsamplingData.matrixWidth;
for (int j = max - 1; j >= 0; --j)
{
int ofsX = horizontalSubsamplingData.pixelPositions[index];
int palIdx = pixels[ofsX] & 0xff;
float w = horizontalSubsamplingData.weights[index];
red += qRed(rgba[palIdx]) * w;
green += qGreen(rgba[palIdx]) * w;
blue+= qBlue(rgba[palIdx]) * w;
alpha += qAlpha(rgba[palIdx]) * w;
index++;
}
int ri = std::max((int)red, 0);
ri = std::min(ri, 255);
int gi = std::max((int)green, 0);
gi = std::min(gi, 255);
int bi = std::max((int)blue, 0);
bi = std::min(bi, 255);
int ai = std::max((int)alpha, 0);
ai = std::min(ai, 255);
trg[i + destOfsY] = qRgba(ri, gi, bi, ai);
}
pixels += sourcePitch;
}
}
示例3: processImage
QImage ColorMatrixEffect::processImage(const QImage &image, const KoFilterEffectRenderContext &context) const
{
QImage result = image;
QRgb *src = (QRgb*)image.bits();
QRgb *dst = (QRgb*)result.bits();
int w = result.width();
const qreal * m = m_matrix.data();
qreal sa, sr, sg, sb;
qreal da, dr, dg, db;
QRect roi = context.filterRegion().toRect();
for (int row = roi.top(); row < roi.bottom(); ++row) {
for (int col = roi.left(); col < roi.right(); ++col) {
const QRgb &s = src[row*w+col];
sa = fromIntColor[qAlpha(s)];
sr = fromIntColor[qRed(s)];
sg = fromIntColor[qGreen(s)];
sb = fromIntColor[qBlue(s)];
// the matrix is applied to non-premultiplied color values
// so we have to convert colors by dividing by alpha value
if (sa > 0.0 && sa < 1.0) {
sr /= sa;
sb /= sa;
sg /= sa;
}
// apply matrix to color values
dr = m[ 0] * sr + m[ 1] * sg + m[ 2] * sb + m[ 3] * sa + m[ 4];
dg = m[ 5] * sr + m[ 6] * sg + m[ 7] * sb + m[ 8] * sa + m[ 9];
db = m[10] * sr + m[11] * sg + m[12] * sb + m[13] * sa + m[14];
da = m[15] * sr + m[16] * sg + m[17] * sb + m[18] * sa + m[19];
// the new alpha value
da *= 255.0;
// set pre-multiplied color values on destination image
dst[row*w+col] = qRgba(static_cast<quint8>(qBound(qreal(0.0), dr * da, qreal(255.0))),
static_cast<quint8>(qBound(qreal(0.0), dg * da, qreal(255.0))),
static_cast<quint8>(qBound(qreal(0.0), db * da, qreal(255.0))),
static_cast<quint8>(qBound(qreal(0.0), da, qreal(255.0))));
}
}
return result;
}
示例4: QColor
/**
* @param x
* @param y
* @return invalid color if x or y is outside image boundaries
*/
QColor Layer::colorAt(int x, int y, int dia) const
{
if(x<0 || y<0 || x>=_width || y>=_height)
return QColor();
if(dia<=1) {
quint32 c = pixelAt(x, y);
if(qAlpha(c)==0)
return QColor();
return QColor::fromRgb(c);
} else {
Brush b(dia, 0.9);
BrushStamp bs = makeGimpStyleBrushStamp(b, Point(x, y, 1));
return getDabColor(bs);
}
}
示例5: drawSpindaSpot
static void drawSpindaSpot(
QImage* image,
const spinda_coords* coords,
const char** single_spot_map,
const spinda_colors_t* face_colors,
const spinda_colors_t* spot_colors
)
{
for(size_t i = 0; i < MAX_SPOT_HEIGHT and single_spot_map[i] != NULL; ++i)
{
for(size_t j = 0; j < std::strlen(single_spot_map[i]); ++j)
{
if(single_spot_map[i][j] == '*')
{
QPoint point(
int(coords->x+j),
int(coords->y+i)
);
if(qAlpha(image->pixel(point)) > 0)
{
if(image->pixel(point) == face_colors->color_main.rgb())
{
image->setPixel(
point,
spot_colors->color_main.rgb()
);
}
else if(image->pixel(point) == face_colors->color_light.rgb())
{
image->setPixel(
point,
spot_colors->color_light.rgb()
);
}
else if(image->pixel(point) == face_colors->color_dark.rgb())
{
image->setPixel(
point,
spot_colors->color_dark.rgb()
);
}
}
}
}
}
}
示例6: QImage
QImage QKernelConv::inverseColor(QImage *src) {
QRgb color,color2;
int r,g,b,alpha;
QImage *ret = new QImage(src->width(),src->height(),src->format());
for (int i=0; i< src->height() ; i++) {
for (int j=0; j<src->width() ; j++) {
color=src->pixel(j,i);
r=255-qRed(color);
g=255-qBlue(color);
b=255-qGreen(color);
alpha=qAlpha(color);
color2=qRgba(r,g,b,alpha);
ret->setPixel(j,i,color2);
}
}
return *ret;
}
示例7: Q_UNUSED
QgsRasterBlock* QgsSingleBandColorDataRenderer::block( int bandNo, QgsRectangle const & extent, int width, int height )
{
Q_UNUSED( bandNo );
QgsRasterBlock *outputBlock = new QgsRasterBlock();
if ( !mInput )
{
return outputBlock;
}
QgsRasterBlock *inputBlock = mInput->block( mBand, extent, width, height );
if ( !inputBlock || inputBlock->isEmpty() )
{
QgsDebugMsg( "No raster data!" );
delete inputBlock;
return outputBlock;
}
bool hasTransparency = usesTransparency();
if ( !hasTransparency )
{
// Nothing to do, just retype if necessary
inputBlock->convert( QgsRasterBlock::ARGB32_Premultiplied );
delete outputBlock;
return inputBlock;
}
if ( !outputBlock->reset( QgsRasterBlock::ARGB32_Premultiplied, width, height ) )
{
delete inputBlock;
return outputBlock;
}
for ( size_t i = 0; i < ( size_t )width*height; i++ )
{
QRgb pixelColor;
double alpha = 255.0;
QRgb c = inputBlock->color( i );
alpha = qAlpha( c );
pixelColor = qRgba( mOpacity * qRed( c ), mOpacity * qGreen( c ), mOpacity * qBlue( c ), mOpacity * alpha );
outputBlock->setColor( i, pixelColor );
}
delete inputBlock;
return outputBlock;
}
示例8: newDisablePixmap
static QPixmap* newDisablePixmap(const QPixmap& pm)
{
// Use nice alpha-blended pixmaps
QImage i = pm.convertToImage().convertDepth(32);
for ( int y = 0; y < i.height(); y++ ) {
for ( int x = 0; x < i.width(); x++ ) {
QRgb p = i.pixel( x, y );
int a = qAlpha(p)/3;
int g = qGray(qRed(p),qGreen(p),qBlue(p));
i.setPixel( x, y, qRgba(g,g,g,a) );
}
}
i.setAlphaBuffer( TRUE );
QPixmap* r = new QPixmap;
r->convertFromImage(i);
return r;
}
示例9: qAlpha
// compute changes. TODO: implement functionality to do this on the gpu
void UnitySupportGui::addToSmoothness(int to_apply)
{
for (int y=0; y<image->height();y++)
{
for(int x = 0; x<image->width();x++)
{
QRgb* line_out = (QRgb *)image->scanLine(y);
line_out += x;
int appliedValue = qAlpha(*line_out)+to_apply;
int c = qGreen(*line_out);
//Supposed to be a grayscaled Image;
*line_out = qRgba(c,c,c,appliedValue);
}
}
}
示例10: iconToGrayscale
void SCRIBUS_API iconToGrayscale(QPixmap* pm)
{
QImage qi(pm->toImage());
int h=qi.height();
int w=qi.width();
QRgb c_rgb;
for (int i=0;i<w;++i)
{
for (int j=0;j<h;++j)
{
c_rgb=qi.pixel(i,j);
int k = qMin(qRound(0.3 * qRed(c_rgb) + 0.59 * qGreen(c_rgb) + 0.11 * qBlue(c_rgb)), 255);
qi.setPixel(i, j, qRgba(k, k, k, qAlpha(c_rgb)));
}
}
*pm=QPixmap::fromImage(qi);
}
示例11: crackImage
void Data::crackImage()
{
if(subImage.isNull()||maskImage.isNull())
return;
int w, h;
w=maskImage.width();
h=maskImage.height();
for(int y=0;y<h;y++)
{
for(int x=0;x<w;x++)
{
QRgb val=subImage.pixel(x,y);
if(qAlpha(val)==255)
{
QPoint p(x,y);
pixData newPix;
newPix.p=p;
newPix.d=val;
fp<<newPix;
index[getId(newPix.p)]=fp.count()-1;
}
}
}
for(int i=0;i<fp.count();i++)
{
QPoint newNeigh;
QPoint p;
p=fp[i].p;
newNeigh=p+QPoint(1,0);
checkNeigh(i,newNeigh);
newNeigh=p+QPoint(0,1);
checkNeigh(i,newNeigh);
newNeigh=p+QPoint(-1,0);
checkNeigh(i,newNeigh);
newNeigh=p+QPoint(0,-1);
checkNeigh(i,newNeigh);
}
}
示例12: newImage
QuillImage Sepia::apply(const QuillImage &image) const
{
QuillImage newImage(image);
QRgb *endp = (QRgb*)(newImage.bits()+newImage.byteCount());
// Apply the actual operation
for (QRgb *p=(QRgb*)newImage.bits(); p<endp; p++)
{
QRgb rgb = *p;
int colorvalue = (qRed(rgb)*299 + qGreen(rgb)*587 + qBlue(rgb)*114)
/ 1000;
int newRed, newGreen, newBlue;
if (colorvalue < 128) {
newRed = colorvalue;
newGreen = colorvalue * 104 / 128;
newBlue = colorvalue * 69 / 128;
}
else {
newRed = colorvalue;
newGreen = 104 + (colorvalue-128) * 152 / 128;
newBlue = 69 + (colorvalue-128) * 187 / 128;
}
if (newRed < 0) newRed = 0;
if (newRed > 255) newRed = 255;
if (newGreen < 0) newGreen = 0;
if (newGreen > 255) newGreen = 255;
if (newBlue < 0) newBlue = 0;
if (newBlue > 255) newBlue = 255;
*p = qRgba(newRed, newGreen, newBlue,
qAlpha(rgb));
}
newImage = Vignette::apply(newImage, 1.0, 0.5);
return newImage;
}
示例13: Q_UNUSED
RGBMap RGBImage::rgbMap(const QSize& size, uint rgb, int step)
{
Q_UNUSED(rgb);
QMutexLocker locker(&m_mutex);
if (m_image.width() == 0 || m_image.height() == 0)
return RGBMap();
int xOffs = xOffset();
int yOffs = yOffset();
switch(animationStyle())
{
default:
case Static:
break;
case Horizontal:
xOffs += step;
break;
case Vertical:
yOffs += step;
break;
case Animation:
xOffs += step * size.width();
break;
}
RGBMap map(size.height());
for (int y = 0; y < size.height(); y++)
{
map[y].resize(size.width());
for (int x = 0; x < size.width(); x++)
{
int x1 = (x + xOffs) % m_image.width();
int y1 = (y + yOffs) % m_image.height();
map[y][x] = m_image.pixel(x1,y1);
if (qAlpha(map[y][x]) == 0)
map[y][x] = 0;
}
}
return map;
}
示例14: QByteArray
/**
* Automatic marshaling of a QImage for org.freedesktop.Notifications.Notify
*
* This function is from the Clementine project (see
* http://www.clementine-player.org) and licensed under the GNU General Public
* License, version 3 or later.
*
* Copyright 2010, David Sansome <[email protected]>
*/
QDBusArgument &operator<<( QDBusArgument &arg, const QImage &image )
{
if ( image.isNull() )
{
arg.beginStructure();
arg << 0 << 0 << 0 << false << 0 << 0 << QByteArray();
arg.endStructure();
return arg;
}
QImage scaled = image.scaledToHeight( 100, Qt::SmoothTransformation );
scaled = scaled.convertToFormat( QImage::Format_ARGB32 );
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
// ABGR -> ARGB
QImage i = scaled.rgbSwapped();
#else
// ABGR -> GBAR
QImage i( scaled.size(), scaled.format() );
for ( int y = 0; y < i.height(); ++y )
{
QRgb *p = ( QRgb * ) scaled.scanLine( y );
QRgb *q = ( QRgb * ) i.scanLine( y );
QRgb *end = p + scaled.width();
while ( p < end )
{
*q = qRgba( qGreen( *p ), qBlue( *p ), qAlpha( *p ), qRed( *p ) );
p++;
q++;
}
}
#endif
arg.beginStructure();
arg << i.width();
arg << i.height();
arg << i.bytesPerLine();
arg << i.hasAlphaChannel();
int channels = i.isGrayscale() ? 1 : ( i.hasAlphaChannel() ? 4 : 3 );
arg << i.depth() / channels;
arg << channels;
arg << QByteArray( reinterpret_cast<const char *>( i.bits() ), i.numBytes() );
arg.endStructure();
return arg;
}
示例15: QColor
void RenderArea::updateInputPoints()
{
int intensity;
inputPoints->clear();
for (int i = 0; i < m_points_count; i++)
{
columnPoints *column = new columnPoints;
for (int o = m_points_count - 1; o >= 0; o--)
{
intensity = QColor(imageInput->pixel(centerX + i,centerY + o)).red();
FPoint *point = new FPoint;
if (imageMask)
{
QRgb bodMasky = imageMask->pixel(centerX + i,centerY + o);
if (qAlpha(bodMasky) == 255)
{
intensity = -1;
}
}
point->intensity = intensity;
/*
if (i == m_points_count - 1)
{
qDebug() << "o - intensity" << o << " - " << intensity;
// intenzita je v poøádku, test mapy je tøeba!
}
*/
column->append(point);
}
inputPoints->append(column);
}
emit pointsChanged();
}