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
-
How to optimize mysql subquery performance?
by Jayaram P (0 replies)
-
C# video Editing/rendering
by pkuchaliya (0 replies)
-
How to Fill DataSet with more records (around 1 lakh) in a faster way
by Jayaram P (0 replies)
-
Can't print on the network with MSADESS ??
by anatha1 (2 replies)
-
Very Urgent regarding deleting the images from a folder
by Nanosteps (6 replies)
Related podcasts
-
Object-Oriented Programming in Ruby
In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...
This thread is for discussions of Image to HTML.