• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ qRgba函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: painter

void ImageEditor::paintEvent(QPaintEvent *event)
{
	if (!_image_loaded)
		return;
	
 	QPainter painter(this);
 	QPixmap pixmaptoshow;
	if(!_flag_mask)
 		pixmaptoshow=QPixmap::fromImage(_image_layer.scaled(this->size(),Qt::KeepAspectRatio));
	else
		pixmaptoshow=QPixmap::fromImage(_image_mask.scaled(this->size(),Qt::KeepAspectRatio));
	
 	painter.drawPixmap(0,0, pixmaptoshow);
 	_real_size=pixmaptoshow.size();
 
	
 	//draw point
	if(_scissor)
	{
		QBrush blackBrush(qRgba(0, 0, 0, 255));
		painter.setBrush(blackBrush);
		for (int i=0;i<_contourList.size();i++)
			for(int j=0;j<_contourList[i].size();j+=3)
		{
			QPoint ConP;						
			ConP=QPoint(_contourList[i][j].x()*_real_size.width(),_contourList[i][j].y()*_real_size.height());
			painter.drawEllipse(ConP,1,1);
		}
		for(int i=0;i<_segList.size();i+=3)
		{
			QPoint ConP;						
			ConP=QPoint(_segList[i].x()*_real_size.width(),_segList[i].y()*_real_size.height());
			painter.drawEllipse(ConP,1,1);
		}

		QBrush redBrush(qRgba(255, 0, 0, 255));
		painter.setBrush(redBrush);

		for(int i=0;i<_fixedSeedList.size();i++)
		{
			
			QPoint ConP;						
			ConP=QPoint(_fixedSeedList[i].x()*_real_size.width(),_fixedSeedList[i].y()*_real_size.height());
		
			painter.drawEllipse(ConP,3,3);
		}

	}
	else
	{
		if(parameters)
		{
			for(int i=0;i<parameters->ui_points.size();i++)
			{
				if(i==parameters->ActIndex)
				{
					QBrush redBrush(qRgba(255, 0, 0, 255));
					painter.setBrush(redBrush);
				}
				else
				{
					QBrush yellowBrush(qRgba(255, 255, 0, 255));
					painter.setBrush(yellowBrush);
				}

				QPoint ConP;
				switch(_name)
				{
				case 'L':
				case 'l':				
					ConP=QPoint(parameters->ui_points[i].lp.x*_real_size.width(),parameters->ui_points[i].lp.y*_real_size.height());
					break;

				case 'R':
				case 'r':
					ConP=QPoint(parameters->ui_points[i].rp.x*_real_size.width(),parameters->ui_points[i].rp.y*_real_size.height());

				}
				painter.drawEllipse(ConP,3,3);
			}

		}
	}	
	
}
开发者ID:etrigger,项目名称:Image-Morphing,代码行数:85,代码来源:ImageEditor.cpp


示例2: QCOMPARE

