Hi all.

Could anyone give me a pointer please?

I've almost finished a project I'm working on but have one last issue to resolve.
I have an image on a form that I apply a colour gradient to. However, when I grab this to create a bitmap (this.DrawToBitmap(BackGroundBmp, BackGroundRect);) I do not get the gradient. So, I've applied the gradient to the bitmap directly. However this is noticeably darker than the form image with the gradient over it. Any idea?

Bitmap BackGroundBmp = new Bitmap(this.Width, this.Height);
Rectangle BackGroundRect = new Rectangle(0, 0,this.Width, this.Height);
this.DrawToBitmap(BackGroundBmp, BackGroundRect);


Graphics g = Graphics.FromImage(BackGroundBmp);
g.FillRectangle(RenderBGGradient, RenderBGGradBrush);


Thanks in advance.

I'm not going to pretend that I understand why but even though the image on the form had a gradient on it, but was not visible in the bitmap that was rendered (using -> this.DrawToBitmap), it must have some how applied this gradient (I'm using alpha blend in the gradient). It was doubling up on the gradient that was applied to the form and the bitmap...... which made it darker. I applied the gradient straight to the bitmap......problem solved. The gradient wasn't visible in the rendered bitmap so, therefore, if I'd not been so sloppy and removed the code that applied the gradient to the form, I would have solved this sooner.

That's great you got it solved. Why not post the finished code (using CODE TAGS) so that when others are searching for an answer to their problem they can find and benefit from your solution?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.