Click here to Skip to main content
13,139,254 members (91,211 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I wih to create an image to load as a background in a header on an html page that consists of a gradient from dark to lighter blue.

Short of proprietry graphics packages, is there a simple way (ie free?) of achieving this?

similar to these[^]
Posted 19-Apr-10 11:06am
Dalek Dave433.3K
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This[^] looks promising.
Otherwise there's plenty of other sites, just Google 'gradient creator'. :)

DD says...WooHoo that is not only exactly what I want, but the first little go I had, guessing at a couple numbers, got the right effect!

From KS: Glad to hear you found it useful. :thumbsup:
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hi Dave,

It seems from the answer above that you're sorted, but just thought I'd offer another possible solution.

How about doing it in code? You could create a new Bitmap, draw onto it using a Graphics object (obtained using Graphics.FromImage(bitmap)), then save the bitmap to file in your desired format.

DD Says...Sounds rather more complicated than my current envelope of ability would allow, but not beyond my horizon of potential, I shall investigate this.
Thanks though, you have put another project on my list of things to learn. The more the merrier.

Hi again Dave,

I've just had a play to make sure it was as easy as I thought and it is!
I don't have VB installed here, but here's the C# code - should be easy enough to convert.
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Windows.Forms;
public static class GradientCreator
    public static void CreateGradientBitmap(Size size, Color color1, Color color2, float angle, string filename, ImageFormat format)
        Rectangle fillRectangle = new Rectangle(0, 0, size.Width, size.Height);
        Bitmap b = new Bitmap(size.Width, size.Height);
        Graphics g = Graphics.FromImage(b);
        Brush gradientBrush = new LinearGradientBrush(fillRectangle, color1, color2, angle);
        g.FillRectangle(gradientBrush, fillRectangle);
        catch (Exception ex)
Can be called something like:
GradientCreator.CreateGradientBitmap(new Size(100, 100), Color.DarkBlue, Color.LightBlue, 90f, imagePath, ImageFormat.Jpeg);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 20 Apr 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100