Create gradient .jpg

dakota97

Well-known member
Joined
Nov 14, 2003
Messages
113
Location
Pennsylvania
Hi all,

Is it possible to create a new .jpg file from 2 colors that a user selects in a WinForms app?

What I want to do is give the user an option to select 2 colors using a colorpicker. When they click "save", I want to create a new 1px wide by 1050px high gradient style image to be used as a webpage background, and save it so that it can be uploaded to a web server via FTP. The uploading I can handle, but I need to know if theres a way to create the image file.

Thanks in advance,

-Chris
 
The following should get you started
C#:
           LinearGradientBrush b = new LinearGradientBrush(new Rectangle(0,0,100,100),Color.Red, Color.Blue, 45f );
            Bitmap bmp = new Bitmap(100,100);
            Graphics g = Graphics.FromImage(bmp);
            g.FillRectangle(b,0,0,100,100);
            bmp.Save("c:\\test.bmp");
 
Back
Top