tags:

views:

64

answers:

2

As a follow on to my previous question I have gotten my region but spent the last two hours trying to display tiny pictures wihing that region alone; with the end goal being to be able to arbitarily display any number of images I choose. so far this is my code:

    void OnPaintRadar(Object sender, PaintEventArgs e)
{
    Graphics g = e.Graphics;        
    Bitmap blip = new Bitmap(tst_Graphics.Properties.Resources.dogtag);
    Rectangle radar_rect = new Rectangle(myRadarBox.Left + 80, myRadarBox.Left + 7, myRadarBox.Width - 200, myRadarBox.Height + 200);
    using (Pen drw_pen = new Pen(Color.White, 1) )
    {
        using (GraphicsPath path = new GraphicsPath())
        {
            path.AddPie(radar_rect, 180, 180);
            path.CloseFigure();
            using (Region rdRegion = new Region(path) )
            {
                g.DrawPath(drw_pen, path);
                g.Clip = rdRegion;
                PictureBox pb = new PictureBox();
                pb.Image = (blip);
                pb.Size = blip.Size;
                g.DrawImage(blip, radar_rect);
            }
        }

    }

}// end paint method

I have tried the DrawImageUnscaled method also but I either get a my tiny picture blown to fill the pie region or nothing is displayed.

+1  A: 

This line:

pb.Image = (blip);

is what's causing the tiny image to appear large. Basically, you pulling a tiny bitmap out of resources, and then setting the PictureBox's Image property to that bitmap (I'm assuming "pb" is a PictureBox on your form). Try commenting out that line and the line below it.

MusiGenesis
No joy.Actually I just thought since I wasn't using the picturebox anyways commenting the lines out wouldn't affect anything since I'm adding the image, not the picturebox, to the region.
Dark Star1
+1  A: 

Click here to run a sample application that demonstrates the basics of how to do radar (or one way, at least). Note: this application does not do double-buffering or transparency of the tiny image.

Source code for the project is here.

MusiGenesis
Thank you very much. I'll have a look at it and get back to you later.
Dark Star1