wpf RadioButton control

929Free 281 Reputation points
2020-07-20T06:58:10.807+00:00

hello, I have a ****.png picture. I want to turn the content into pictures. Who can help me.... thanks

c# code :
<RadioButton GroupName="Group_1" Name="Option_1" Content="Test" Visibility="Visible" Canvas.Left="336" Canvas.Top="216" Height="44" Width="181"/>

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,705 questions
0 comments No comments
{count} votes

Accepted answer
  1. DaisyTian-1203 11,621 Reputation points
    2020-07-20T08:56:22.83+00:00

    You can use Graphics.DrawString to add context in the image, I will give you my method:

     public void AddContext()  
            {  
                string dir = "C:\\Users\......\\Pictures\\Img.png";  
                if (File.Exists(dir))  
                {  
                    FileStream fs = new FileStream(dir, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);  
                    byte[] bytes = new byte[fs.Length];  
                    fs.Read(bytes, 0, bytes.Length);  
                    fs.Close();  
                    MemoryStream ms = new MemoryStream(bytes);  
                    Bitmap img = new Bitmap(ms);  
                    Graphics g = Graphics.FromImage(img);  
                    String str = "This is Content!!";  
                    Font font = new Font("Arial", 20);  
                    SolidBrush sbrush = new SolidBrush(System.Drawing.Color.Red);  
                    g.DrawString(str, font, sbrush, new PointF(20, 30));  
                    img.Save("123.jpg", System.Drawing.Imaging.ImageFormat.Png);  
      
                }  
            }  
    

    The reslut is:
    13041-165522.jpg


0 additional answers

Sort by: Most helpful