// Testing get/set functions
void tst_QColor::getSetCheck()
{
    QColor obj1;
    // int QColor::alpha()
    // void QColor::setAlpha(int)
    obj1.setAlpha(0);
    QCOMPARE(obj1.alpha(), 0);
    obj1.setAlpha(-1);
    QCOMPARE(obj1.alpha(), 0); // range<0, 255>
    obj1.setAlpha(INT_MIN);
    QCOMPARE(obj1.alpha(), 0); // range<0, 255>
    obj1.setAlpha(255);
    QCOMPARE(obj1.alpha(), 255); // range<0, 255>
    obj1.setAlpha(INT_MAX);
    QCOMPARE(obj1.alpha(), 255); // range<0, 255>

    // qreal QColor::alphaF()
    // void QColor::setAlphaF(qreal)
    obj1.setAlphaF(0.0);
    QCOMPARE(obj1.alphaF(), qreal(0.0)); // range<0.0, 1.0>
    obj1.setAlphaF(-0.2);
    QCOMPARE(obj1.alphaF(), qreal(0.0)); // range<0.0, 1.0>
    obj1.setAlphaF(1.0);
    QCOMPARE(obj1.alphaF(), qreal(1.0)); // range<0.0, 1.0>
    obj1.setAlphaF(1.1);
    QCOMPARE(obj1.alphaF(), qreal(1.0)); // range<0.0, 1.0>

    // int QColor::red()
    // void QColor::setRed(int)
    obj1.setRed(0);
    QCOMPARE(obj1.red(), 0);
    obj1.setRed(-1);
    QCOMPARE(obj1.red(), 0); // range<0, 255>
    obj1.setRed(INT_MIN);
    QCOMPARE(obj1.red(), 0); // range<0, 255>
    obj1.setRed(255);
    QCOMPARE(obj1.red(), 255); // range<0, 255>
    obj1.setRed(INT_MAX);
    QCOMPARE(obj1.red(), 255); // range<0, 255>

    // int QColor::green()
    // void QColor::setGreen(int)
    obj1.setGreen(0);
    QCOMPARE(obj1.green(), 0);
    obj1.setGreen(-1);
    QCOMPARE(obj1.green(), 0); // range<0, 255>
    obj1.setGreen(INT_MIN);
    QCOMPARE(obj1.green(), 0); // range<0, 255>
    obj1.setGreen(255);
    QCOMPARE(obj1.green(), 255); // range<0, 255>
    obj1.setGreen(INT_MAX);
    QCOMPARE(obj1.green(), 255); // range<0, 255>

    // int QColor::blue()
    // void QColor::setBlue(int)
    obj1.setBlue(0);
    QCOMPARE(obj1.blue(), 0);
    obj1.setBlue(-1);
    QCOMPARE(obj1.blue(), 0); // range<0, 255>
    obj1.setBlue(INT_MIN);
    QCOMPARE(obj1.blue(), 0); // range<0, 255>
    obj1.setBlue(255);
    QCOMPARE(obj1.blue(), 255); // range<0, 255>
    obj1.setBlue(INT_MAX);
    QCOMPARE(obj1.blue(), 255); // range<0, 255>

    // qreal QColor::redF()
    // void QColor::setRedF(qreal)
    obj1.setRedF(0.0);
    QCOMPARE(obj1.redF(), qreal(0.0));
    obj1.setRedF(-0.2);
    QCOMPARE(obj1.redF(), qreal(0.0)); // range<0.0, 1.0
    obj1.setRedF(1.1);
    QCOMPARE(obj1.redF(), qreal(1.0)); // range<0.0, 1.0

    // qreal QColor::greenF()
    // void QColor::setGreenF(qreal)
    obj1.setGreenF(0.0);
    QCOMPARE(obj1.greenF(), qreal(0.0));
    obj1.setGreenF(-0.2);
    QCOMPARE(obj1.greenF(), qreal(0.0)); // range<0.0, 1.0
    obj1.setGreenF(1.1);
    QCOMPARE(obj1.greenF(), qreal(1.0)); // range<0.0, 1.0

    // qreal QColor::blueF()
    // void QColor::setBlueF(qreal)
    obj1.setBlueF(0.0);
    QCOMPARE(obj1.blueF(), qreal(0.0));
    obj1.setBlueF(-0.2);
    QCOMPARE(obj1.blueF(), qreal(0.0)); // range<0.0, 1.0
    obj1.setBlueF(1.1);
    QCOMPARE(obj1.blueF(), qreal(1.0)); // range<0.0, 1.0

    // QRgb QColor::rgba()
    // void QColor::setRgba(QRgb)
    QRgb var9(qRgba(10, 20, 30, 40));
    obj1.setRgba(var9);
    QCOMPARE(obj1.rgba(), var9);
    obj1.setRgba(QRgb(0));
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:android-qt,代码行数:101,代码来源:tst_qcolor.cpp


示例3: GDALAllRegister


//.........这里部分代码省略.........
	//double noDataDouble;

	//set up the three class breaks for pseudocolour mapping
	double myBreakSizeDouble = myAdjustedRasterBandStats->rangeDouble / 3;
	double myClassBreakMin1 = myAdjustedRasterBandStats->minValDouble;
	double myClassBreakMax1 = myAdjustedRasterBandStats->minValDouble + myBreakSizeDouble;
	double myClassBreakMin2 = myClassBreakMax1;
	double myClassBreakMax2 = myClassBreakMin2 + myBreakSizeDouble;
	double myClassBreakMin3 = myClassBreakMax2;
	double myClassBreakMax3 = myAdjustedRasterBandStats->maxValDouble;

	printf ("ClassBreak size : %f \n",myBreakSizeDouble);
	printf ("ClassBreak 1 : %f - %f\n",myClassBreakMin1,myClassBreakMax1);
	printf ("ClassBreak 2 : %f - %f\n",myClassBreakMin2,myClassBreakMax2);
	printf ("ClassBreak 3 : %f - %f\n",myClassBreakMin3,myClassBreakMax3);

	int myRedInt=0;
	int myGreenInt=0;
	int myBlueInt=0;
	for (int myColumnInt = 0; myColumnInt < myYDimInt; myColumnInt++)
	{
		for (int myRowInt =0; myRowInt < myXDimInt; myRowInt++)
		{
			int myInt=myGdalScanData[myColumnInt*myXDimInt + myRowInt];
			//dont draw this point if it is no data !
			//double check that myInt >= min and <= max
			//this is relevant if we are plotting within stddevs
			if ((myInt < myAdjustedRasterBandStats->minValDouble ) && (myInt != myAdjustedRasterBandStats->noDataDouble))
			{
				myInt = static_cast<int>(myAdjustedRasterBandStats->minValDouble);
			}
			if ((myInt > myAdjustedRasterBandStats->maxValDouble)   && (myInt != myAdjustedRasterBandStats->noDataDouble))
			{
				myInt = static_cast<int>(myAdjustedRasterBandStats->maxValDouble);
			}
			if (myInt==myAdjustedRasterBandStats->noDataDouble)
			{
				//hardcoding to white for now
				myRedInt = 255;
				myBlueInt = 255;
				myGreenInt =255;
			}
			else if(!invertHistogramFlag)
			{
				//check if we are in the first class break
				if ((myInt >= myClassBreakMin1) &&  (myInt < myClassBreakMax1) )
				{
					myRedInt = 0;
					myBlueInt = 255;
					myGreenInt = static_cast<int>(((255/myAdjustedRasterBandStats->rangeDouble) * (myInt-myClassBreakMin1))*3);
				}
				//check if we are in the second class break
				else if ((myInt >= myClassBreakMin2) &&  (myInt < myClassBreakMax2) )
				{
					myRedInt = static_cast<int>(((255/myAdjustedRasterBandStats->rangeDouble) * ((myInt-myClassBreakMin2)/1))*3);
					myBlueInt = static_cast<int>(255-(((255/myAdjustedRasterBandStats->rangeDouble) * ((myInt-myClassBreakMin2)/1))*3));
					myGreenInt = 255;
				}
				//otherwise we must be in the third classbreak
				else
				{
					myRedInt = 255;
					myBlueInt = 0;
					myGreenInt = static_cast<int>(255-(((255/myAdjustedRasterBandStats->rangeDouble) * ((myInt-myClassBreakMin3)/1)*3)));
				}
			}
			else  //invert histogram toggle is on
			{
				//check if we are in the first class break
				if ((myInt >= myClassBreakMin1) &&  (myInt < myClassBreakMax1) )
				{
					myRedInt = 255;
					myBlueInt = 0;
					myGreenInt = static_cast<int>(((255/myAdjustedRasterBandStats->rangeDouble) * ((myInt-myClassBreakMin1)/1)*3));
				}
				//check if we are in the second class break
				else if ((myInt >= myClassBreakMin2) &&  (myInt < myClassBreakMax2) )
				{
					myRedInt = static_cast<int>(255-(((255/myAdjustedRasterBandStats->rangeDouble) * ((myInt-myClassBreakMin2)/1))*3));
					myBlueInt = static_cast<int>(((255/myAdjustedRasterBandStats->rangeDouble) * ((myInt-myClassBreakMin2)/1))*3);
					myGreenInt = 255;
				}
				//otherwise we must be in the third classbreak
				else
				{
					myRedInt = 0;
					myBlueInt = 255;
					myGreenInt = static_cast<int>(255-(((255/myAdjustedRasterBandStats->rangeDouble) * (myInt-myClassBreakMin3))*3));
				}
			}
			myQImage.setPixel( myRowInt, myColumnInt, qRgba( myRedInt, myGreenInt, myBlueInt, transparencyLevelInt ));
		}
	}
	//draw with the experimental transaparency support
	CPLFree(myGdalScanData);
	GDALClose(gdalDataset);
	printf("Saving image...\n");
	myQImage.save(theOutputFileString,"PNG");
	return ;
}
开发者ID:alexckp,项目名称:qgis,代码行数:101,代码来源:imagewriter.cpp


