使用Bitmap绘制渐变颜色

void CTestGrandientContainer::Draw( const TRect& aRect ) const
        {
        // [[[ begin generated region: do not modify [Generated Contents]
        CWindowGc& gc = SystemGc();
        gc.Clear( aRect );
       
        CFbsBitmap* brush=new(ELeave)CFbsBitmap;
        TInt startColor=8716481; // 开始颜色
        TInt endColor=16777215; // 结束颜色
        TInt brushWidth=320; // 宽度
        ColorUtils::TBitmapOrientation brushOrientation=ColorUtils::EBitmapOrientationVertical;//渐变是垂直还是平行
        ColorUtils::CreateGradientBitmapL(*brush, iEikonEnv->WsSession(), brushWidth,
                        brushOrientation,startColor, endColor);        //创建渐变位图,参数可以参考API
        gc.DrawBitmap(aRect,brush);        //绘制
        }

 

转自http://www.devdiv.net/bbs/thread-6648-1-1.html

你可能感兴趣的:(symbian,api)