コード例 #1
0
// ---------------------------------------------------------------------------
// Convert device-independent color to device-dependent color.
// ---------------------------------------------------------------------------
//
TInt CPeninputPenTraceDecorator::Rgb2DeviceColor( TDisplayMode aDisplayMode, const TRgb& aColor )
{
    switch( aDisplayMode )
    {
    case EGray2:
    {
        return aColor.Gray2();
    }
    case EGray4:
    {
        return aColor.Gray4();
    }
    case EGray16:
    {
        return aColor.Gray16();
    }
    case EGray256:
    {
        return aColor.Gray256();
    }
    case EColor16:
    {
        return aColor.Color16();
    }
    case EColor256:
    {
        return aColor.Color256();
    }
    case EColor64K:
    {
        return aColor.Color64K();
    }
    case EColor16M:
    {
        return aColor.Color16M();
    }
    case EColor4K:
    {
        return aColor.Color4K();
    }
    case EColor16MU:
    {
        return aColor.Color16MU();
    }
    case EColor16MA:
    {
        return aColor.Color16MA();
    }
    case EColor16MAP:
    {
        return aColor.Color16MAP();
    }
    default:
        return aColor.Internal();
    }
}
コード例 #2
0
/**
Draws a VerticalGradient onto a CFbsBitmap from top/color aLo to bottom/aHi
*/
void CTe_graphicsperformanceSuiteStepBase::VerticalGradientAlphaL(CFbsBitmap* aBitmap, TRgb aLo, TRgb aHi)
	{
	const TSize size = aBitmap->SizeInPixels();
	const TDisplayMode mode = aBitmap->DisplayMode();
	const TInt scanLineLength = CFbsBitmap::ScanLineLength(size.iWidth, mode);
	HBufC8* buffer = HBufC8::NewL(scanLineLength);
	CleanupStack::PushL(buffer);
	TPtr8 des = buffer->Des();
	des.SetLength(scanLineLength);
	for(TInt i=0; i<size.iHeight; i++)
		{
		TRgb color = InterpolateColour(aLo, aHi, i, size.iHeight);
		switch(mode)
			{
			case EGray256:
				{
				TUint8  g = color.Gray256();
				TUint8* p = (TUint8*)des.Ptr();
				for(TInt j=0; j<size.iWidth; j++)
					{						
					p[j] = g;
					}
				}
				break;
			case EColor64K:
				{
				TUint16  g = color._Color64K();
				TUint16* p = (TUint16*)des.Ptr();
				for(TInt j=0; j<size.iWidth/2; j++)
					{						
					p[j] = g;
					}
				}
				break;
			case EColor16MU:
				{
				TUint32 rgba = color._Color16MU();
				TUint32* p = (TUint32*)des.Ptr();
				for(TInt j=0; j<(size.iWidth/4); j++)
					{						
					p[j] = rgba;
					}
				}
				break;
			case EColor16MA:
				{
				TUint32 rgba = color._Color16MA();
				TUint32* p = (TUint32*)des.Ptr();
				for(TInt j=0; j<(size.iWidth/4); j++)
					{						
					p[j] = rgba;
					}
				}
				break;
			case EColor16MAP:
				{
				TUint32 rgba = color._Color16MAP();
				TUint32* p = (TUint32*)des.Ptr();
				for(TInt j=0; j<(size.iWidth/4); j++)
					{						
					p[j] = rgba;
					}
				}
				break;
			default:
				ASSERT(EFalse);
				break;
			}
		aBitmap->SetScanLine(des, i);
		}
	CleanupStack::PopAndDestroy(buffer);
	}