Add a timestamp to an image in VB.Net
In .Net/VB.Net, what is the best way to embed a timestamp (simple text like "2011/Jan/13 13:44") into a bitm开发者_开发知识库ap image?
I am loading images from a database, and they come without a timestamp embedded directly in the bitmap. What I am trying to do is add a timestamp to the image when I save it.
Thank you,
I take it you mean that you want to paint a date/time onto the bitmap before dishing it up to somebody. If that's the case, then this link
http://www.switchonthecode.com/tutorials/csharp-snippet-tutorial-how-to-draw-text-on-an-image
will show you the path to enlightenment. Basically, in C#, it's something like:
Bitmap myBitmap = new Bitmap("C:\\myImage.jpg");
Graphics g = Graphics.FromImage(myBitmap);
g.DrawString("My\nText", new Font("Tahoma", 40), Brushes.White, new PointF(0, 0));
I think you'll have to use the bitmaps as rendering surfaces and manually call the DrawText method on them.
Play around with the Graphics
class and see if you can get one from a bitmap (Also see if Bitmap does not come with a GetGraphics
function
精彩评论