示例4: htmlUnitsToMM

double QgsComposerHtml::findNearbyPageBreak( double yPos )
{
  if ( !mWebPage || !mRenderedPage || !mUseSmartBreaks )
  {
    return yPos;
  }

  //convert yPos to pixels
  int idealPos = yPos * htmlUnitsToMM();

  //if ideal break pos is past end of page, there's nothing we need to do
  if ( idealPos >= mRenderedPage->height() )
  {
    return yPos;
  }

  int maxSearchDistance = mMaxBreakDistance * htmlUnitsToMM();

  //loop through all lines just before ideal break location, up to max distance
  //of maxSearchDistance
  int changes = 0;
  QRgb currentColor;
  bool currentPixelTransparent = false;
  bool previousPixelTransparent = false;
  QRgb pixelColor;
  QList< QPair<int, int> > candidates;
  int minRow = qMax( idealPos - maxSearchDistance, 0 );
  for ( int candidateRow = idealPos; candidateRow >= minRow; --candidateRow )
  {
    changes = 0;
    currentColor = qRgba( 0, 0, 0, 0 );
    //check all pixels in this line
    for ( int col = 0; col < mRenderedPage->width(); ++col )
    {
      //count how many times the pixels change color in this row
      //eventually, we select a row to break at with the minimum number of color changes
      //since this is likely a line break, or gap between table cells, etc
      //but very unlikely to be midway through a text line or picture
      pixelColor = mRenderedPage->pixel( col, candidateRow );
      currentPixelTransparent = qAlpha( pixelColor ) == 0;
      if ( pixelColor != currentColor && !( currentPixelTransparent && previousPixelTransparent ) )
      {
        //color has changed
        currentColor = pixelColor;
        changes++;
      }
      previousPixelTransparent = currentPixelTransparent;
    }
    candidates.append( qMakePair( candidateRow, changes ) );
  }

  //sort candidate rows by number of changes ascending, row number descending
  qSort( candidates.begin(), candidates.end(), candidateSort );
  //first candidate is now the largest row with smallest number of changes

  //ok, now take the mid point of the best candidate position
  //we do this so that the spacing between text lines is likely to be split in half
  //otherwise the html will be broken immediately above a line of text, which
  //looks a little messy
  int maxCandidateRow = candidates[0].first;
  int minCandidateRow = maxCandidateRow + 1;
  int minCandidateChanges = candidates[0].second;

  QList< QPair<int, int> >::iterator it;
  for ( it = candidates.begin(); it != candidates.end(); ++it )
  {
    if (( *it ).second != minCandidateChanges || ( *it ).first != minCandidateRow - 1 )
    {
      //no longer in a consecutive block of rows of minimum pixel color changes
      //so return the row mid-way through the block
      //first converting back to mm
      return ( minCandidateRow + ( maxCandidateRow - minCandidateRow ) / 2 ) / htmlUnitsToMM();
    }
    minCandidateRow = ( *it ).first;
  }

  //above loop didn't work for some reason
  //return first candidate converted to mm
  return candidates[0].first / htmlUnitsToMM();
}
开发者ID:AM7000000,项目名称:QGIS,代码行数:80,代码来源:qgscomposerhtml.cpp


示例5: qRgba

 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "qgsrasterrenderer.h"
#include "qgsrastertransparency.h"

#include <QCoreApplication>
#include <QDomDocument>
#include <QDomElement>
#include <QImage>
#include <QPainter>

// See #9101 before any change of NODATA_COLOR!
const QRgb QgsRasterRenderer::NODATA_COLOR = qRgba( 0, 0, 0, 0 );

QgsRasterRenderer::QgsRasterRenderer( QgsRasterInterface* input, const QString& type )
    : QgsRasterInterface( input )
    , mType( type ), mOpacity( 1.0 ), mRasterTransparency( nullptr )
    , mAlphaBand( -1 ) //, mInvertColor( false )
{
}

QgsRasterRenderer::~QgsRasterRenderer()
{
    delete mRasterTransparency;
}

int QgsRasterRenderer::bandCount() const
{
开发者ID:Zakui,项目名称:QGIS,代码行数:31,代码来源:qgsrasterrenderer.cpp


示例6: sizeof


//.........这里部分代码省略.........
            for (int y = 0; y < h; ++y) {
                if (*p1 != *p2) {
                    done = true;
                    break;
                }
                p1 += frameStride;
                p2 += prevStride;
            }
        }
        ++maxx;

        // Find top edge of change
        done = false;
        for (miny = 0; miny < h && !done; ++miny) {
            const quint32 *p1 = framePtr + miny * frameStride;
            const quint32 *p2 = prevPtr + miny * prevStride + offset.x();
            for (int x = 0; x < w; ++x) {
                if (*p1 != *p2) {
                    done = true;
                    break;
                }
                ++p1;
                ++p2;
            }
        }
        --miny;

        // Find right edge of change
        done = false;
        for (maxy = h-1; maxy >= 0 && !done; --maxy) {
            const quint32 *p1 = framePtr + maxy * frameStride;
            const quint32 *p2 = prevPtr + maxy * prevStride + offset.x();
            for (int x = 0; x < w; ++x) {
                if (*p1 != *p2) {
                    done = true;
                    break;
                }
                ++p1;
                ++p2;
            }
        }
        ++maxy;

        if (minx > maxx)
            minx = maxx = 0;
        if (miny > maxy)
            miny = maxy = 0;

        if (alignx > 1) {
            minx -= minx % alignx;
            maxx = maxx - maxx % alignx + alignx - 1;
        }

        int dw = maxx - minx + 1;
        int dh = maxy - miny + 1;

        QImage diff(dw, dh, QImage::Format_ARGB32);

        int x, y;
        for (y = 0; y < dh; ++y) {
            QRgb* li = (QRgb*)frame.scanLine(y+miny)+minx;
            QRgb* lp = (QRgb*)prev.scanLine(y+miny+offset.y())+minx+offset.x();
            QRgb* ld = (QRgb*)diff.scanLine(y);
            if (alignx) {
                for (x = 0; x < dw; x += alignx) {
                    int i;
                    for (i = 0; i < alignx; ++i) {
                        if (li[x+i] != lp[x+i])
                            break;
                    }
                    if (i == alignx) {
                        // All the same
                        for (i = 0; i < alignx; ++i)
                            ld[x+i] = qRgba(0,0,0,0);
                    } else {
                        // Some different
                        for (i = 0; i < alignx; ++i)
                            ld[x+i] = 0xff000000 | li[x+i];
                    }
                }
            } else {
                for (x = 0; x < dw; ++x) {
                    if (li[x] != lp[x])
                        ld[x] = 0xff000000 | li[x];
                    else
                        ld[x] = qRgba(0,0,0,0);
                }
            }
        }

        d->composeImage(diff, QPoint(minx, miny) + offset);
    }
    if (prev.isNull() || (prev.size() == frame.size() && offset == QPoint(0,0))) {
        prev = frame;
    } else {
        QPainter p(&prev);
        p.drawImage(offset.x(), offset.y(), frame, 0, 0,
                    frame.width(), frame.height());
    }
}
开发者ID:stephaneAG,项目名称:PengPod700,代码行数:101,代码来源:qanimationwriter.cpp


示例7: qRgba

#include "ColorTabBar.h"

#include <QPainter>
#include <QtEvents>


static const QRgb g_TabDefaultColor[5] =
{
    qRgba(237, 28, 36, 200),
    qRgba(255, 127, 39, 200),
    qRgba(34, 177, 36, 200),
    qRgba(0, 162, 232, 200),
    qRgba(63, 72, 204, 200)
};

QColorTabBar::QColorTabBar(QWidget *parent) :
    QTabBar(parent)
{
    m_bNotify = false;
    m_nNotifyIndex = -1;
    m_nActiveIndex = -1;
    m_nHoverIndex = -1;
    m_nBlinkCount = 0;

    m_bHorz = true;

    m_nBlinkIndex = -1;
    m_bBlinkFalg = false;
    m_nTimerBlink = 0;

    setMouseTracking( true );
开发者ID:habilience,项目名称:habilience-t3ksensor-tools,代码行数:31,代码来源:ColorTabBar.cpp


示例8: outputBlock

QgsRasterBlock *QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle  const &extent, int width, int height, QgsRasterBlockFeedback *feedback )
{
  std::unique_ptr< QgsRasterBlock > outputBlock( new QgsRasterBlock() );
  if ( !mInput || mClassData.isEmpty() )
  {
    return outputBlock.release();
  }

  std::shared_ptr< QgsRasterBlock > inputBlock( mInput->block( bandNo, extent, width, height, feedback ) );

  if ( !inputBlock || inputBlock->isEmpty() )
  {
    QgsDebugMsg( QStringLiteral( "No raster data!" ) );
    return outputBlock.release();
  }

  double currentOpacity = mOpacity;

  //rendering is faster without considering user-defined transparency
  bool hasTransparency = usesTransparency();

  std::shared_ptr< QgsRasterBlock > alphaBlock;

  if ( mAlphaBand > 0 && mAlphaBand != mBand )
  {
    alphaBlock.reset( mInput->block( mAlphaBand, extent, width, height, feedback ) );
    if ( !alphaBlock || alphaBlock->isEmpty() )
    {
      return outputBlock.release();
    }
  }
  else if ( mAlphaBand == mBand )
  {
    alphaBlock = inputBlock;
  }

  if ( !outputBlock->reset( Qgis::ARGB32_Premultiplied, width, height ) )
  {
    return outputBlock.release();
  }

  QRgb myDefaultColor = NODATA_COLOR;

  //use direct data access instead of QgsRasterBlock::setValue
  //because of performance
  unsigned int *outputData = ( unsigned int * )( outputBlock->bits() );

  qgssize rasterSize = ( qgssize )width * height;
  bool isNoData = false;
  for ( qgssize i = 0; i < rasterSize; ++i )
  {
    const double value = inputBlock->valueAndNoData( i, isNoData );
    if ( isNoData )
    {
      outputData[i] = myDefaultColor;
      continue;
    }
    int val = static_cast< int >( value );
    if ( !mColors.contains( val ) )
    {
      outputData[i] = myDefaultColor;
      continue;
    }

    if ( !hasTransparency )
    {
      outputData[i] = mColors.value( val );
    }
    else
    {
      currentOpacity = mOpacity;
      if ( mRasterTransparency )
      {
        currentOpacity = mRasterTransparency->alphaValue( val, mOpacity * 255 ) / 255.0;
      }
      if ( mAlphaBand > 0 )
      {
        currentOpacity *= alphaBlock->value( i ) / 255.0;
      }

      QRgb c = mColors.value( val );
      outputData[i] = qRgba( currentOpacity * qRed( c ), currentOpacity * qGreen( c ), currentOpacity * qBlue( c ), currentOpacity * qAlpha( c ) );
    }
  }

  return outputBlock.release();
}
开发者ID:mbernasocchi,项目名称:QGIS,代码行数:87,代码来源:qgspalettedrasterrenderer.cpp


