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,783 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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"/>
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: