image processing in .Net..doable??

eramgarden

Well-known member
Joined
Mar 8, 2004
Messages
579
I worked on a Java application ..it was an image processing application...

For example, the imput was a TIF file, the application added a text to the buttom of the image and the output was a GIF file...

So it converted a TIF file to a GIF file and added a text to the buttom of it...

was wondering if the same thing is doable in .Net.
 
Yes, its Easily Doable

This is pretty easy to do in .NET as well, the code would look something like this (in C#):

Bitmap b = new Bitmap("image.tif");
Graphics g = Graphics.FromImage(b);

Font boldFont = new Font("Times New Roman", 10, FontStyle.Bold);

g.DrawString("Im A Button!", boldFont, Brushes.Black, 10.0f, 10.0f);

b.Save("image.gif", ImageFormat.Gif);

g.Dispose();
b.Dispose();

Of course, if you arent doing anything else after that then you dont really need the dispose, but if youre done with the image it never hurts.
 
Wow, are you serious?? its doable with .Net?!! wow...

Let me ask you more question...

1. Where can I find more detail on .Net graphics? a sample website would be great...

2. What the Java app did was to :read a list of TIF images, add the text to it, output it to a folder. Would this be easy to do in .Net??

Any more leds would be great...
THANKS SO MUCH...
 
Yes, most everything that you can do in Java you can just as easily do in .NET, Microsoft actually has a Java to .NET conversion tool which you might be interested in, you can find it here (I havent tried it, and am not sure if it works with the command-line compiler however):

http://msdn.microsoft.com/vstudio/downloads/tools/jlca/default.aspx

1) I dont have any good tutorials on using GDI+ / .NET graphics. I typically use this forum, along with The Code Project:

http://www.thecodeproject.com

You may also want to bookmark the MSDN documentation on the Drawing namespace:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawing.asp

2) If you wanted to do all pictures in a folder this would be easy. If the list was in a file it would be easy as well, actually. To read from a file:

System.IO.StreamReader myReader = new StreamReader(fileName);

string picToOpen = myReader.ReadLine();

// do image manipulation...

Or if its all the files in a folder you would use:

string[] pics = System.IO.Directory.GetFiles(folderName);

for (int i = 0; i < pics.Length; i++) {
// load pics and do image processing
}

Thats about all there is to it.
 
Back
Top