.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

C# Snippet Tutorial - How to Draw Text on an Image

Posted By: Syed Shakeer Hussain     Posted Date: October 05, 2010    Points: 2   Category :ASP.Net
In this snippet tutorial we're going to be adding on to our series of C# image editing tutorials. This tutorial is going to provide the code required to do basic text drawing including anti-aliasing and text alignment.

For more information on C# image editing, check out our previous two tutorials: C# Tutorial - Image Editing: Saving, Cropping, and Resizing and C# Tutorial - Image Editing: Rotate.

Ok, let's get started. The first thing we need to do is get a Bitmap object from an image file.

Bitmap myBitmap = new Bitmap("C:\\myImage.jpg");

Now that we have a Bitmap object we can get a Graphics object from it. The Graphics object will be doing all of our text drawing.

View Complete Post

More Related Resource Links

Built-in Functions - Text and Image Functions in SQL Server

Text and image functions operate on TEXT, NTEXT and IMAGE data types. These data types are deprecated with SQL Server 2005 and should be replaced by VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) when possible. Alternatively you can also consider storing large string values using XML data type. Text and image functions are nondeterministic.

Future versions of SQL Server will not support TEXT, NTEXT and IMAGE data types. Columns with TEXT / NTEXT data type do not support commonly used string functions such as LEN, LEFT, RIGHT, etc. Furthermore, due to the large size of TEXT data you''re likely to see performance issues if you store such data in the database. However, at times you can''t help but use the TEXT / NTEXT / IMAGE data types (for example when supporting 3rd party databases when you cannot change the schema) - this is when text and image functions come in handy.

Built-in Functions - Text and Image Functions

Text and image functions operate on TEXT, NTEXT and IMAGE data types. These data types are deprecated with SQL Server 2005 and should be replaced by VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) when possible. Alternatively you can also consider storing large string values using XML data type. Text and image functions are nondeterministic.

How to convert both text and image into image

Hi, Here is a question. how to convert both text and image together into an image. To clarify my question I can say if I have a text editor where I can add both text,image,audio or video player, how can I convert the whole texteditor.text (it gives me html code) to an image and save it in a file. I will be highly pleased with your answer. Help me please. Thank you. 

Overlay Image in InfoPath with text field

Hi, We are currently designing a simple test for some employees to take and it will be delivered via InfoPath forms services. Upon successful completion of the test the userr will be invited to click a button to view (then print) their certificate. The certificate has been received as a .jpg. Is there any way to overlay the image with a text box, as this would enble the user to print a certificate where their name appears on it.

How to Use Image and Text in CommandField

 Hello, I have a CommandField with an edit button.  I want to be able to use an image for the edit, but text for the update and delete buttons.  I can't figure out how to use both.  Here is the CommandField:  <asp:CommandField ShowEditButton="true" ButtonType="Image" EditImageUrl="~/Images/pencil.gif" HeaderText="Edit" />  

How to create a button with image and text


Currently I have button on a form and I need to make buttons image but maintain the click event functions that they have. For instance I have a button that says Update. Is there a way to add an image and put text in that image that says Update and maintain it's functionality. here is the code for the button:

<asp:Button ID="btnUpdate" runat="server" Text="Update" Visible="False" />


Draw text on screen, one line and then next (GDI+)


I want to draw some lines on screen, one line and then next, just likes you see the subtitle of a movie.

but they overlaped, and I just get a black rect in the end.

It is not repainted between every drawing, so i want to know how to force to repaint.

It is to screen, not form. thx.


private void Show(string line)
  IntPtr desk = GetDesktopWindow();
  IntPtr hdc = GetDCEx(desk, IntPtr.Zero, 1027);
  //RedrawWindow(desk, Rectangle.Empty, IntPtr.Zero, 0x85);
  Graphics g = Graphics.FromHdc(hdc);
  g.DrawString(line, this.Font, new SolidBrush(forecolor), new PointF(Screen.GetWorkingArea(this).Width - 500,
  Screen.GetWorkingArea(this).Height - 60));

how to draw a part of the page to image



i want to draw a part of the page like panel or table  or whatever to image

how to convert it to stream to save it to image?


thanks in advance.


How to save WPF RichTextBox content (text + image) to the database



I want to save (and after that also to retrieve) the content of an WPF RichTextBox (text + image) to/from the database.

I found this: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/750a654e-b002-4742-8f46-609e93f6ec81 but like the author said, the solution seams not to work for text with image - the image is ignored/removed and only the formatted text is saved and after that retrieved to/from database.

Know someone a solution about this issue?

Best regards,





C# Tutorial - Image Editing: Saving, Cropping, and Resizing

In C# it can be tiresome to do certain image editing functions using GDI+. This post has some fun editing methods which can come in handy at times. I have also included a nice little C# program to show all the functionality of the methods below.

Saving a Jpeg
The first thing to do here is set up the method signature with the input parameters. These are the save file path (string), the Image to save (System.Drawing.Bitmap), and a quality setting (long).

Can a gridview contain an image and text in the same column?


I have a 1-column gridview (and it must remain 1-column) which contains only text.  My requirement is to prefix each row with an image followed by the text.  The image may or may not be indented a bit, like an expanded child node in a tree.

I know a gridview renders as a table and I know I could put an image at the beginning of each row in a table (using a repeater, for example).  But this is an existing app with a couple gridviews which need to be enhanced and I don't have the time to swap out the gridviews for repeaters.

I can't find any reference anywhere on the 'net which deals with this topic.  Anyone have any ideas?

Thanks in advance,


 - C# & .Net v4

Draw a circle on an Image


Hi all,

I have an image of an industrial part that I display on a webpage, that part may contain defects, if it does I need to draw a red circle on that image.

I cant find a way of drawing on top of that image...

Can anyone help,

Thank you very much.


PS: Developing in ASP.Net

How to write ListViewItem that contain image , text and button ?


I need to write some listViewItem  ( using WPF ) - that contain image, text and button.

I want to inherit from the simple listViewItem class and add to the listview item that contain the three items ( image, text, button ).

I don't understand how the listView control will arrange the 3 items ( image , text, button ) in the right order in the control - how to tell the listview control that the image is first, text is second and the button is the third ?  

setting the tooltip as image instead of Text


I'm a web dev newbie.I want to set tool tip as image(16X16).Is it possible to give a source as a image

Loading rtf with image gives "Unrecognized structure in data format 'Rich Text Format'.\r\nParamet


I'm trying to load this rtf into a RichTextBox:

{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0 \cf0\ql{\f2 {\ltrch >> -----------------------------------------------------}{\ltrch \line }{\ltrch >> 19-10-2010 11:22}{\ltrch \line }{\ltrch >> -----------------------------------------------------}{\ltrch \line }\li0\ri0\sa0\sb0\fi0\ql\par}
{\f2 {\ltrch {\*\shppict{\pict\picwgoal1020\pichgoal1035\pngblip

How can I do this image and text split in html?


1) The image is from a asp:image tag
2) text is from asp:label

view here : http://screencast.com/t/fNL3SUzG

How can I get text to start after the image is set in the top left corner, and then have text wrap underneath the image, if the text is long enough.

I need to use asp:image and asp:labels as the inputs are populated from codebehind.

How can this text and image format be done ???

how can I draw an image to a picturebox using VB2005?


trying to draw an image to rthe picturebox not from a file, but from a bitmap in memory.

also scroll the image across the picturebox . I have an idea of using the PictureBox_Paint().

how to use DrawImage(image, 0,0,picturebox.width,picturebox.height) with these arguments.

please help thanks. 

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend