While you're doing what Michael said, go look at the #1 GDI+ question
which you will no-doubt be asking shortly.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
[quoted text, click to view] Suresh Gladstone wrote:
> Hi,
> Iam Facing some problem in the gradient of pixels while invoking DrawIamge
> of System.Graphics. My objective is to position a set of pixels in a bitmap
> and enlarge it based on the dimension specified for the container.I choose
> DrawImage method of Graphics object which Draws the specified portion of the
> specified Image at the specified location and with the specified size.
> While experimenting, I could see that the pixels drawn were enlarged and
> stretched. But the rectangles of the pixels formed are blurred and forms a
> gradient from the middle to the edges of each pixel rectangle. But what I
> really want is something which is of equal gradient in the stretched pixel.
> Please find the code snippet below,
>
>
> private void button1_Click(object sender, EventArgs e)
> {
> Graphics g = this.CreateGraphics();
> Bitmap bg = new Bitmap(9, 8);// CREATING A BITMAP OBJECT WHICH SIZE
> 9X8, ADDING SIX PIXELS TO THE BITMAP
> bg.SetPixel(1, 1, Color.Red);
> bg.SetPixel(1, 3, Color.Blue);
> bg.SetPixel(1, 5, Color.Green);
> bg.SetPixel(3, 1, Color.Orange);
> bg.SetPixel(3, 3, Color.Violet);
> bg.SetPixel(3, 5, Color.Pink);
> g.DrawImage(bg, 50, 50, 200, 200); //ENLARGING AND DRAWING THE
> BITMAP TO SIZE 200 X 200
> //HERE IS WHERE THE PIXELS FORM RECTANGLES WITH GRADIENT FROM MIDDLE
> TO EDGES
> }
>
> My requirement is, the stretched pixel should be a rectangle with solid
> color and constant gradient. How do I acheive this ?
>
> Any help will be really appreciated.
>
> Regards,
> suresh
>
>