private void ExtFill(Graphics vGraphics, int x, int y, FLOODFILLTYPE floodFillType, Color fillColor, Color borderColor = default(Color)) { IntPtr vDC = vGraphics.GetHdc(); IntPtr vBrush = CreateSolidBrush(ColorTranslator.ToWin32(fillColor)); IntPtr vPreviouseBrush = SelectObject(vDC, vBrush); switch (floodFillType) { case FLOODFILLTYPE.FLOODFILLSURFACE: ExtFloodFill(vDC, x, y, GetPixel(vDC, x, y), (uint)FLOODFILLTYPE.FLOODFILLSURFACE); break; case FLOODFILLTYPE.FLOODFILLBORDER: ExtFloodFill(vDC, x, y, ColorTranslator.ToWin32(borderColor), (uint)FLOODFILLTYPE.FLOODFILLBORDER); break; } SelectObject(vDC, vPreviouseBrush); DeleteObject(vBrush); vGraphics.ReleaseHdc(vDC); }