Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

Help with CODE....

Hi
I am useing the following code to draw a ring, of light and its not working?

        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap b = new Bitmap(710, 710);
            b.MakeTransparent(Color.Blue);
            Graphics g = Graphics.FromImage(b);
            g.Clear(Color.WhiteSmoke);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.DrawEllipse(new Pen(Brushes.White, 6f), 5, 5, 700, 700);
            b.Save(new System.IO.FileStream(@"c:\temp\lightring.gif", System.IO.FileMode.Create), System.Drawing.Imaging.ImageFormat.Gif);
        }
0
schenkp
Asked:
schenkp
  • 4
  • 3
2 Solutions
 
muzzy2003Commented:
This is drawing a white circle on a very pale background, and it is working. What is the problem you are trying to solve?
0
 
schenkpAuthor Commented:
I am tring to have it display over the active form?  But for some reason its not or am i doing something wrong?
0
 
muzzy2003Commented:
All you're doing here is creating a graphic and saving it out to a file. There's nothing here to display it. Are you talking ASP.NET forms or Windows forms?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
muzzy2003Commented:
If it's Windows forms, try using:

Graphics g = this.CreateGraphics();

instead, and not using your Bitmap b at all.
0
 
schenkpAuthor Commented:
       private void button1_Click(object sender, EventArgs e)
        {
            Bitmap b = new Bitmap(710, 710);
            b.MakeTransparent(Color.WhiteSmoke);
            //Graphics g = Graphics.FromImage(b);
            Graphics g = this.CreateGraphics();
            g.Clear(Color.WhiteSmoke);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.DrawEllipse(new Pen(Brushes.White, 6f), 5, 5, 700, 700);
           // b.Save(new System.IO.FileStream(@"c:\temp\lightring.gif", System.IO.FileMode.Create), System.Drawing.Imaging.ImageFormat.Gif);
        }

0
 
schenkpAuthor Commented:
How can i make the everything on the form transparent except for the ring?
0
 
muzzy2003Commented:
Remove the g.Clear(Color.WhiteSmoke), and you'll just be drawing the ring onto the form.
0
 
Fernando SotoRetiredCommented:
Hi schenkp;

This will make the form transparent except for the ring. I made the color of the ring to yellow because to many things are white and you may not see it.

      private void button1_Click(object sender, System.EventArgs e)
      {
            this.TransparencyKey = Color.WhiteSmoke;
            this.BackColor = Color.WhiteSmoke;
            this.Refresh();
            Graphics g = this.CreateGraphics();
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.DrawEllipse(new Pen(Brushes.Yellow, 6f), 5, 5, 700, 700);
      }

Fernando
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now