How to display an image in the area defined in Picturebox?

Following my previous question, I got my region, but spent the last two hours trying to display tiny snapshots in this region; with the ultimate goal is the ability to arbitrarily display any number of images that 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 also tried the DrawImageUnscaled method, but I either got my small picture to fill the pie area, or nothing is displayed.

0
source share
2 answers

, , (, , ). . .

.

+1

:

pb.Image = (blip);

- , . , , PictureBox Image ( , "pb" - PictureBox ). .

+1

Source: https://habr.com/ru/post/1748210/


All Articles