C#动态画椭圆

动态画椭圆

public static void CreateEllipsePic(int intWidth, int intHeight, int intCornerHeight, int intCornerTopLeftWidth, int intCornerTopRightWidth, int intCornerBottomLeftWidth, int intCornerBottomRightWidth, Color BgColor, Color color, string strPath)
        {
            Bitmap bitmap = new Bitmap(intWidth, intHeight);
            Graphics g = Graphics.FromImage(bitmap);
            SolidBrush sb;// = new SolidBrush(BgColor);
            Rectangle rect;// = new Rectangle(0, 0, intWidth, intHeight);
            //g.FillRectangle(sb, rect);

            int intRealRectHeight = intHeight - intCornerHeight * 2 + 1;
            if (intRealRectHeight > 0)
            {
                sb = new SolidBrush(color);
                rect = new Rectangle(0, intCornerHeight, intWidth, intRealRectHeight);
                g.FillRectangle(sb, rect);
            }


            int intBegin, intEnd;
            int j;
            int varPrama = 2;
            int intTempHeight = intCornerHeight - 1, intTempHeight1;
            for (int i = 0; i <= intCornerHeight; i++)
            {
                intBegin = intCornerTopLeftWidth - varPrama;
                if (intBegin < 0) intBegin = 0;
                intEnd = intWidth - intCornerTopRightWidth + varPrama;
                if (intEnd > intWidth) intEnd = intWidth;
                for (j = intBegin; j < intEnd; j++)
                {
                    bitmap.SetPixel(j, i, color);
                }
                if (i == 0 || i == intTempHeight)
                {
                    varPrama = varPrama + 2;
                }
                else
                {
                    varPrama = varPrama + 1;
                }
            }

            varPrama = 2;
            intTempHeight = intHeight - 1;
            intTempHeight1 = intHeight - intCornerHeight + 1;
            for (int i = intHeight - 1; i >= intHeight - intCornerHeight; i--)
            {
                intBegin = intCornerBottomLeftWidth - varPrama;
                if (intBegin < 0) intBegin = 0;
                intEnd = intWidth - intCornerBottomRightWidth + varPrama;
                if (intEnd > intWidth) intEnd = intWidth;
                for (j = intBegin; j < intEnd; j++)
                {
                    bitmap.SetPixel(j, i, color);
                }

                if (i == intTempHeight || i == intTempHeight1)
                {
                    varPrama = varPrama + 2;
                }
                else
                {
                    varPrama = varPrama + 1;
                }
            }

            bitmap.Save(strPath);
            g.Dispose();
            bitmap.Dispose();

        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值