Fill Panel with gradient in three colors

后端 未结 2 1071
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 14:15

I\'m working on project and I have to do kind of color picker using C#.

So I\'ve decided that it will be a Panel with this background in Win Forms App.

Back

2条回答
  •  温柔的废话
    2020-11-28 14:31

    From the mouse click event argument e, you can get the Point with the exact co-ordinates of the click:

    Point clickPoint = e.GetPosition(backgroundControlWithImg);
    

    Then get the colour of the image at that position using something like:

    System.Drawing.Image image = backgroundControl.BackgroundImage;
    Bitmap _bitmap = new Bitmap(image);
    Color _color = bitmap.GetPixel(Point.x, Point.y);
    

    Something like that. What are you using for the Color Picker, WPF or?

提交回复
热议问题