473,322 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

write text as image

Hi,

Does anyone know of any examples for writing text into images? I have a
program that collects some system information and I would like to write that
text into a BMP or JPG file.

Thank you.
Nov 21 '05 #1
4 2827
"Dragon" <ba***********@hotmail.com> schrieb:
Does anyone know of any examples for writing text into images? I have a
program that collects some system information and I would like to write
that text into a BMP or JPG file.


\\\
Dim b As New Bitmap(100, 100, ...)
Dim g As Graphics = Graphics.FromImage(b)
g.DrawString(...)
g.Dispose()
b.Save(...)
b.Dispose()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

"Dragon" <ba***********@hotmail.com> wrote in message
news:O%******************@TK2MSFTNGP12.phx.gbl...
Hi,

Does anyone know of any examples for writing text into images? I have a
program that collects some system information and I would like to write
that text into a BMP or JPG file.

Thank you.


Tested this and it works ;)

Dim img As System.Drawing.Bitmap
Dim canvas As System.Drawing.Graphics

' Create a blank image.
img = New System.Drawing.Bitmap( _
200, _
200, _
System.Drawing.Imaging.PixelFormat.Format32bppArgb _
)

Try
' Create the canvas.
canvas = System.Drawing.Graphics.FromImage(img)

' Paint a background.
canvas.Clear(System.Drawing.Color.White)

' Draw the "Hello World!" string.
canvas.DrawString( _
"Hello World!", _
New System.Drawing.Font("Verdana", 12), _
System.Drawing.Brushes.Black, _
10, _
10 _
)

' Save the image to disk.
img.Save( _
"C:\HelloWorld.jpg", _
System.Drawing.Imaging.ImageFormat.Jpeg _
)
img.Save( _
"C:\HelloWorld.bmp", _
System.Drawing.Imaging.ImageFormat.Bmp _
)
Finally
' Cleanup.
If Not canvas Is Nothing
canvas.Dispose()
End If
img.Dispose()
End Try
HTH,
Mythran ;)

Nov 21 '05 #3
Thank you everyone. I shall give it a try.
"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:uf*************@TK2MSFTNGP10.phx.gbl...

"Dragon" <ba***********@hotmail.com> wrote in message
news:O%******************@TK2MSFTNGP12.phx.gbl...
Hi,

Does anyone know of any examples for writing text into images? I have a
program that collects some system information and I would like to write
that text into a BMP or JPG file.

Thank you.


Tested this and it works ;)

Dim img As System.Drawing.Bitmap
Dim canvas As System.Drawing.Graphics

' Create a blank image.
img = New System.Drawing.Bitmap( _
200, _
200, _
System.Drawing.Imaging.PixelFormat.Format32bppArgb _
)

Try
' Create the canvas.
canvas = System.Drawing.Graphics.FromImage(img)

' Paint a background.
canvas.Clear(System.Drawing.Color.White)

' Draw the "Hello World!" string.
canvas.DrawString( _
"Hello World!", _
New System.Drawing.Font("Verdana", 12), _
System.Drawing.Brushes.Black, _
10, _
10 _
)

' Save the image to disk.
img.Save( _
"C:\HelloWorld.jpg", _
System.Drawing.Imaging.ImageFormat.Jpeg _
)
img.Save( _
"C:\HelloWorld.bmp", _
System.Drawing.Imaging.ImageFormat.Bmp _
)
Finally
' Cleanup.
If Not canvas Is Nothing
canvas.Dispose()
End If
img.Dispose()
End Try
HTH,
Mythran ;)

Nov 21 '05 #4
There is an example of creating high resolution image files with text in the
GDI+ FAQ.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Dragon" <ba***********@hotmail.com> wrote in message
news:O%******************@TK2MSFTNGP12.phx.gbl...
Hi,

Does anyone know of any examples for writing text into images? I have a
program that collects some system information and I would like to write
that text into a BMP or JPG file.

Thank you.

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Rhek | last post by:
Hello, I would like to apologize for double posting this question because I posted this same question in what looks like the VB 6 newgroups and not the .Net newsgroup... Here goes: The code...
6
by: ok | last post by:
<img src="http://www.6park.com/enter2/av.gif" onload="document.write('an iframe obj');"> First of all, it destroy the HTML page. Secondly even if it does not destroy it, the iframe object will...
3
by: francisco lopez | last post by:
I hope not sent I twice. ok here is my problem, the javascript form validation works perfect during I put a emaildirection in the <form action:""> comand, like this: <form...
1
by: von | last post by:
I am trying to write a single piece of data (that is generated from a Javascript) to a text file on my server via a Perl script. The Javascript is setup so that I can display the required data on...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
3
by: Coby Herd | last post by:
I cannot find any information on how to insert an image into a block of text and have the text wrap around the image. All if the text and graphics in the client's site are being pulled from the...
5
by: philip | last post by:
Here is some lines of code than I wrote. You can copy/paste theis code as code of form1 in a new project. My problem is this one : I try to write in a file a serie of bytes. BUT some bytes...
6
by: | last post by:
Using the HttpRequest object to gather material (potentially from an external server), is it possible to write the response stream into which ever file type is required e.g. I request not just...
8
by: RC | last post by:
I found background-color, background-image, but I don't see background-text. I would like have some text write to the padding areas like th, td { margin: 0; border-width: 1; width: 40px; height:...
3
by: Dave Keen | last post by:
Hi all. Hope you can help me. This should be easy but I can't make this work. In brief I am building a page of thumbnails using images held in a SQLServer 2000 database. I do this by creating...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.