ARCed.UI.DrawHelper.CalculateGraphicsPathFromBitmap C# (CSharp) Method

CalculateGraphicsPathFromBitmap() public static method

public static CalculateGraphicsPathFromBitmap ( Bitmap bitmap, Color colorTransparent ) : GraphicsPath
bitmap System.Drawing.Bitmap
colorTransparent System.Drawing.Color
return System.Drawing.Drawing2D.GraphicsPath
        public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent)
        {
            var graphicsPath = new GraphicsPath();
            if (colorTransparent == Color.Empty)
                colorTransparent = bitmap.GetPixel(0, 0);

            for (int row = 0; row < bitmap.Height; row++)
            {
                int colOpaquePixel = 0;
                for (int col = 0; col < bitmap.Width; col++)
                {
                    if (bitmap.GetPixel(col, row) != colorTransparent)
                    {
                        colOpaquePixel = col;
                        int colNext = col;
                        for (colNext = colOpaquePixel; colNext < bitmap.Width; colNext++)
                            if (bitmap.GetPixel(colNext, row) == colorTransparent)
                                break;

                        graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1));
                        col = colNext;
                    }
                }
            }
            return graphicsPath;
        }

Same methods

DrawHelper::CalculateGraphicsPathFromBitmap ( Bitmap bitmap ) : GraphicsPath