Конвертируем GIF/JPG в HTML
Очень забавная программка. Конвертирует изображение картинки .GIF/.JPG в HTML формат :)
import java.awt.*; import java.awt.image.*; import java.io.*; import java.awt.event.*;
public static void writeToFn(String fn,String Dbytes,String status) { try { System.out.println(Dbytes + " pixel " + status); DataOutputStream dos = new DataOutputStream( new FileOutputStream(fn,true)); dos.writeBytes(Dbytes); // dos.writeByte(13); // line feed for each line dos.writeByte(10); // line feed for each line // close here dos.close(); } catch (IOException e) { System.err.println("File error: " + e.getMessage()); } } public static void writeToFn(String fn,String Dbytes) { try { System.out.println(Dbytes ); DataOutputStream dos = new DataOutputStream( new FileOutputStream(fn,true)); dos.writeBytes(Dbytes); // dos.writeByte(13); // line feed for each line dos.writeByte(10); // line feed for each line // close here dos.close(); } catch (IOException e) { System.err.println("File error: " + e.getMessage()); } } public boolean processFile(String fn) { boolean OK=false; int exitcounter; try { im = getToolkit().getImage(fn); } catch (Exception e) { System.out.println("1HOLY MOLY THIS NEVER HAPPENS!!!! "+e); } MediaTracker tracker= new MediaTracker(this); tracker.addImage(im,0); try { tracker.waitForID(0); } catch (InterruptedException e) { System.out.println("2HOLY MOLY THIS NEVER HAPPENS "+e); } if (tracker.isErrorID(0)) { System.out.println("IMAGE FILE COULD NOT BE LOADED"); System.out.println(fn); } else { exitcounter=0; while ( ((W==-1)//(H==-1)) && (exitcounter<=16000000) ) { W=im.getWidth(null); H=im.getHeight(null); exitcounter++; } if (exitcounter>15999999) { System.out.println("Timeout attempting to load image, is it to big?"); } else { OK=true; } } return(OK); }
public static void usage() { System.out.println("Usage:"); System.out.println("java img2html infile outfile "); System.out.println(" infile : image file .gif "); System.out.println(" outfile : html file to be created"); //System.out.println(" /i : Inverse data "); } } // end of class
Страница сайта http://silicontaiga.ru
Оригинал находится по адресу http://silicontaiga.ru/home.asp?artId=5371 |