当前位置: 首页>>代码示例>>C++>>正文


C++ qRed函数代码示例

本文整理汇总了C++中qRed函数的典型用法代码示例。如果您正苦于以下问题:C++ qRed函数的具体用法?C++ qRed怎么用?C++ qRed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了qRed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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

示例2: 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

示例3: fprintf

void SegmentListVIIRSDNB::printData(SegmentVIIRSDNB *segm, int linesfrom, int viewsfrom)
{
    int yaaa = 0;
    int xaaa = 0;
    fprintf(stderr, "projectionCoordX \n");
    for( int i = linesfrom + 0; i < linesfrom + 32; i++) //this->NbrOfLines - 1; i++)
    {
        for( int j = viewsfrom + 0; j < viewsfrom + 16; j++) //this->earth_views_per_scanline - 1 ; j++ )
        {

            fprintf(stderr, "%u, ", segm->getProjectionX(i,j));
        }

        fprintf(stderr, "\n");
    }


    fprintf(stderr, "projectionCoordY \n");
    for( int i = linesfrom + 0; i < linesfrom + 32; i++) //this->NbrOfLines - 1; i++)
    {
        for( int j = viewsfrom + 0; j < viewsfrom + 16; j++) //this->earth_views_per_scanline - 1 ; j++ )
        {

            fprintf(stderr, "%u, ", segm->getProjectionY(i,j));
        }

        fprintf(stderr, "\n");
    }

    fprintf(stderr, "projectionCoordValues \n");
    for( int i = linesfrom + 0; i < linesfrom + 32; i++) //this->NbrOfLines - 1; i++)
    {
        for( int j = viewsfrom + 0; j < viewsfrom + 16; j++) //this->earth_views_per_scanline - 1 ; j++ )
        {

            fprintf(stderr, "%u, ", qRed(segm->getProjectionValue(i,j)));
        }

        fprintf(stderr, "\n");
    }

}
开发者ID:Sammalou,项目名称:EUMETCastView,代码行数:42,代码来源:segmentlistviirsdnb.cpp

示例4: 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

示例5: 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

示例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: _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

示例8: 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

示例9: 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

示例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: 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

示例12: 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

示例13: result

//This function makes a pixmap which is based on icon, but has a number painted on it.
QPixmap BoxContainerItem::calcComplexPixmap(const QPixmap &icon, const QColor &fgColour, const QFont *font, const int count)
{
    QPixmap result(icon);
    QPixmap numberPixmap(icon.size());
    QImage iconImage(icon.convertToImage());
    QImage numberImage;
    QRgb *rgbline;
    QPainter p;

    //Make a transparent number; first make a white number on a black background.
    //This pixmap also is the base alpha-channel, the foreground colour is added later.
    numberPixmap.fill(Qt::black);
    p.begin(&numberPixmap, false);
    p.setPen(Qt::white);
    if(font)
        p.setFont(*font);
    p.drawText(icon.rect(), Qt::AlignCenter, QString::number(count));
    p.end();

    //Convert to image and add the alpha channel.
    numberImage = numberPixmap.convertToImage();
    if(numberImage.depth() != 32)   //Make sure depth is 32 (and thus can have an alpha channel)
        numberImage = numberImage.convertDepth(32);
    numberImage.setAlphaBuffer(true);   //Enable alpha channel
    for(int xx = 0; xx < numberImage.height(); ++xx)
    {
        rgbline = (QRgb *)numberImage.scanLine(xx);

        for(int yy = 0; yy < numberImage.width(); ++yy)
        {
            //Set colour and alpha channel
            rgbline[ yy ] = qRgba(fgColour.red(), fgColour.green(), fgColour.blue(), qRed(rgbline[ yy ]));
        }
    }

    //Merge icon and number and convert to result.
    KIconEffect::overlay(iconImage, numberImage);
    result.convertFromImage(iconImage);

    return result;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:42,代码来源:boxcontaineritem.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: 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


注:本文中的qRed函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。