i try to create a custom usercontrol inherited from panel. I want to create it with a custom 3D effect.
ColorStart and ColorStopp are two Properties.
private void PaintGradient()
{
Point[] pt = new Point[]{new Point(0, 0),
new Point(0, 100)};
PathGradientBrush pathBrush = new PathGradientBrush(pt);
// -- -- -- >>> here comes the OutOfMemoryException
pathBrush.CenterPoint = new PointF(0, 50);
Color[] surrColors = new Color[2];
surrColors[0] = ColorStart;
surrColors[1] = ColorStart;
pathBrush.SurroundColors = surrColors;
pathBrush.CenterColor = ColorStopp;
Bitmap bmp = new Bitmap(this.Width, this.Height);
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(pathBrush, new Rectangle(0, 0, this.Width, this.Height));
this.BackgroundImage = bmp;
this.BackgroundImageLayout = ImageLayout.Stretch;
}
did you have an idea why this error occures.
Thanks Arnold