Asked by:
How can i convert image to text in c#

Question
-
In my application i am creating monochrome images for the given text and i am storing it in a folder. after that if a press the button i must get the images in picturebox and text in to text boxes how can it is possible please give me some example.
thanks regards deepthid
deepthi dTuesday, October 12, 2010 5:36 AM
All replies
-
Hi there.
It seems that yur are looking for a way to save metadata (text) togehter with your image, right?
If that's the case, you have a couple of options:
- Save the image together with a text file containing the text to a Zip file.
- Store the image and the text in an object and serialize that to a file.
- Store the image as a blob, and the text as a text field to a local database
It really depends on your requirements which is best for you, but my gut feeling says that going the serialize route is probably the most simple solution for you.
Hope this helps.
Regards,
Magnus
My blog: InsomniacGeek.comTuesday, October 12, 2010 6:54 AM -
can u please give some example
deepthi dTuesday, October 12, 2010 1:04 PM -
Hi deepthid,
Thanks for your question.
>>In my application i am creating monochrome images for the given text and i am storing it in a folder.
You can use Graphics.DrawString Method (String, Font, Brush, PointF) raws the specified text string at the specified location with the specified Brush and Font objects. Here is an sample code: http://msdn.microsoft.com/en-us/library/76c5db29.aspx
>>after that if a press the button i must get the images in picturebox and text in to text boxes how can it is possible please give me some example.
You can save the pic in a folder and use the given text as the pic's name, in this way, when you press the button, it is easy to fill the Textbox with the pic's name.
Hope these helps, if you have any problems, please feel free to let me know.
Best Regards,
Alan Chen
________________________________________
Please remember to mark the replies as answers if they help and unmark them if they provide no help- Marked as answer by Alan_chenModerator Monday, October 18, 2010 2:23 AM
- Unmarked as answer by deepthid Wednesday, November 24, 2010 11:22 AM
Thursday, October 14, 2010 3:47 AMModerator -
Hi deepthid.
You can learn about serialization here:
http://msdn.microsoft.com/en-us/library/182eeyhh.aspxExamples on how to serialize and deserialize:
http://msdn.microsoft.com/en-us/library/szzyf24s(v=VS.100).aspx
http://msdn.microsoft.com/en-us/library/fa420a9y.aspxHope this helps.
Regards,
Magnus
My blog: InsomniacGeek.com- Marked as answer by Alan_chenModerator Monday, October 18, 2010 2:23 AM
- Unmarked as answer by deepthid Wednesday, November 24, 2010 11:22 AM
Friday, October 15, 2010 10:00 AM -
http://www.dailycoding.com/Posts/convert_image_to_base64_string_and_base64_string_to_image.aspx
visit above link
or
use this artical
1: private Bitmap CreateBitmapImage(string sImageText)
2: {
3: Bitmap objBmpImage = new Bitmap(1, 1);
4:
5: int intWidth = 0;
6: int intHeight = 0;
7:
8: // Create the Font object for the image text drawing.
9: Font objFont = new Font("Arial", 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
10:
11: // Create a graphics object to measure the text's width and height.
12: Graphics objGraphics = Graphics.FromImage(objBmpImage);
13:
14: // This is where the bitmap size is determined.
15: intWidth = (int)objGraphics.MeasureString(sImageText, objFont).Width;
16: intHeight = (int)objGraphics.MeasureString(sImageText, objFont).Height;
17:
18: // Create the bmpImage again with the correct size for the text and font.
19: objBmpImage = new Bitmap(objBmpImage, new Size(intWidth, intHeight));
20:
21: // Add the colors to the new bitmap.
22: objGraphics = Graphics.FromImage(objBmpImage);
23:
24: // Set Background color
25: objGraphics.Clear(Color.White);
26: objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
27: objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
28: objGraphics.DrawString(sImageText, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
29: objGraphics.Flush();
30:
31: return (objBmpImage);
32: }
for more info visit :- http://chiragrdarji.wordpress.com/2008/05/09/generate-image-from-text-using-c-or-convert-text-in-to-image-using-c/
Saturday, October 16, 2010 8:17 PM