Click here to Skip to main content
15,890,370 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have an image like 1.png, in the image there are two fields on it. like below:
C++
Name:
Date:

i have an app to receive the name and date from user, then put the values on the image
C++
Name: John
Date: 2018-10-01

and save it as john.png.

how to implement this using C#?

Thank you!

What I have tried:

i need to use 1.png as a template.

i don't have a solution.

Thank you!
Posted
Updated 29-Sep-18 0:43am

1 solution

Assuming your image has the name and date areas in the same place each time, then it's not too difficult:
using (Image i = Image.FromFile(inputPath))
    {
    using (Graphics g = Graphics.FromImage(i))
        {
        g.DrawString("John", Font, Brushes.Black, new PointF(fX, fY1));
        g.DrawString("2018-10-01", Font, Brushes.Black, new PointF(fX, fY2));
        }
    i.Save(outputPath, ImageFormat.Png);
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900