示例9: QImage

void knob::drawKnob( QPainter * _p )
{
	if( updateAngle() == false && !m_cache.isNull() )
	{
		_p->drawImage( 0, 0, m_cache );
		return;
	}

	m_cache = QImage( size(), QImage::Format_ARGB32 );
	m_cache.fill( qRgba( 0, 0, 0, 0 ) );

	QPainter p( &m_cache );

	QPoint mid;

	if( m_knobNum == knobStyled )
	{
		p.setRenderHint( QPainter::Antialiasing );

		// Perhaps this can move to setOuterRadius()
		if( m_outerColor )
		{
			QRadialGradient gradient( centerPoint(), outerRadius() );
			gradient.setColorAt(0.4, _p->pen().brush().color() );
			gradient.setColorAt(1, *m_outerColor );

			p.setPen( QPen( gradient, lineWidth(),
						Qt::SolidLine, Qt::RoundCap ) );
		}
		else {
			QPen pen = p.pen();
			pen.setWidth( (int) lineWidth() );
			pen.setCapStyle( Qt::RoundCap );

			p.setPen( pen );
		}

		p.drawLine( calculateLine( centerPoint(), outerRadius(),
							innerRadius() ) );
		p.end();
		_p->drawImage( 0, 0, m_cache );
		return;
	}


	// Old-skool knobs
	const float radius = m_knobPixmap->width() / 2.0f - 1;
	mid = QPoint( width() / 2, m_knobPixmap->height() / 2 );

	p.drawPixmap( static_cast<int>(
				width() / 2 - m_knobPixmap->width() / 2 ), 0,
				*m_knobPixmap );

	p.setRenderHint( QPainter::Antialiasing );

	const int centerAngle = angleFromValue( model()->centerValue(), model()->minValue(), model()->maxValue(), m_totalAngle );

	const int arcLineWidth = 2;
	const int arcRectSize = m_knobPixmap->width() - arcLineWidth;

	QColor col;
	if( m_knobNum == knobVintage_32 )
	{	col = QApplication::palette().color( QPalette::Active, QPalette::Shadow ); }
	else
	{	col = QApplication::palette().color( QPalette::Active, QPalette::WindowText ); }
	col.setAlpha( 70 );

	p.setPen( QPen( col, 2 ) );
	p.drawArc( mid.x() - arcRectSize/2, 1, arcRectSize, arcRectSize, 315*16, 16*m_totalAngle );

	switch( m_knobNum )
	{
		case knobSmall_17:
		{
			p.setPen( QPen( QApplication::palette().color( QPalette::Active,
							QPalette::WindowText ), 2 ) );
			p.drawLine( calculateLine( mid, radius-2 ) );
			break;
		}
		case knobBright_26:
		{
			p.setPen( QPen( QApplication::palette().color( QPalette::Active, QPalette::WindowText ), 2 ) );
			p.drawLine( calculateLine( mid, radius-5 ) );
			break;
		}
		case knobDark_28:
		{
			p.setPen( QPen( QApplication::palette().color( QPalette::Active, QPalette::WindowText ), 2 ) );
			const float rb = qMax<float>( ( radius - 10 ) / 3.0,
									0.0 );
			const float re = qMax<float>( ( radius - 4 ), 0.0 );
			QLineF ln = calculateLine( mid, re, rb );
			ln.translate( 1, 1 );
			p.drawLine( ln );
			break;
		}
		case knobGreen_17:
		{
			p.setPen( QPen( QApplication::palette().color( QPalette::Active,
							QPalette::BrightText), 2 ) );
//.........这里部分代码省略.........
开发者ID:Pavleen30,项目名称:SOEN6471,代码行数:101,代码来源:knob.cpp


示例10: result

QImage SpecularmapGenerator::calculateSpecmap(QImage input, double scale, double contrast) {
    QImage result(input.width(), input.height(), QImage::Format_ARGB32);

    //generate contrast lookup table
    unsigned short contrastLookup[256];
    double newValue = 0;

    for(int i = 0; i < 256; i++) {
        newValue = (double)i;
        newValue /= 255.0;
        newValue -= 0.5;
        newValue *= contrast;
        newValue += 0.5;
        newValue *= 255;

        if(newValue < 0)
            newValue = 0;
        if(newValue > 255)
            newValue = 255;

        contrastLookup[i] = (unsigned short)newValue;
    }

    #pragma omp parallel for  // OpenMP
    //for every row of the image
    for(int y = 0; y < result.height(); y++) {
        QRgb *scanline = (QRgb*) result.scanLine(y);

        //for every column of the image
        for(int x = 0; x < result.width(); x++) {
            double r, g, b, a;
            double intensity = 0.0;

            QColor pxColor = QColor(input.pixel(x, y));

            r = pxColor.redF() * redMultiplier;
            g = pxColor.greenF() * greenMultiplier;
            b = pxColor.blueF() * blueMultiplier;
            a = pxColor.alphaF() * alphaMultiplier;

            if(mode == IntensityMap::AVERAGE) {
                //take the average out of all selected channels
                double multiplierSum = (redMultiplier + greenMultiplier + blueMultiplier + alphaMultiplier);

                if(multiplierSum == 0.0)
                    multiplierSum = 1.0;

                intensity = (r + g + b + a) / multiplierSum;
            }
            else if(mode == IntensityMap::MAX) {
                //take the maximum out of all selected channels
                double tempMaxRG = std::max(r, g);
                double tempMaxBA = std::max(b, a);
                intensity = std::max(tempMaxRG, tempMaxBA);
            }

            //apply scale (brightness)
            intensity *= scale;

            if(intensity > 1.0)
                intensity = 1.0;

            //convert intensity to the 0-255 range
            int c = (int)(255.0 * intensity);

            //apply contrast
            c = (int)contrastLookup[c];

            //write color into image pixel
            scanline[x] = qRgba(c, c, c, pxColor.alpha());
        }
    }

    return result;
}
开发者ID:voyager25,项目名称:NormalmapGenerator,代码行数:75,代码来源:specularmapgenerator.cpp


示例11: onNewSketch

void MainWindow::onNewSketch() {
	for (int i = 0; i < parametriclsystem::NUM_LAYERS; ++i) {
		glWidget->sketch[i].fill(qRgba(255, 255, 255, 0));
	}
	glWidget->update();
}
开发者ID:gnishida,项目名称:SketchTree,代码行数:6,代码来源:MainWindow.cpp


示例12: overlapOpenGL

void TrackerArenaForm::overlapOpenGL(QPainter& painter)
{
	if (model_->readyFrameInd_ < 0)
		return;
	
	// draw track adornments
	const float r = 5;

	std::vector<TrackUIItem*> trackList;
	model_->getTrackList(trackList);
	for (auto pTrack : trackList)
	{
		BlobRegistrationRecord blobInfo = pTrack->LastPosition;
		auto pos = blobInfo.ObsPosPixExactOrApprox;

		if (!pTrack->IsLive)
		{
			painter.setPen(QColor::fromRgb(0, 0, 0));
			painter.drawEllipse(pos.x - r, pos.y - r, 2 * r, 2 * r);
		}
		else
		{
			painter.setPen(QColor::fromRgb(0, 0, 0));
			painter.drawText(pos.x, pos.y, QString::number(pTrack->TrackId));

			QColor penColor;
			if (blobInfo.HasObservation)
				penColor = QColor::fromRgba(qRgba(0, 255, 0, 255));
			else
				penColor = QColor::fromRgb(qRgba(0, 0, 255, 255));
			
			painter.setPen(penColor);

			painter.drawEllipse(pos.x - r, pos.y - r, 2 * r, 2 * r);
		}

		// attempt to estimate most probable hypothesis for current track
		//int latestFrameInd = pTrack->latesetFrameIndExcl();

		//TrackChangePerFrame change;
		//if (model_->getLatestTrack(latestFrameInd, pTrack->TrackId, change))
		//{
		//	auto pos = change.ObservationPosPixExactOrApprox;

		//	painter.setPen(QColor::fromRgb(0, 0, 0));
		//	painter.drawText(pos.x, pos.y, QString::number(pTrack->TrackId));

		//	QColor penColor;
		//	if (change.UpdateType == TrackChangeUpdateType::ObservationUpdate || change.UpdateType == TrackChangeUpdateType::New)
		//		penColor = QColor::fromRgb(0, 255, 0);
		//	else if (change.UpdateType == TrackChangeUpdateType::NoObservation)
		//		penColor = QColor::fromRgb(255, 255, 0);
		//	else if (change.UpdateType == TrackChangeUpdateType::Pruned)
		//		penColor = QColor::fromRgb(255, 0, 0);
		//	painter.setPen(penColor);
		//	
		//	painter.drawEllipse(pos.x - r, pos.y - r, 2 * r, 2 * r);
		//}
		//else
		//{
		//	qDebug() << "Can't get latest track hypothesis TrackId=" << pTrack->TrackId;
		//	CV_Assert(false);
		//}
	}
}
开发者ID:tivadj,项目名称:PoolWatch,代码行数:65,代码来源:TrackerArenaForm.cpp


示例13: grayRgb

inline QRgb grayRgb(QRgb rgb) {
	int gray = (qRed(rgb) + qGreen(rgb) + qBlue(rgb)) / 3;
	return qRgba(gray, gray, gray, qAlpha(rgb) / 2);
}
开发者ID:TodorGrin,项目名称:boox-opensource,代码行数:4,代码来源:ZLQtApplicationWindow.cpp


示例14: extend


//.........这里部分代码省略.........
            int g2 = qGreen(p2);
            int b2 = qBlue(p2);
            int a2 = qAlpha(p2);
            int r, g, b, a;
            r=0; g=0; b=0; a=0;
            for(int u=0; u<1; u++) {
            	for(int v=0; v<1;v++) {
            	  if (boundaries.contains(  bitmapImage->boundaries.topLeft() + QPoint(x+u,y+v) )) {
            			QRgb p1  = image->pixel(offset.x()+x+u,offset.y()+y+v);
            			int r1 = qRed(p1);
            			int g1 = qGreen(p1);
            			int b1 = qBlue(p1);
            			int a1 = qAlpha(p1);
            			r = r + r1;
            			g = g + g1;
            			b = b + b1;
            			a = a + a1;
            		}
            	}
            }
            r = r/1;
            g = g/1;
            b = b/1;
            a = a/1;
            //r = 255;
            //g = 0;
            //b = 0;
            a = 255;
            		QRgb p1  = image->pixel(offset.x()+x,offset.y()+y);
            		int r1 = qRed(p1);
            		int g1 = qGreen(p1);
            		int b1 = qBlue(p1);
            		int a1 = qAlpha(p1);
            r = (r1*(255-r2) + r2*r)/255;
            g = (g1*(255-g2) + g2*g)/255;
            b = (b1*(255-b2) + b2*b)/255;
            a = (a1*(255-a2) + a2*a)/255;*/
            QRgb p1  = image->pixel(offset.x()+x,offset.y()+y);
            QRgb p2 = image2->pixel(x,y);

            int a1 = qAlpha(p1);
            int a2 = qAlpha(p2);
            int r1 = qRed(p1);
            int r2 = qRed(p2); // remember that the bitmap format is RGB32 Premultiplied
            int g1 = qGreen(p1);
            int g2 = qGreen(p2);
            int b1 = qBlue(p1);
            int b2 = qBlue(p2);

            /*qreal a1 = qAlpha(p1); qreal a2 = qAlpha(p2);
            qreal r1 = qRed(p1);   qreal r2 = qRed(p2); // remember that the bitmap format is RGB32 Premultiplied
            qreal g1 = qGreen(p1); qreal g2 = qGreen(p2);
            qreal b1 = qBlue(p1);  qreal b2 = qBlue(p2);*/

            // unite
            int a = qMax(a1, a2);
            int r = qMax(r1, r2);
            int g = qMax(g1, g2);
            int b = qMax(b1, b2);

            // blend
            /*int a = a2 + a1*(255-a2)/255;
            int r = r2 + r1*(255-a2)/255;
            int g = g2 + g1*(255-a2)/255;
            int b = b2 + b1*(255-a2)/255;*/

            // source
            /*int a = a2;
            int r = r2;
            int g = g2;
            int b = b2;*/

            /*int a = qRound(a1+a2);
            int r = qRound((a1+a2)*((r1+0.)/a1+(r2+0.)/a2)/1);
            int g = qRound((a1+a2)*((g1+0.)/a1+(g2+0.)/a2)/1);
            int b = qRound((a1+a2)*((b1+0.)/a1+(b2+0.)/a2)/1);*/

            // add
            /*int a = qMin(255, qRound(1.0*(a1+a2)));
            int r = qMin(255, qRound(0.5*(r1+r2)));
            int g = qMin(255, qRound(0.5*(g1+g2)));
            int b = qMin(255, qRound(0.5*(b1+b2)));*/

            /*int a = qMin(255, qRound((1.0*a1+0.32*a2)));
            int r = qMin(255, qRound((1.0*r1+0.32*r2)));
            int g = qMin(255, qRound((1.0*g1+0.32*g2)));
            int b = qMin(255, qRound((1.0*b1+0.32*b2)));*/

            QRgb mix = qRgba(r, g, b, a);
            /*qDebug() << "------";
            qDebug() << r1 << g1 << b1 << a1;
            qDebug() << r2 << g2 << b2 << a2;
            qDebug() << r << g << b << a;
            qDebug() << qRed(mix) << qGreen(mix) << qBlue(mix) << qAlpha(mix);*/
            //QRgb mix = qRgba(r2, g2, b2, a);
            if (a2 != 0)
                image->setPixel(offset.x()+x,offset.y()+y, mix);
        }
    }
}
开发者ID:sarathms,项目名称:pencil,代码行数:101,代码来源:bitmapimage.cpp


示例15: qRgba

quint32 Layer::_getMaskColor() const {
    QRgb rgbCol = qRgba( 255,255,255,255);
    return rgbCol;
}
开发者ID:slovelan,项目名称:NRAODev,代码行数:4,代码来源:Layer.cpp


示例16: qRgba

QRgb BitmapImage::pixel(QPoint P)
{
    QRgb result = qRgba(0,0,0,0); // black
    if ( boundaries.contains( P ) ) result = image->pixel(P - topLeft());
    return result;
}
开发者ID:sarathms,项目名称:pencil,代码行数:6,代码来源:bitmapimage.cpp


示例17: diagramSizeScaleFactor

QImage* QgsPieDiagramFactory::createDiagram( int size, const QgsFeature& f, const QgsRenderContext& renderContext ) const
{
  QgsAttributeMap dataValues = f.attributeMap();
  double sizeScaleFactor = diagramSizeScaleFactor( renderContext );

  //create transparent QImage
  int imageSideLength = size * sizeScaleFactor * renderContext.rasterScaleFactor() + 2 * mMaximumPenWidth + 2 * mMaximumGap;
  QImage* diagramImage = new QImage( QSize( imageSideLength, imageSideLength ), QImage::Format_ARGB32_Premultiplied );
  diagramImage->fill( qRgba( 0, 0, 0, 0 ) ); //transparent background
  QPainter p;
  p.begin( diagramImage );
  p.setRenderHint( QPainter::Antialiasing );
  p.setPen( Qt::NoPen );

  //calculate sum of data values
  double sum = 0;
  QList<double> valueList; //cash the values to use them in drawing later

  QgsAttributeMap::const_iterator value_it;
  QList<QgsDiagramCategory>::const_iterator it = mCategories.constBegin();
  for ( ; it != mCategories.constEnd(); ++it )
  {
    value_it = dataValues.find( it->propertyIndex() );
    valueList.push_back( value_it->toDouble() );
    if ( value_it != dataValues.constEnd() )
    {
      sum += value_it->toDouble();
    }
  }

  if ( doubleNear( sum, 0.0 ) )
  {
    p.end();
    delete diagramImage;
    return 0;
  }

  //draw pies

  int totalAngle = 0;
  int currentAngle, currentGap;
  int xGapOffset = 0;
  int yGapOffset = 0;

  QList<QgsDiagramCategory>::const_iterator category_it = mCategories.constBegin();
  QList<double>::const_iterator valueList_it = valueList.constBegin();

  for ( ; category_it != mCategories.constEnd() && valueList_it != valueList.constEnd(); ++category_it, ++valueList_it )
  {
    p.setPen( category_it->pen() );
    currentAngle = ( int )(( *valueList_it ) / sum * 360 * 16 );
    p.setBrush( category_it->brush() );

    xGapOffset = 0;
    yGapOffset = 0;
    currentGap = category_it->gap();
    if ( currentGap != 0 )
    {
      //qt angles are degrees*16
      gapOffsetsForPieSlice( currentGap, totalAngle + currentAngle / 2, xGapOffset, yGapOffset );
    }

    p.drawPie( mMaximumPenWidth * renderContext.rasterScaleFactor() + mMaximumGap + xGapOffset, mMaximumPenWidth * renderContext.rasterScaleFactor() + mMaximumGap - yGapOffset, sizeScaleFactor * renderContext.rasterScaleFactor() * size, sizeScaleFactor * renderContext.rasterScaleFactor() * size, totalAngle, currentAngle );
    totalAngle += currentAngle;
  }
  p.end();

  return diagramImage;
}
开发者ID:RealworldSystems,项目名称:Quantum-GIS,代码行数:69,代码来源:qgspiediagramfactory.cpp


