本文整理汇总了C++中TRgb::Green方法的典型用法代码示例。如果您正苦于以下问题:C++ TRgb::Green方法的具体用法?C++ TRgb::Green怎么用?C++ TRgb::Green使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRgb
的用法示例。
在下文中一共展示了TRgb::Green方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InterpolateColour
/**
Interpolates between the two TRgb values aHi and aLo including alpha channel, with the value aX and the denoinator aN
*/
TRgb CTe_graphicsperformanceSuiteStepBase::InterpolateColour(TRgb aLo, TRgb aHi, TInt aX, TInt aN)
{
TInt y = aN - aX;
TUint8 a = (TUint8)( (aHi.Alpha()*aX + aLo.Alpha()*y)/aN );
TUint8 r = (TUint8)( (aHi.Red()*aX + aLo.Red()*y)/aN );
TUint8 g = (TUint8)( (aHi.Green()*aX + aLo.Green()*y)/aN );
TUint8 b = (TUint8)( (aHi.Blue()*aX + aLo.Blue()*y)/aN );
return TRgb(r, g, b, a);
}
示例2: ColorAdjust
EXPORT_C TRgb ColorUtils::ColorAdjust(TRgb aColor,TInt aPercentage)
/** Brightens or darkens a 24-bit colour by a percentage.
If the percentage given is less than 100%, a darker colour will be returned.
The algorithm brightens or darkens each of the R, G and B channels equally.
@param aColor Input colour.
@param aPercentage Percentage by which to adjust the input colour.
@return The adjusted colour. */
{
// Poor algorithm for the moment, but it can improve and all apps that
// use this will benefit. (I don't think the accuracy for a 16/256 color system
// is really relevant anyway)
TInt red=aColor.Red();
TInt green=aColor.Green();
TInt blue=aColor.Blue();
TInt alpha=aColor.Alpha();
if (aPercentage<=100)
{
red=(red * aPercentage)/100;
green=(green * aPercentage)/100;
blue=(blue * aPercentage)/100;
}
else
{
red = 255 - (((255 - red) * 100) / aPercentage);
green = 255 - (((255 - green) * 100) / aPercentage);
blue = 255 - (((255 - blue) * 100) / aPercentage);
}
return TRgb(red,green,blue,alpha);
}
示例3: getPixel
unsigned char CameraImage::getPixel(int x, int y) const
{
TPoint pixelPosition(x,y);
TRgb color;
image->GetPixel(color, pixelPosition);
return ((color.Red() + color.Green() + color.Blue()) / 3);
}
示例4: CreateSurface
void CGameImageLoader::CreateSurface()
{
TSize imagesize = iBitmap->SizeInPixels();
if (iPixelFormat)
{
// the image must be converted to the requested pixel format
int x, y;
TRgb pixel;
TPoint point;
TRAPD(error, iSurface = new Game::Surface(iPixelFormat, imagesize.iWidth, imagesize.iHeight));
if( error != KErrNone )
{
iErrorCode = error;
return;
}
if (!iSurface)
{
iErrorCode = KErrNoMemory;
return;
}
for(y=0; y<imagesize.iHeight; y++)
for(x=0; x<imagesize.iWidth; x++)
{
point.iX = x;
point.iY = y;
iBitmap->GetPixel(pixel, point);
iSurface->setPixel(x, y, iPixelFormat->makePixel(pixel.Red(), pixel.Green(), pixel.Blue()));
}
}
else
{
// no pixel conversion required
Game::PixelFormat bitmapPixelFormat(12);
Game::Surface tmpSurface(&bitmapPixelFormat, (Game::Pixel*)iBitmap->DataAddress(), imagesize.iWidth, imagesize.iHeight);
// TRAPD(error, iSurface = new Game::Surface(&bitmapPixelFormat, (Game::Pixel*)iBitmap->DataAddress(), imagesize.iWidth, imagesize.iHeight));
TRAPD(error, iSurface = new Game::Surface(&bitmapPixelFormat, &tmpSurface));
if( error != KErrNone )
{
delete iSurface;
iSurface = NULL;
iErrorCode = error;
return;
}
if (!iSurface)
{
iErrorCode = KErrNoMemory;
return;
}
}
}
示例5: CompareDisplayL
/**
Compare the window with the bitmap.
@param aScreen The screen device object
@param aBitmap The bitmap object for comparison
@return ETrue if the window and the bitmap is identified. Otherwise return EFalse.
*/
TBool CT_WServGenericpluginStepLoad::CompareDisplayL(CWsScreenDevice* aScreen, CFbsBitmap* aBitmap)
{
// Capture window display to bitmap
CFbsBitmap* screenBitmap = new(ELeave) CFbsBitmap();
CleanupStack::PushL(screenBitmap);
User::LeaveIfError(screenBitmap->Create(KWinRect.Size(), iDisplayMode));
User::LeaveIfError(aScreen->CopyScreenToBitmap(screenBitmap, KWinRect));
//Compare the window bitmap with the bitmap pass in for comparison
TBool ret = ETrue;
const TReal KErrorLimit = 0.05;
TInt mismatchedPixels = 0;
TRgb testWinPix = TRgb(0,0,0,0);
TRgb checkWinPix = TRgb(0,0,0,0);
for (TInt x = 0; x < KWinRect.Width(); x++)
{
for (TInt y = 0; y < KWinRect.Height(); y++)
{
screenBitmap->GetPixel(testWinPix, TPoint(x,y));
aBitmap->GetPixel(checkWinPix, TPoint(x,y));
//check if there are differeces between test Window colors and check Window colors
if(((TReal)abs(testWinPix.Red() - checkWinPix.Red())/255) > KErrorLimit ||
((TReal)abs(testWinPix.Blue() - checkWinPix.Blue())/255) > KErrorLimit ||
((TReal)abs(testWinPix.Green() - checkWinPix.Green())/255) > KErrorLimit ||
((TReal)abs(testWinPix.Alpha() - checkWinPix.Alpha())/255) > KErrorLimit)
{
mismatchedPixels++; // -- Useful for debugging
ret = EFalse;
break;
}
}
}
/* INFO_PRINTF2(_L("Number of different pixels: %i"), mismatchedPixels); */ // -- Useful for debugging
CleanupStack::PopAndDestroy(screenBitmap);
return ret;
}
示例6: RgbToHsl
/**
Auxilliary function for TestCaseID tbrdrcol-DrawColorCubeBackgroundNow
This method converts a TRgb colour HSL format.
*/
THsl ColorConverter::RgbToHsl(TRgb aRgb)
{
const TInt r = aRgb.Red();
const TInt g = aRgb.Green();
const TInt b = aRgb.Blue();
const TInt cmax = Max(r, Max(g,b));
const TInt cmin = Min(r, Min(g,b));
TInt h = 0;
TInt l = (cmax + cmin) >> 1; // Divided with 2
TInt s = 0;
if (cmax==cmin)
{
s = 0;
h = 0; // it's really undefined
}
else
{
if ( l < (255/2) )
{
s = ((cmax-cmin)*255)/(cmax+cmin);
}
else
{
s = ((cmax-cmin)*255)/((2*255)-cmax-cmin);
}
TInt delta = cmax - cmin;
if (r==cmax)
{
h = ((g-b)*255) / delta;
}
else if (g==cmax)
{
h = 2*255 + ((b-r)*255) / delta;
}
else
{
h = 4*255 + ((r-g)*255) / delta;
}
h /= 6;
if (h<0)
{
h += (1*255);
}
}
return THsl(h, s, l);
}
示例7: bitmap
void tst_NativeImageHandleProvider::bitmap()
{
#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG)
QPixmap tmp(10, 20);
if (tmp.pixmapData()->classId() == QPixmapData::OpenVGClass) {
BitmapProvider prov;
// This should fail because of null ptr.
QPixmap pm = pixmapFromNativeImageHandleProvider(&prov);
QVERIFY(pm.isNull());
pm = QPixmap();
QCOMPARE(prov.refCount, 0);
prov.bmp = new CFbsBitmap;
QCOMPARE(prov.bmp->Create(TSize(prov.w, prov.h), EColor16MAP), KErrNone);
CFbsBitmapDevice *bitmapDevice = CFbsBitmapDevice::NewL(prov.bmp);
CBitmapContext *bitmapContext = 0;
QCOMPARE(bitmapDevice->CreateBitmapContext(bitmapContext), KErrNone);
TRgb symbianColor = TRgb(255, 200, 100);
bitmapContext->SetBrushColor(symbianColor);
bitmapContext->Clear();
delete bitmapContext;
delete bitmapDevice;
pm = pixmapFromNativeImageHandleProvider(&prov);
QVERIFY(!pm.isNull());
QCOMPARE(pm.width(), prov.w);
QCOMPARE(pm.height(), prov.h);
QVERIFY(prov.refCount == 1);
QImage img = pm.toImage();
QVERIFY(prov.refCount == 1);
QRgb pix = img.pixel(QPoint(1, 2));
QCOMPARE(qRed(pix), symbianColor.Red());
QCOMPARE(qGreen(pix), symbianColor.Green());
QCOMPARE(qBlue(pix), symbianColor.Blue());
pm = QPixmap(); // should result in calling release
QCOMPARE(prov.refCount, 0);
delete prov.bmp;
} else {
QSKIP("Not openvg", SkipSingle);
}
#else
QSKIP("Not applicable", SkipSingle);
#endif
}
示例8: UpdateColor
EXPORT_C TInt CWsContainGraphicBitmap::UpdateColor(TRgb aColor)
{
if (!iIsReady)
return KErrNotReady;
// Send the color the server side
TBuf8<3> cmd;
TInt red = aColor.Red();
TInt green = aColor.Green();
TInt blue = aColor.Blue();
//Append the color
cmd.Append(red);
cmd.Append(green);
cmd.Append(blue);
SendMessage(cmd);
return Flush();
}
示例9: fill
void tst_QVolatileImage::fill()
{
QVolatileImage img(100, 100, QImage::Format_ARGB32_Premultiplied);
QColor col = QColor(10, 20, 30);
img.fill(col.rgba());
QVERIFY(img.imageRef().pixel(1, 1) == col.rgba());
QVERIFY(img.toImage().pixel(1, 1) == col.rgba());
#ifdef Q_OS_SYMBIAN
CFbsBitmap *bmp = static_cast<CFbsBitmap *>(img.duplicateNativeImage());
QVERIFY(bmp);
TRgb pix;
bmp->GetPixel(pix, TPoint(1, 1));
QCOMPARE(pix.Red(), col.red());
QCOMPARE(pix.Green(), col.green());
QCOMPARE(pix.Blue(), col.blue());
delete bmp;
#endif
}
示例10: bitmap
void tst_QVolatileImage::bitmap()
{
#ifdef Q_OS_SYMBIAN
CFbsBitmap *bmp = new CFbsBitmap;
QVERIFY(bmp->Create(TSize(100, 50), EColor64K) == KErrNone);
QVolatileImage bmpimg(bmp);
CFbsBitmap *dupbmp = static_cast<CFbsBitmap *>(bmpimg.duplicateNativeImage());
QVERIFY(dupbmp);
QVERIFY(dupbmp != bmp);
QCOMPARE(dupbmp->DataAddress(), bmp->DataAddress());
delete dupbmp;
delete bmp;
bmpimg.beginDataAccess();
qMemSet(bmpimg.bits(), 0, bmpimg.byteCount());
qMemSet(bmpimg.bits(), 1, bmpimg.bytesPerLine() * bmpimg.height());
bmpimg.endDataAccess();
// Test bgr->rgb conversion in case of EColor16M.
bmp = new CFbsBitmap;
QVERIFY(bmp->Create(TSize(101, 89), EColor16M) == KErrNone);
bmp->BeginDataAccess();
TUint32 *addr = bmp->DataAddress();
uint rgb = QColor(10, 20, 30).rgb();
qMemCopy(bmp->DataAddress(), &rgb, 3);
bmp->EndDataAccess();
TRgb symrgb;
bmp->GetPixel(symrgb, TPoint(0, 0));
QVERIFY(symrgb.Red() == 10 && symrgb.Green() == 20 && symrgb.Blue() == 30);
bmpimg = QVolatileImage(bmp);
QVERIFY(bmpimg.toImage().pixel(0, 0) == rgb);
// check if there really was a conversion
bmp->BeginDataAccess();
bmpimg.beginDataAccess();
qMemCopy(&rgb, bmpimg.constBits(), 3);
uint rgb2 = rgb;
qMemCopy(&rgb2, bmp->DataAddress(), 3);
QVERIFY(rgb != rgb2);
bmpimg.endDataAccess(true);
bmp->EndDataAccess(true);
delete bmp;
bmp = new CFbsBitmap;
QVERIFY(bmp->Create(TSize(101, 89), EGray2) == KErrNone);
bmpimg = QVolatileImage(bmp); // inverts pixels, but should do it in place
QCOMPARE(bmpimg.constBits(), (const uchar *) bmp->DataAddress());
QCOMPARE(bmpimg.format(), QImage::Format_MonoLSB);
bmpimg.ensureFormat(QImage::Format_ARGB32_Premultiplied);
QVERIFY(bmpimg.constBits() != (const uchar *) bmp->DataAddress());
QCOMPARE(bmpimg.format(), QImage::Format_ARGB32_Premultiplied);
delete bmp;
// The following two formats must be optimal always.
bmp = new CFbsBitmap;
QVERIFY(bmp->Create(TSize(101, 89), EColor16MAP) == KErrNone);
bmpimg = QVolatileImage(bmp);
QCOMPARE(bmpimg.format(), QImage::Format_ARGB32_Premultiplied);
QCOMPARE(bmpimg.constBits(), (const uchar *) bmp->DataAddress());
bmpimg.ensureFormat(QImage::Format_ARGB32_Premultiplied);
QCOMPARE(bmpimg.constBits(), (const uchar *) bmp->DataAddress());
delete bmp;
bmp = new CFbsBitmap;
QVERIFY(bmp->Create(TSize(101, 89), EColor16MU) == KErrNone);
bmpimg = QVolatileImage(bmp);
QCOMPARE(bmpimg.format(), QImage::Format_RGB32);
QCOMPARE(bmpimg.constBits(), (const uchar *) bmp->DataAddress());
bmpimg.ensureFormat(QImage::Format_RGB32);
QCOMPARE(bmpimg.constBits(), (const uchar *) bmp->DataAddress());
delete bmp;
#else
QSKIP("CFbsBitmap is only available on Symbian, skipping bitmap test", SkipSingle);
#endif
}
示例11: platformActiveSelectionForegroundColor
Color RenderThemeSymbian::platformActiveSelectionForegroundColor() const
{
TRgb c = CEikonEnv::Static()->Color(EColorControlHighlightText);
return Color(c.Red(),c.Green(),c.Blue());
}
示例12: DrawPoint
TRect CPeninputPenTraceDecorator::DrawPoint( const TPoint& aPoint )
{
if ( !iBitsBitmap || !iMaskBitmap || !iXSquareArray )
{
__ASSERT_DEBUG( EFalse, User::Panic( _L("PenTrace Decorator: invalid status"), 0 ) );
return TRect();
}
TSize cvsize = iBitsBitmap->SizeInPixels();
if ( cvsize.iWidth < 1 || cvsize.iHeight < 1 )
{
__ASSERT_DEBUG( EFalse, User::Panic( _L("PenTrace Decorator: invalid status"), 0 ) );
return TRect();
}
TBitmapUtil bits( iBitsBitmap );
TBitmapUtil mask( iMaskBitmap );
TDrawLineParams params;
bits.Begin( TPoint( 0, 0 ) );
mask.Begin( TPoint( 0, 0 ) );
if ( ETrue )
{
TDisplayMode mode = iDisplayMode;
TRgb rgb = iPenTraceColor;
TInt32 clr = (TInt32) Rgb2DeviceColor( mode, rgb );
params.rtAffected = TRect();
params.bits = &bits;
params.mask = &mask;
params.SqX = iXSquareArray; // squares of X
params.nW = cvsize.iWidth; // width of destination
params.nH = cvsize.iHeight; // height of destination
params.color = clr;
params.bR = rgb.Red(); // value of red channel
params.bG = rgb.Green(); // value of green channel
params.bB = rgb.Blue(); // value of blue channel
params.x1 = aPoint.iX << 4 ; // (x of start point) << 4
params.y1 = aPoint.iY << 4 ; // (y of start point) << 4
params.d1 = 1; // width of start point
params.x2 = aPoint.iX << 4; // (x of end point) << 4
params.y2 = aPoint.iY << 4; // (y of end point) << 4
params.d2 = 1; // width of end point
DrawLongSegment( ¶ms );
}
mask.End();
bits.End();
iModified = ETrue;
return params.rtAffected;
}
示例13: DrawNextLine
// ---------------------------------------------------------------------------
// Continue to draw a line in a series of lines.
// ---------------------------------------------------------------------------
//
TRect CPeninputPenTraceDecorator::DrawNextLine( const TPoint& aPt1, const TPoint& aPt2 )
{
if ( !iBitsBitmap || !iMaskBitmap || !iXSquareArray )
{
__ASSERT_DEBUG( EFalse, User::Panic( _L("Pen Trace Decorator: invalid status"), 0 ) );
return TRect();
}
TSize cvsize = iBitsBitmap->SizeInPixels();
if ( cvsize.iWidth < 1 || cvsize.iHeight < 1 )
{
__ASSERT_DEBUG( EFalse, User::Panic( _L("Pen Trace Decorator: invalid status"), 0 ) );
return TRect();
}
TInt width_start = 0 ;
TInt width_end = 0;
TInt penWidthDefault = 16; //default width
TInt penWidthMin = 8; // min width
TInt penWidthAdapt = 4; // adaption factor
TInt penPressureThreshold = 1200; // threshold of pressure
TPoint pt1 = aPt1;
TPoint pt2 = aPt2;
width_start = iLastPenWidth;
TInt pressure = ( pt1.iX - pt2.iX ) * ( pt1.iX - pt2.iX ) + ( pt1.iY - pt2.iY ) * ( pt1.iY - pt2.iY );
if ( pressure >= penPressureThreshold )
{
width_end = penWidthMin;
}
else
{
width_end = (TUint8)( ( penWidthDefault * penWidthAdapt * ( penPressureThreshold - pressure ) + penPressureThreshold / 2 ) / penPressureThreshold + penWidthMin );
}
width_end = (TUint8)( ( width_start + width_end + 1 ) / 2 );
iLastPenWidth = width_end;
TBitmapUtil bits( iBitsBitmap );
TBitmapUtil mask( iMaskBitmap );
TDrawLineParams params;
bits.Begin( TPoint( 0, 0 ) );
mask.Begin( TPoint( 0, 0 ) );
if ( ETrue )
{
TDisplayMode mode = iDisplayMode;
TRgb color = iPenTraceColor;
TInt32 clrdev = (TInt32) Rgb2DeviceColor( mode, color );
params.rtAffected = TRect();
params.bits = &bits;
params.mask = &mask;
params.SqX = iXSquareArray; // squares of X
params.nW = cvsize.iWidth; // width of destination
params.nH = cvsize.iHeight; // height of destination
params.color = clrdev;
params.bR = color.Red(); // value of red channel
params.bG = color.Green(); // value of green channel
params.bB = color.Blue(); // value of blue channel
params.x1 = pt1.iX << 4 ; // (x of start point) << 4
params.y1 = pt1.iY << 4 ; // (y of start point) << 4
params.d1 = width_start; // (width of start point) << 3
params.x2 = pt2.iX << 4; // (x of end point) << 4
params.y2 = pt2.iY << 4; // (y of end point) << 4
params.d2 = width_end; // (width of end point) << 3
DrawLongSegment( ¶ms );
}
mask.End();
bits.End();
iModified = ETrue;
iLineCount++;
return params.rtAffected;
}