本文整理汇总了C++中TRgb类的典型用法代码示例。如果您正苦于以下问题:C++ TRgb类的具体用法?C++ TRgb怎么用?C++ TRgb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TRgb类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetPenColor
//Ensure the pen colour is set in the bitmap with the correct alpha blending level
void CTransGc::SetPenColor(const TRgb &aColor)
{
TRgb Color = aColor;
Color.SetAlpha(iAlpha);
iFbsBitGc.SetPenColor(Color);
}
示例2: TRgb
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: pixelPosition
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: Blit
// -----------------------------------------------------------------------------
// Blit
//
// Blits given image to gc.
//
// -----------------------------------------------------------------------------
//
inline static TBool Blit(
MAknsSkinInstance* aSkin, CBitmapContext& aGc, const TRect& aTrgRect,
CAknsImageItemData* aImgData, const TAknsItemID& aIID,
const TAknsBackground* aLayout, const TPoint& aPADelta,
const TInt aDrawParam )
{
CAknsAppSkinInstance* appInstance =
static_cast<CAknsAppSkinInstance*>(aSkin);
if ( IsBackgroundItem( aIID,appInstance ) &&
appInstance && appInstance->AnimBackgroundState() )
{
if( (aDrawParam&KAknsDrawParamPrepareOnly) )
{
return ETrue;
}
TRgb color = KRgbWhite;
color.SetAlpha(0x00);
aGc.SetPenColor(color);
aGc.SetBrushColor(color);
aGc.SetPenStyle(CGraphicsContext::ESolidPen);
aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
aGc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
TRect layoutRect( aTrgRect );
if( aLayout )
{
layoutRect = aLayout->iRect;
}
layoutRect.Move( -aPADelta );
TRect drawRect = aTrgRect;
drawRect.Intersection( layoutRect );
aGc.Clear(drawRect);
return ETrue;
}
TRect layoutRect( aTrgRect );
const TAknsImageAttributeData* attr = NULL;
if( aLayout )
{
layoutRect = aLayout->iRect;
if( aLayout->iAttr.iAttributes != EAknsImageAttributeNone )
{
attr = &(aLayout->iAttr);
}
}
layoutRect.Move( -aPADelta );
TRect drawRect(aTrgRect);
drawRect.Intersection( layoutRect );
return DrawPartialCachedImage( aSkin, aGc, layoutRect, drawRect,
aImgData, aIID, attr, aDrawParam );
}
示例5: 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;
}
}
}
示例6: SetTransparentBackground
void CButton::SetTransparentBackground(TBool aState)
{
TInt alpha;
if (aState){alpha=0;}
else {alpha=255;}
TRgb backgroundColour = KRgbWhite; // for example
if(KErrNone == iButton->Window().SetTransparencyAlphaChannel())
{backgroundColour.SetAlpha(alpha);}
iButton->Window().SetBackgroundColor(backgroundColour);
}
示例7: RWindowGroup
void CWindowMover::ConstructL(MWindowMover* m,QmlApplicationViewer* v,RWsSession* aWs)
{
iWinGroup=new (ELeave) RWindowGroup(*aWs);
iWinGroup->Construct((TUint32)&iWinGroup, EFalse);
iWinGroup->EnableReceiptOfFocus(EFalse); // Don't capture any key events.
iWinGroup->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront+KAddPriority+1);
CApaWindowGroupName* wn=CApaWindowGroupName::NewL(*aWs);
wn->SetHidden(ETrue);
wn->SetSystem(ETrue);
wn->SetWindowGroupName(*iWinGroup);
delete wn;
iCallBack=m;
viewer=v;
iDragged=EFalse;
CreateWindowL(iWinGroup);
SetPointerCapture(ETrue);
EnableDragEvents();
// for transparency
TRgb backgroundColour = KRgbWhite; // for example
//#ifndef _DEBUG
if(KErrNone == Window().SetTransparencyAlphaChannel())
{backgroundColour.SetAlpha(0);}
//#endif
Window().SetBackgroundColor(backgroundColour);
//SetSize(TSize(1,1));
MakeVisible(EFalse);
SetExtentToWholeScreen();
settings=new QSettings(KConfigFile,QSettings::IniFormat);
xAnim=new MyAnimation();
yAnim=new MyAnimation();
//QEasingCurve curve=new QEasingCurve(QEasingCurve::OutQuad);
xAnim->setEasingCurve(QEasingCurve::OutQuad);
yAnim->setEasingCurve(QEasingCurve::OutQuad);
xAnim->setDuration(200);
yAnim->setDuration(200);
connect(xAnim,SIGNAL(valueChanged(QVariant)),this,SLOT(xAnimChanged(QVariant)));
connect(yAnim,SIGNAL(valueChanged(QVariant)),this,SLOT(yAnimChanged(QVariant)));
connect(yAnim,SIGNAL(finished()),this,SLOT(finished()));
connect(xAnim,SIGNAL(finished()),this,SLOT(finished()));
iTimer=new QTimer();
iTimer->setInterval(400);
iTimer->setSingleShot(false);
connect(iTimer,SIGNAL(timeout()),this,SLOT(checkLaunchArea()));
ActivateL();
int gest=settings->value("settings/gesture").toInt();
if (gest==0) axisSet=false;
else if (gest==1) {axisX=1;axisY=0; axisSet=true;}
else if (gest==2) {axisX=0;axisY=1; axisSet=true;}
}
示例8: 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);
}
示例9: defined
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
}
示例10: 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();
}
示例11: new
/**
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;
}
示例12: TRgb
/**
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);
}
示例13: minor2Pot
CGameSpriteFrame::CGameSpriteFrame(const TFileName& filename, TUint32 id, const CGameRect& r, CFbsBitmap* loader){
loader->Load(filename, id, 0);
TInt i,j;
TInt h = loader->SizeInPixels().iHeight;
TInt w = loader->SizeInPixels().iWidth;
h = (h<r.h)?h:r.h;
w = (w<r.w)?w:r.w;
TInt H = minor2Pot(h);
TInt W = minor2Pot(w);
if(H>W)W=H;
else H=W;
this->texDim = H;
TRgb color;
TPoint point;
this->pixels = new TUint32[W*H];
for(i=0;i<w;i++){
for(j=0;j<h;j++){
point.SetXY(i,j);
loader->GetPixel(color,point);
this->pixels[i+j*W] = color.Value();
}
}
glGenTextures(1, &(this->texId));
glBindTexture(GL_TEXTURE_2D, this->texId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
GLint format = GL_RGBA;
glTexImage2D(GL_TEXTURE_2D, 0, format, W, H, 0,
format, GL_UNSIGNED_BYTE, this->pixels);
}
示例14: BaseConstructL
/**
* @brief Completes the second phase of Symbian object construction.
* Put initialization code that could leave here.
*/
void CTap2CloseAppUi::ConstructL()
{
// [[[ begin generated region: do not modify [Generated Contents]
BaseConstructL( EAknEnableSkin |
EAknEnableMSK );
InitializeContainersL();
// ]]] end generated region [Generated Contents]
//CCoeControl
iWinGroup=new (ELeave) RWindowGroup(CEikonEnv::Static()->WsSession());
iWinGroup->Construct((TUint32)&iWinGroup, EFalse);
iWinGroup->EnableReceiptOfFocus(EFalse); // Don't capture any key events.
iWinGroup->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
CApaWindowGroupName* wn=CApaWindowGroupName::NewL(CEikonEnv::Static()->WsSession());
wn->SetHidden(ETrue);
wn->SetSystem(ETrue);
wn->SetWindowGroupName(*iWinGroup);
delete wn;
iButton = CAknButton::NewL();
iButton->ConstructFromResourceL(R_CLOSE_BUTTON);
iButton->CreateWindowL(iWinGroup);
TInt scrX=CEikonEnv::Static()->ScreenDevice()->SizeInPixels().iWidth;
TRgb backgroundColour = KRgbWhite; // for example
if(KErrNone == iButton->Window().SetTransparencyAlphaChannel())
{backgroundColour.SetAlpha(0);}
iButton->Window().SetBackgroundColor(backgroundColour);
iButton->SetIconSize(KSize);
TRect r;
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EBatteryPane,r);
iButton->SetRect(TRect ( TPoint(scrX-KSize.iWidth-r.Width()-5,0),KSize));
iButton->SetObserver(this);
iButton->MakeVisible(ETrue);
iButton->ActivateL();
CEikonEnv::Static()->RootWin().SetOrdinalPosition(-4);
HideApplicationFromFSW(ETrue);
iObserver=CGroupListObserver::NewL(this);
}
示例15: Min
/**
Auxiliary function for all Test Cases
This method returns a TRgb colour which is a lighter tone of colour aColor.
*/
TRgb CSimpleControl::LightRgb(TRgb aColor) const
{
TInt value = aColor.Value();
TInt r = Min(255,((value & 0x000000ff) ) + 30);
TInt g = Min(255,((value & 0x0000ff00) >> 8) + 30);
TInt b = Min(255,((value & 0x00ff0000) >> 16) + 30);
return TRgb(r,g,b);
}