Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

Add text to png file.

I have 5 png image files, each is a different color of a simple balloon map marker.  I'd like be able to dynamically insert/edit/add a number to each.    The numbers could be from 1 to 250.  So, with 5 colors, I would need 1250 png file to cover all combinations of colors/numbers.  I'd like to use the 5 colored png files, and then dynamically insert a number, centered within the ballon.

I'm using the Google maps javascript v3 API, and map marker.   Unless maybe there is a way using the API to add numbers to a png file that is used as a map marker?
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

I converted this to vb.Net on the fly from:
http://tech.pro/tutorial/654/csharp-snippet-tutorial-how-to-draw-text-on-an-image

Adjusting for a dynamic width / height of the images.

Dim strFormat  as StringFormat = new StringFormat();
strFormat.Alignment = StringAlignment.Center
strFormat.LineAlignment = StringAlignment.Center

Dim myBmp as Bitmap = new Bitmap("C:\\myImage.png")
Dim g as Graphics = Graphics.FromImage(myBmp)
Dim i as Integer = GetRandomNumber() 'implement to return 1 to 250.
g.DrawString("My\nText", new Font("Tahoma", 20), Brushes.White, new RectangleF(0, 0, g.Width, g.Height), strFormat)  'it may be myBmp.Width, myBmp.Height

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of HLRosenberger
HLRosenberger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HLRosenberger

ASKER

google solution.