Library code snippets
Image to HTML
Usage goes like this: pic2htm.exe file1.jpg file2.htm 4
The last parameter (4 in this example) is the amount to scale down by.
For full-sized, put a 1, for half size, put 2, etc. You must have something
there
as there are no checks to see if there's nothing there.
Below is the code.
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Drawing2D;
class pic2htm {
public static void Main(string[] args) {
Bitmap b = (Bitmap)Image.FromFile(args[0]);
StreamWriter SW = new StreamWriter(args[1]);
SW.WriteLine("<b><font size='1pt'><pre>");
for(int y=0;y<b.Height;y+=int.Parse(args[2])) {
for(int x=0;x<b.Width;x+=int.Parse(args[2])) {
SW.Write("<font color='#" + b.GetPixel(x,y).Name.Substring(2)
+ "'>");
SW.Write(((byte)b.GetPixel(x,y).ToArgb())>>7);
SW.Write("</font>");
}
SW.WriteLine();
}
SW.WriteLine("</pre></font></b>");
SW.Close();
SW = null;
}
}
Related articles
Related discussion
-
What is C#
by paulfp (5 replies)
-
Schema Data from OLAP
by odin (0 replies)
-
Popup Window
by rajasahekar (3 replies)
-
Capture tab key
by kyledunn (3 replies)
-
Updating source with data adapter
by kyledunn (0 replies)
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum) -
Applicatie ontwikkelaar binnen Defensie
in Amsterdam (£50K-£90K per annum) -
Microsoft Dynamics CRM Technical Consultant
in Netherlands (€50K-€90K per annum) -
Front End Developer
in Hammersmith (£45K-£60K per annum)
Events coming up
-
Nov
19
C# 3.0 and LINQ with Visual Studio 2008 Training Course
London, United Kingdom
This course has been developed to help existing C#.NET 2.0 programmers and developers upgrade their .NET development skills and learn about the new features of Microsoft's C# 3.0 and LINQ to XML and ADO.NET using Visual Studio 2008 (currently codenamed Orcas).
Comments
Leave a comment
Sign in or Join us (it's free).