本文整理汇总了C++中qBlue函数的典型用法代码示例。如果您正苦于以下问题:C++ qBlue函数的具体用法?C++ qBlue怎么用?C++ qBlue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qBlue函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: connect
void Widget::initializeGL()
{
timer.setInterval (10);
timer.setSingleShot(false);
timer.start();
connect(&timer, SIGNAL(timeout()), this, SLOT(onTimer()));
initializeGLFunctions();
printf("\n%s\n", glGetString(GL_VERSION));
printf("%s\n", glGetString(GL_VENDOR));
printf("%s\n", glGetString(GL_RENDERER));
fflush (stdout);
QImage part_img (":/match.png");
for (int line = 0; line < part_img.height(); line++)
{
QRgb *pixel = (QRgb *)part_img.scanLine (line);
for (int b = 0; b < part_img.width(); b++)
if( 0 == qRed(pixel[b]) &&
0 == qGreen(pixel[b]) &&
0 == qBlue(pixel[b])
) {
pixel[b] = 0x00ffffff;
}
}
partTexture = bindTexture (part_img,
GL_TEXTURE_2D,
GL_RGBA,
QGLContext::DefaultBindOption);
myShader.addShaderFromSourceFile(QGLShader::Vertex, ":/ground.vert");
myShader.addShaderFromSourceFile(QGLShader::Fragment, ":/ground.frag");
myShader.link();
particle.addShaderFromSourceFile(QGLShader::Vertex,":/particle.vert");
particle.addShaderFromSourceFile(QGLShader::Fragment,":/particle.frag");
particle.link();
terrainMesh.loadRawTriangles(":/terrain.raw");
terrainTexture =bindTexture(QImage(":/terrain.jpg"));
}
开发者ID:f1z1k,项目名称:fire,代码行数:42,代码来源:widget.cpp
示例2: qRed
// Add random noise to the image
void MainWindow::AddNoise(QImage *image, double mag, bool colorNoise)
{
int r, c;
QRgb pixel;
int noiseMag = mag;
noiseMag *= 2;
for(r=0;r<image->height();r++)
{
for(c=0;c<image->width();c++)
{
pixel = image->pixel(c, r);
int red = qRed(pixel);
int green = qGreen(pixel);
int blue = qBlue(pixel);
// If colorNoise, add color independently to each channel
if(colorNoise)
{
red += rand()%noiseMag - noiseMag/2;
green += rand()%noiseMag - noiseMag/2;
blue += rand()%noiseMag - noiseMag/2;
}
// otherwise add the same amount of noise to each channel
else
{
int noise = rand()%noiseMag - noiseMag/2;
red += noise;
green += noise;
blue += noise;
}
// Make sure we don't over or under saturate
red = min(255, max(0, red));
green = min(255, max(0, green));
blue = min(255, max(0, blue));
image->setPixel(c, r, qRgb( red, green, blue));
}
}
}
开发者ID:mandary,项目名称:ComputerVision,代码行数:43,代码来源:Project1.cpp
示例3: for
void Histogram::generate(QImage* image)
{
int width = image->width();
int height = image->height();
if (image->format() == QImage::Format_Indexed8)
{
for (int x=0; x<width; x++)
{ for (int y=0; y<height; y++)
{
QRgb pixel = image->pixel(x, y);
int l = qGray(pixel);
int value = L-> value(l)+1;
L -> insert(l, value);
}
}
}
else
{
for (int x=0; x<width; x++)
{ for (int y=0; y<height; y++)
{
QRgb pixel = image->pixel(x, y);
int r = qRed(pixel);
int g = qGreen(pixel);
int b = qBlue(pixel);
int valueR = R-> value(r)+1;
int valueG = G-> value(g)+1;
int valueB = B-> value(b)+1;
R -> insert(r, valueR);
G -> insert(g, valueG);
B -> insert(b, valueB);
}
}
}
}
开发者ID:irmina90,项目名称:pto2014_klozie,代码行数:42,代码来源:histogram.cpp
示例4: RGB24Buffer
RGB24Buffer *QTFileLoader::RGB24BufferFromQImage(QImage *image)
{
if (image == NULL)
return NULL;
RGB24Buffer *result = new RGB24Buffer(image->height(), image->width(), false);
if (image->format() == QImage::Format_ARGB32 || image->format() == QImage::Format_RGB32 )
{
for (int i = 0; i < image->height(); i++)
{
uint8_t *in = (uint8_t *)image->scanLine(i);
RGBColor *out = &result->element(i, 0);
for (int j = 0; j < image->width(); j++)
{
uint8_t r = *(in++);
uint8_t g = *(in++);
uint8_t b = *(in++);
*out = RGBColor(b,g,r);
in++;
out++;
}
}
} else {
/**
* TODO: Make this faster using .bits() method.
* So far don't want to mess with possible image formats
*
*/
qDebug("QTFileLoader::RGB24BufferFromQImage():Slow conversion.");
for (int i = 0; i < image->height(); i++)
{
for (int j = 0; j < image->width(); j++)
{
QRgb pixel = image->pixel(j,i);
result->element(i,j) = RGBColor(qRed(pixel), qGreen(pixel), qBlue(pixel));
}
}
}
return result;
}
开发者ID:Aldrog,项目名称:corecvs,代码行数:42,代码来源:qtFileLoader.cpp
示例5: paintShadow
void paintShadow(QPainter *p, const QRect &r, const ShadowSettings &settings, const QImage &shadowImage)
{
const int s = -settings.size;
QRect rect = r.adjusted(s - 32, s - 32, 32 - s, 32 - s);
rect.adjust(settings.offsetX, settings.offsetY, settings.offsetX, settings.offsetY);
int radius = shadowImage.width() / 2;
// corners
for (int i = 0; i < 4; ++i) {
const int x = i & 1 ? rect.x() : rect.x() + rect.width() - radius;
const int y = i & 2 ? rect.y() : rect.y() + rect.height() - radius;
p->drawImage(x, y, shadowImage,
i & 1 ? 0 : radius + 1, i & 2 ? 0 : radius + 1, radius, radius);
}
// sides
for (int i = 0; i < 2; ++i) {
const int x = rect.x() + radius;
const int y = i & 1 ? rect.y() : rect.y() + rect.height() - radius;
p->drawTiledPixmap(x, y, rect.width() - 2 * radius, radius,
QPixmap::fromImage(shadowImage.copy(radius, i & 1 ? 0 : radius + 1, 1, radius)));
}
for (int i = 0; i < 2; ++i) {
const int x = i & 1 ? rect.x() : rect.x() + rect.width() - radius;
const int y = rect.y() + radius;
p->drawTiledPixmap(x, y, radius, rect.height() - 2 * radius,
QPixmap::fromImage(shadowImage.copy(i & 1 ? 0 : radius + 1, radius, radius, 1)));
}
// center
QRgb pixel = shadowImage.pixel(radius, radius);
if (shadowImage.format() == QImage::Format_ARGB32_Premultiplied) {
const int alpha = qAlpha(pixel);
if (alpha != 0 && alpha != 255) {
pixel = qRgba(qBound(0, qRed(pixel) * 255 / alpha, 255),
qBound(0, qGreen(pixel) * 255 / alpha, 255),
qBound(0, qBlue(pixel) * 255 / alpha, 255),
alpha);
}
}
p->fillRect(rect.adjusted(radius, radius, -radius, -radius), QColor::fromRgba(pixel));
}
开发者ID:KDE,项目名称:smaragd,代码行数:42,代码来源:shadowengine.cpp
示例6: int
/**
* Changes the transparency (alpha component) of an image.
* @param image Image to be manipulated. Must be true color (8 bit per channel).
* @param factor > 1.0 == more transparency, < 1.0 == less transparency.
*/
void PlaylistItem::imageTransparency( QImage& image, float factor ) //static
{
uint *data = reinterpret_cast<unsigned int *>( image.bits() );
const int pixels = image.width() * image.height();
uint table[256];
register int c;
// Precalculate lookup table
for( int i = 0; i < 256; ++i ) {
c = int( double( i ) * factor );
if( c > 255 ) c = 255;
table[i] = c;
}
// Process all pixels. Highly optimized.
for( int i = 0; i < pixels; ++i ) {
c = data[i]; // Memory access is slow, so do it only once
data[i] = qRgba( qRed( c ), qGreen( c ), qBlue( c ), table[qAlpha( c )] );
}
}
开发者ID:gms8994,项目名称:amarok-1.4,代码行数:25,代码来源:playlistitem.cpp
示例7: Matrix
/*!
Used to convert RGB Jpg files to grayscale.
\param image a QImage with original image data points
\return a grayscale Matrix from QImage
*/
Matrix ImageB::convertRGB2Gray( QImage image )
{
QRgb pix;
Matrix mat = Matrix(image.height(),image.width());
for (long i=1; i <= image.width();i++)
{
for(long j=1; j <= image.height();j++)
{
int h =0;
pix = image.pixel(i,j); //pega valor do pixel
//média dos pixels
h = int((qRed(pix) + qGreen(pix) + qBlue(pix))/3);
mat(j,i) = h; //seta dado na matriz
}
}
return mat;
}
开发者ID:Guokr1991,项目名称:ImageB,代码行数:26,代码来源:imageb.cpp
示例8: levelImage
//==============================================================================
void GameServer::LoadLevelFromImage_(const QString filename)
{
QFile levelImage(filename);
if (levelImage.exists())
{
QImage map;
map.load(filename, "png");
levelMap_.Resize(map.width(), map.height());
for (int i = 0; i < map.height(); i++)
{
for (int j = 0; j < map.width(); j++)
{
auto color = map.pixel(j, i);
int summ = qRed(color) + qGreen(color) + qBlue(color);
int value = summ > (255 * 3 / 2) ? '.' : '#';
levelMap_.SetCell(j, i, value);
}
}
}
}
开发者ID:dahin,项目名称:fefu-mmorpg,代码行数:21,代码来源:GameServer.cpp
示例9: _binarize
static void _binarize(QString sourceFile, QString destFile)
{
QImage image(sourceFile);
int width = image.width();
int height = image.height();
QRgb color;
QRgb avg;
QRgb black = qRgb(0, 0, 0);
QRgb white = qRgb(255, 255, 255);
for(int i = 0; i < width; i++)
{
for(int j= 0; j < height; j++)
{
color = image.pixel(i, j);
avg = (qRed(color) + qGreen(color) + qBlue(color))/3;
image.setPixel(i, j, avg >= 128 ? white : black);
}
}
image.save(destFile);
}
开发者ID:hywwqq,项目名称:Android,代码行数:20,代码来源:imageProcessor.cpp
示例10: qRgba
void ImageHandler::ghostImage(QImage *img)
{
int w = img->width(),
h = img->height(),
x, y;
for (y=0; y<h; y++)
{
uint *line = (uint*)img->scanLine(y);
for (x=0; x<w; x++)
{
//if ((x%2 && !(y%2)) || (!(x%2) && y%2))
{
line[x] = qRgba(qRed(line[x]), qGreen(line[x]), qBlue(line[x]), (line[x] ? 125 : 0));
}
}
}
}
开发者ID:alserkli,项目名称:qgo,代码行数:20,代码来源:imagehandler.cpp
示例11: fuzzyComparePixels
static bool fuzzyComparePixels(const QRgb testPixel, const QRgb refPixel, const char* file, int line, int x = -1, int y = -1)
{
static int maxFuzz = 1;
static bool maxFuzzSet = false;
// On 16 bpp systems, we need to allow for more fuzz:
if (!maxFuzzSet) {
maxFuzzSet = true;
if (QGuiApplication::primaryScreen()->depth() < 24)
maxFuzz = 32;
}
int redFuzz = qAbs(qRed(testPixel) - qRed(refPixel));
int greenFuzz = qAbs(qGreen(testPixel) - qGreen(refPixel));
int blueFuzz = qAbs(qBlue(testPixel) - qBlue(refPixel));
int alphaFuzz = qAbs(qAlpha(testPixel) - qAlpha(refPixel));
if (refPixel != 0 && testPixel == 0) {
QString msg;
if (x >= 0) {
msg = QString("Test pixel [%1, %2] is null (black) when it should be (%3,%4,%5,%6)")
.arg(x).arg(y)
.arg(qRed(refPixel)).arg(qGreen(refPixel)).arg(qBlue(refPixel)).arg(qAlpha(refPixel));
} else {
msg = QString("Test pixel is null (black) when it should be (%2,%3,%4,%5)")
.arg(qRed(refPixel)).arg(qGreen(refPixel)).arg(qBlue(refPixel)).arg(qAlpha(refPixel));
}
QTest::qFail(msg.toLatin1(), file, line);
return false;
}
if (redFuzz > maxFuzz || greenFuzz > maxFuzz || blueFuzz > maxFuzz || alphaFuzz > maxFuzz) {
QString msg;
if (x >= 0)
msg = QString("Pixel [%1,%2]: ").arg(x).arg(y);
else
msg = QString("Pixel ");
msg += QString("Max fuzz (%1) exceeded: (%2,%3,%4,%5) vs (%6,%7,%8,%9)")
.arg(maxFuzz)
.arg(qRed(testPixel)).arg(qGreen(testPixel)).arg(qBlue(testPixel)).arg(qAlpha(testPixel))
.arg(qRed(refPixel)).arg(qGreen(refPixel)).arg(qBlue(refPixel)).arg(qAlpha(refPixel));
QTest::qFail(msg.toLatin1(), file, line);
return false;
}
return true;
}
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:49,代码来源:tst_qopengl.cpp
示例12: qGreen
QPixmap Cell::fadedPixmap(const QPixmap & pixmap)
{
QImage image = pixmap.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 + 3 * qGreen(pix)) / 4;
int b = (255 + 3 * qBlue(pix)) / 4;
int r = (255 + 3 * qRed(pix)) / 4;
line[x] = qRgb(r, g, b);
}
}
}
return QPixmap::fromImage(image);
}
开发者ID:Summeli,项目名称:NetwalkMobile-BB10,代码行数:20,代码来源:cell.cpp
示例13: Q_ASSERT
void CloudsBlending::blend( QImage * const bottom, TextureTile const * const top ) const
{
QImage const * const topImage = top->image();
Q_ASSERT( topImage );
Q_ASSERT( bottom->size() == topImage->size() );
int const width = bottom->width();
int const height = bottom->height();
for ( int y = 0; y < height; ++y ) {
for ( int x = 0; x < width; ++x ) {
qreal const c = qRed( topImage->pixel( x, y )) / 255.0;
QRgb const bottomPixel = bottom->pixel( x, y );
int const bottomRed = qRed( bottomPixel );
int const bottomGreen = qGreen( bottomPixel );
int const bottomBlue = qBlue( bottomPixel );
bottom->setPixel( x, y, qRgb(( int )( bottomRed + ( 255 - bottomRed ) * c ),
( int )( bottomGreen + ( 255 - bottomGreen ) * c ),
( int )( bottomBlue + ( 255 - bottomBlue ) * c )));
}
}
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:20,代码来源:BlendingAlgorithms.cpp
示例14: clearMask
void QImageWidget::setImage(const char *filename)
{
image.load(filename);
//#ifdef USE_MAEMO
// unlink(filename);
//#endif
clearMask();
if(w > 0 && h > 0 && ( w < image.width() || h < image.height() ) )
{
//printf("set1: setImage %s xy=%d,%d w=%d h=%d width=%d height=%d\n", filename,
//x(), y(), w, h,
// image.width(),image.height());
image = image.scaled(w, h, Qt::KeepAspectRatio);
}
else if(w > image.width() || h > image.height())
{
//printf("set2: setImage %s xy=%d,%d w=%d h=%d width=%d height=%d\n", filename,
//x(),y(),w, h,
// image.width(),image.height());
//qt3 image = image.smoothScale(w,h,Qt::KeepAspectRatio);
image.scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
if(strstr(filename,".bmp") != NULL || strstr(filename,".BMP") != NULL)
{ // it may be a bmp with transparent background
int n = image.numColors();
for(int icol=0; icol<n; icol++)
{
QRgb qcol = image.color(icol);
if(qRed(qcol) == 1 && qGreen(qcol) == 1 && qBlue(qcol) == 1)
{ // image has transparent background
//image.setAlphaBuffer(true);
image.setColor(icol,qRgba(1,1,1,0));
image.createAlphaMask();
}
}
}
perhapsSetMask();
original_image = image.copy();
repaint();
}
开发者ID:takiyuki,项目名称:pvb,代码行数:41,代码来源:QImageWidget.cpp
示例15: prepareSurface
static QImage prepareSurface(QImage img, int w, int h)
{
img = scaleImage(img, w, h);
// slightly larger, to accomodate for the reflection
int hs = h * 2;
int hofs = h / 3;
// offscreen buffer: black is sweet
QImage result(hs, w, QImage::Format_RGB32);
result.fill(0);
// transpose the image, this is to speed-up the rendering
// because we process one column at a time
// (and much better and faster to work row-wise, i.e in one scanline)
for(int x = 0; x < w; x++)
for(int y = 0; y < h; y++)
result.setPixel(hofs + y, x, img.pixel(x, y));
// create the reflection
int ht = hs - h - hofs;
int hte = ht;
for(int x = 0; x < w; x++)
for(int y = 0; y < ht; y++)
{
QRgb color = img.pixel(x, img.height()-y-1);
int a = qAlpha(color);
int r = qRed(color) * a / 256 * (hte - y) / hte * 3/5;
int g = qGreen(color) * a / 256 * (hte - y) / hte * 3/5;
int b = qBlue(color) * a / 256 * (hte - y) / hte * 3/5;
result.setPixel(h+hofs+y, x, qRgb(r, g, b));
}
#ifdef PICTUREFLOW_BILINEAR_FILTER
int hh = BILINEAR_STRETCH_VER*hs;
int ww = BILINEAR_STRETCH_HOR*w;
result = scaleImage(result, hh, ww);
#endif
return result;
}
开发者ID:ashang,项目名称:fqterm,代码行数:41,代码来源:pictureflow.cpp
示例16: PNM
PNM* ConversionGrayscale::transform()
{
// qDebug() << Q_FUNC_INFO << "Not implemented yet!";
int width = image->width();
int height = image->height();
PNM* newImage = new PNM(width, height, QImage::Format_Indexed8);
if (image->format() == QImage::Format_Mono)
{
for (int x = 0; x<width; x++)
for (int y = 0; y<height; y++)
{
QColor color = QColor::fromRgb(image->pixel(x, y)); // Getting the pixel(x,y) value
newImage->setPixel(x, y, color == Qt::white ? Qt::color1 : Qt::color0);
}
}
else // if (image->format() == QImage::Format_RGB32)
{
for (int x = 0; x<width; x++)
for (int y = 0; y<height; y++)
{
QRgb pixel = image->pixel(x, y); // Getting the pixel(x,y) value
int r = qRed(pixel); // Get the 0-255 value of the R channel
int g = qGreen(pixel); // Get the 0-255 value of the G channel
int b = qBlue(pixel); // Get the 0-255 value of the B channel
r = (int) floor(r*0.3);
g = (int) floor(g*0.6);
b = (int) floor(b*0.1);
//QColor newPixel = QColor(r, g, b);
newImage->setPixel(x, y, r + g + b);
}
}
return newImage;
}
开发者ID:GrzKon,项目名称:pto2014_-lazarskiGIMP,代码行数:41,代码来源:conversion_grayscale.cpp
示例17: QByteArray
QDBusArgument& operator<< (QDBusArgument &arg, const QImage &image)
{
if (image.isNull()) {
// Sometimes this gets called with a null QImage for no obvious reason.
arg.beginStructure();
arg << 0 << 0 << 0 << false << 0 << 0 << QByteArray();
arg.endStructure();
return arg;
}
QImage scaled = image.scaledToHeight(128, Qt::SmoothTransformation).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.byteCount());
arg.endStructure();
return arg;
}
开发者ID:polpo,项目名称:cantata-mac,代码行数:41,代码来源:notify.cpp
示例18: _negative
static void _negative(QString sourceFile, QString destFile)
{
QImage image(sourceFile);
int width = image.width();
int height = image.height();
QRgb color;
QRgb negative;
for(int i = 0; i < width; i++)
{
for(int j= 0; j < height; j++)
{
color = image.pixel(i, j);
negative = qRgba(255 - qRed(color),
255 - qGreen(color),
255 - qBlue(color),
qAlpha(color));
image.setPixel(i, j, negative);
}
}
image.save(destFile);
}
开发者ID:hywwqq,项目名称:Android,代码行数:21,代码来源:imageProcessor.cpp
示例19: imageData
bb::ImageData AbstractLoader::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:hamiller,项目名称:ImgurViewer,代码行数:21,代码来源:abstractloader.cpp
示例20: applyImageTransparancy
void applyImageTransparancy(QImage& img, const Numpy2DObj& data)
{
const int xw = min(data.dims[1], img.width());
const int yw = min(data.dims[0], img.height());
for(int y=0; y<yw; ++y)
{
// direction of images is different for qt and numpy image
QRgb* scanline = reinterpret_cast<QRgb*>(img.scanLine(yw-y-1));
for(int x=0; x<xw; ++x)
{
const double val = clipval(data(x, y), 0., 1.);
const QRgb col = *(scanline+x);
// update pixel alpha component
QRgb newcol = qRgba( qRed(col), qGreen(col), qBlue(col),
int(qAlpha(col)*val) );
*(scanline+x) = newcol;
}
}
}
开发者ID:amcdawes,项目名称:veusz,代码行数:21,代码来源:qtloops.cpp
注:本文中的qBlue函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论