示例18: setup_qt

static
void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float screen_gamma=0.0)
{
    if (screen_gamma != 0.0 && png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA)) {
        double file_gamma;
        png_get_gAMA(png_ptr, info_ptr, &file_gamma);
        png_set_gamma(png_ptr, screen_gamma, file_gamma);
    }

    png_uint_32 width;
    png_uint_32 height;
    int bit_depth;
    int color_type;
    png_bytep trans_alpha = 0;
    png_color_16p trans_color_p = 0;
    int num_trans;
    png_colorp palette = 0;
    int num_palette;
    png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0);
    png_set_interlace_handling(png_ptr);

    if (color_type == PNG_COLOR_TYPE_GRAY) {
        // Black & White or 8-bit grayscale
        if (bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1) {
            png_set_invert_mono(png_ptr);
            png_read_update_info(png_ptr, info_ptr);
            if (image.size() != QSize(width, height) || image.format() != QImage::Format_Mono) {
                image = QImage(width, height, QImage::Format_Mono);
                if (image.isNull())
                    return;
            }
            image.setColorCount(2);
            image.setColor(1, qRgb(0,0,0));
            image.setColor(0, qRgb(255,255,255));
        } else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
            png_set_expand(png_ptr);
            png_set_strip_16(png_ptr);
            png_set_gray_to_rgb(png_ptr);
            if (image.size() != QSize(width, height) || image.format() != QImage::Format_ARGB32) {
                image = QImage(width, height, QImage::Format_ARGB32);
                if (image.isNull())
                    return;
            }
            if (QSysInfo::ByteOrder == QSysInfo::BigEndian)
                png_set_swap_alpha(png_ptr);

            png_read_update_info(png_ptr, info_ptr);
        } else {
            if (bit_depth == 16)
                png_set_strip_16(png_ptr);
            else if (bit_depth < 8)
                png_set_packing(png_ptr);
            int ncols = bit_depth < 8 ? 1 << bit_depth : 256;
            png_read_update_info(png_ptr, info_ptr);
            if (image.size() != QSize(width, height) || image.format() != QImage::Format_Indexed8) {
                image = QImage(width, height, QImage::Format_Indexed8);
                if (image.isNull())
                    return;
            }
            image.setColorCount(ncols);
            for (int i=0; i<ncols; i++) {
                int c = i*255/(ncols-1);
                image.setColor(i, qRgba(c,c,c,0xff));
            }
            if (png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &trans_color_p) && trans_color_p) {
                const int g = trans_color_p->gray;
                if (g < ncols) {
                    image.setColor(g, 0);
                }
            }
        }
    } else if (color_type == PNG_COLOR_TYPE_PALETTE
               && png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)
               && num_palette <= 256)
    {
        // 1-bit and 8-bit color
        if (bit_depth != 1)
            png_set_packing(png_ptr);
        png_read_update_info(png_ptr, info_ptr);
        png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0);
        QImage::Format format = bit_depth == 1 ? QImage::Format_Mono : QImage::Format_Indexed8;
        if (image.size() != QSize(width, height) || image.format() != format) {
            image = QImage(width, height, format);
            if (image.isNull())
                return;
        }
        png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
        image.setColorCount(num_palette);
        int i = 0;
        if (png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &trans_color_p) && trans_alpha) {
            while (i < num_trans) {
                image.setColor(i, qRgba(
                    palette[i].red,
                    palette[i].green,
                    palette[i].blue,
                    trans_alpha[i]
                   )
               );
                i++;
            }
//.........这里部分代码省略.........
开发者ID:Afreeca,项目名称:qt,代码行数:101,代码来源:qpnghandler.cpp


示例19: FT_Set_Char_Size


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ qRound函数代码示例发布时间:2022-05-30
下一篇:
C++ qRgb函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap