/** If the display mode of iBitmapInfo is not expected, return EFalse
 * or render to the back buffer and returns ETrue
*/
TBool CCommonInterfaces::DrawColor(const TRect& aRect,const TRgb& aColour)
	{
	TRect local = TRect(aRect.iTl-iRect.iTl, aRect.Size());
	TUint16* pBuffer16;
	TUint32* pBuffer32;

	if (iBitmapInfo.iDisplayMode != iDispMode)
		{
		return EFalse;
		}
	for (TInt y = local.iTl.iY; y < local.iBr.iY; y++)
		{
		for (TInt x = local.iTl.iX; x < local.iBr.iX; x++)
			{
			switch (iDispMode)
				{
				case EColor64K:
					pBuffer16 = (TUint16*)iBitmapInfo.iAddress;
					pBuffer16[y*iBitmapInfo.iLinePitch/2+x] = aColour._Color64K();
					break;
				case EColor16M:
					pBuffer16 = (TUint16*)iBitmapInfo.iAddress;
					pBuffer16[y*iBitmapInfo.iLinePitch/2+x] = aColour._Color64K();
					break;
				case EColor16MU:
					pBuffer32 = (TUint32*)iBitmapInfo.iAddress;
					pBuffer32[y*iBitmapInfo.iLinePitch/4+x] = aColour._Color16MU();
					break;
				case EColor16MA:
					pBuffer32 = (TUint32*)iBitmapInfo.iAddress;
					pBuffer32[y*iBitmapInfo.iLinePitch/4+x] = aColour._Color16MA();
					break;
				case EColor4K:
					pBuffer16 = (TUint16*)iBitmapInfo.iAddress;
					pBuffer16[y*iBitmapInfo.iLinePitch/2+x] = aColour._Color4K();
					break;
				case EColor16MAP:
					pBuffer32 = (TUint32*)iBitmapInfo.iAddress;
					pBuffer32[y*iBitmapInfo.iLinePitch/4+x] = aColour._Color16MAP();
					break;
				default:
					break;
				}
			}
		}
	return ETrue;
	}
/**
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);
	}
void CCommonInterfaces::DrawColour64KPixel(TInt aX,TInt aY, const TRgb& aColour) 
	{ 
	TUint16 *pBuffer = (TUint16*)iBitmapInfo.iAddress; 
	pBuffer[aY*iBitmapInfo.iLinePitch/2+aX] = aColour._Color64K(); 
	}