本文整理汇总了C++中qAlpha函数的典型用法代码示例。如果您正苦于以下问题:C++ qAlpha函数的具体用法?C++ qAlpha怎么用?C++ qAlpha使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qAlpha函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Chris7,项目名称:hifi,代码行数:16,代码来源:MetavoxelSystem.cpp
示例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;
}
}
开发者ID:Karim-AlHousiny,项目名称:BDSup2SubPlusPlus,代码行数:47,代码来源:filterop.cpp
示例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;
}
开发者ID:KDE,项目名称:calligra-history,代码行数:47,代码来源:ColorMatrixEffect.cpp
示例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);
}
}
开发者ID:LionsPhil,项目名称:Drawpile,代码行数:22,代码来源:layer.cpp
示例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()
);
}
}
}
}
}
}
开发者ID:ncorgan,项目名称:libpkmn,代码行数:46,代码来源:Spinda.cpp
示例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;
}
开发者ID:LilyOfTheWest,项目名称:image,代码行数:17,代码来源:qkernelconv.cpp
示例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;
}
开发者ID:carsonfarmer,项目名称:Quantum-GIS,代码行数:46,代码来源:qgssinglebandcolordatarenderer.cpp
示例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;
}
开发者ID:opieproject,项目名称:qte-opie,代码行数:17,代码来源:qiconset.cpp
示例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);
}
}
}
开发者ID:DaOnlyOwner,项目名称:AwesomeBump,代码行数:18,代码来源:unitysupportgui.cpp
示例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);
}
开发者ID:JLuc,项目名称:scribus,代码行数:17,代码来源:util_icon.cpp
示例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);
}
}
开发者ID:MinjieTao,项目名称:PoissonImage,代码行数:46,代码来源:data.cpp
示例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;
}
开发者ID:amtep,项目名称:quillimagefilters,代码行数:45,代码来源:sepia.cpp
示例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;
}
开发者ID:bjorkegeek,项目名称:qlcplus,代码行数:45,代码来源:rgbimage.cpp
示例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;
}
开发者ID:SrNetoChan,项目名称:Quantum-GIS,代码行数:54,代码来源:qgslinuxnative.cpp
示例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();
}
开发者ID:tucna,项目名称:image_reconstruction,代码行数:44,代码来源:renderarea.cpp
示例16: qAlpha
void FilterOp::filterVertically(QVector<QRgb>& src, QVector<QRgb>& trg)
{
const QRgb *inPixels = src.constData();
for (int x = 0; x < dstWidth; ++x)
{
for (int y = dstHeight - 1; y >= 0 ; --y)
{
int yTimesNumContributors = y * verticalSubsamplingData.matrixWidth;
int max = verticalSubsamplingData.numberOfSamples[y];
int ofsY = dstWidth * y;
float red = 0;
float green = 0;
float blue = 0;
float alpha = 0;
int index = yTimesNumContributors;
for (int j = max - 1; j >= 0 ; --j)
{
int color = inPixels[x + (dstWidth * verticalSubsamplingData.pixelPositions[index])];
float w = verticalSubsamplingData.weights[index];
alpha += qAlpha(color) * w;
red += qRed(color) * w;
green += qGreen(color) * w;
blue += qBlue(color) * 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[x + ofsY] = qRgba(ri, gi, bi, ai);
}
}
}
开发者ID:Karim-AlHousiny,项目名称:BDSup2SubPlusPlus,代码行数:44,代码来源:filterop.cpp
示例17: QPixmap
void Cell::initPixmaps()
{
typedef QMap<int, QString> NamesMap;
NamesMap names;
names[L] = "0001";
names[D] = "0010";
names[D|L] = "0011";
names[R] = "0100";
names[R|L] = "0101";
names[R|D] = "0110";
names[R|D|L] = "0111";
names[U] = "1000";
names[U|L] = "1001";
names[U|D] = "1010";
names[U|D|L] = "1011";
names[U|R] = "1100";
names[U|R|L] = "1101";
names[U|R|D] = "1110";
NamesMap::ConstIterator it;
for(it = names.constBegin(); it != names.constEnd(); ++it)
{
connectedpixmap[it.key()] = new QPixmap(":/cable" + it.value() + ".png");
QImage image = connectedpixmap[it.key()]->toImage();
for(int y = 0; y < image.height(); y++)
{
QRgb* line = (QRgb*)image.scanLine(y);
for(int x = 0; x < image.width(); x++)
{
QRgb pix = line[x];
if(qAlpha(pix) == 255)
{
int g = (255 + 4 * qGreen(pix)) / 5;
int b = (255 + 4 * qBlue(pix)) / 5;
int r = (255 + 4 * qRed(pix)) / 5;
line[x] = qRgb(r, g, b);
}
}
}
disconnectedpixmap[it.key()] = new QPixmap(QPixmap::fromImage(image));
}
}
开发者ID:radekp,项目名称:qneoroid,代码行数:44,代码来源:cell.cpp
示例18: imageData
bb::ImageData PictureHelper::fromQImage(const QImage &qImage)
{
bb::ImageData imageData(bb::PixelFormat::RGBA_Premultiplied, qImage.width(), qImage.height());
unsigned char *dstLine = imageData.pixels();
for (int y = 0; y < imageData.height(); y++) {
unsigned char * dst = dstLine;
for (int x = 0; x < imageData.width(); x++) {
QRgb srcPixel = qImage.pixel(x, y);
*dst++ = qRed(srcPixel);
*dst++ = qGreen(srcPixel);
*dst++ = qBlue(srcPixel);
*dst++ = qAlpha(srcPixel);
}
dstLine += imageData.bytesPerLine();
}
return imageData;
}
开发者ID:ndp190,项目名称:clock_w_gallery,代码行数:19,代码来源:PictureHelper.cpp
示例19: qRed
void StickyNoteActor::toGrayScale(QImage& image, int bias) const
{
// naive grayscale conversion, since it is only done once when
// the theme is loaded/changed
// http://en.wikipedia.org/wiki/Grayscale
QRgb pixel;
int gray = 0;
int width = image.width();
int height = image.height();
for (int i = 0; i < height; ++i)
{
for (int j = 0; j < width; ++j)
{
pixel = image.pixel(j, i);
gray = (11 * qRed(pixel) + 16 * qGreen(pixel) + 5 * qBlue(pixel)) / 32 + bias;
image.setPixel(j, i, qRgba(gray, gray, gray, qAlpha(pixel)));
}
}
}
开发者ID:DX94,项目名称:BumpTop,代码行数:19,代码来源:BT_StickyNoteActor.cpp
示例20: addImage
static void addImage( FlifEncoder& encoder, const QImage& in ) {
FlifImage img( in.width(), in.height() );
auto buffer = std::make_unique<uint8_t[]>( in.width() * 4 );
for( int iy=0; iy<in.height(); iy++ ) {
auto line = (const QRgb*)in.constScanLine( iy );
for( int ix=0; ix<in.width(); ix++ ) {
buffer[ix*4+0] = qRed( line[ix] );
buffer[ix*4+1] = qGreen( line[ix] );
buffer[ix*4+2] = qBlue( line[ix] );
buffer[ix*4+3] = qAlpha( line[ix] );
}
img.writeRowRgba8( iy, buffer.get(), in.width() * 4 );
}
encoder.addImage( img ); //TODO: investigate memory model
}
开发者ID:spillerrec,项目名称:qt-flif-plugin,代码行数:19,代码来源:FlifPlugin.cpp
注:本文中的qAlpha函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论