![]() Vom Tiptoi-Tool erstelltes OID-Bild nach Ausdruck auf günstigem Drucker. Der Stift erkennt das Bild nur schlecht. |
![]() Das OID-Bild mit vier Pixeln statt einem. Der Stift erkennt das Bild gut, auch wenn einige Punkte dicker sind als die anderen. |
Oggdrop XPd
tttool assemble buch.yaml
tttool oid-code buch.yaml
java -Xmx1G -jar stitcher.jar .
stitched.png
auf DIN A4 ausdrucken und ausschneidenimport java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileFilter; import java.io.IOException; import javax.imageio.ImageIO; /** * ImageStitcher. Benutzung auf eigene Gefahr. */ public class ImageStitcher { private static final String IMAGE_FILENAME_SUFFIX = ".png"; private static final String IMAGE_FILENAME_PREFIX = "oid-"; // approximately DIN A4 with 1200 dpi private static final int PAGE_WIDTH = 10000; private static final int PAGE_HEIGHT = 14000; private static final int TILE_WIDTH = 1200; private static final int TILE_HEIGHT = 1200; /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // check arguments if (args == null || args.length == 0 || args.length != 1){ System.out.println("Usage: ImageStitcher PathToImageDir"); return; } // check given directory File dir = new File(args[0]); if (!dir.exists() || !dir.isDirectory()){ System.out.println("Error: "+dir.getAbsolutePath()+" is not a directory!"); return; } // list pngs File[] imageFiles = dir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { if (pathname.getName().contains("table")){ return false; } return (pathname.getName().startsWith(IMAGE_FILENAME_PREFIX)) && (pathname.getName().endsWith(IMAGE_FILENAME_SUFFIX)); } }); if (imageFiles == null || imageFiles.length == 0){ System.out.println("Error: Could not find images with name oid-*.png"); return; } createAndWriteImage(dir, imageFiles); } private static void createAndWriteImage(File dir, File[] imageFiles) throws IOException { BufferedImage off_Image = new BufferedImage(PAGE_WIDTH, PAGE_HEIGHT, BufferedImage.TYPE_BYTE_BINARY); Graphics2D g2 = off_Image.createGraphics(); g2.setColor(Color.WHITE); g2.fillRect(0, 0, PAGE_WIDTH, PAGE_HEIGHT); g2.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 60)); g2.setColor(Color.BLACK); for (int i=0; i < imageFiles.length; i++){ int y = i / 4; int x = i % 4; File imageFile = imageFiles[i]; BufferedImage img = ImageIO.read(imageFile); System.out.println("Working on "+imageFile.getAbsolutePath()+"..."); if (img == null){ System.out.println("Error: Could not read image "+imageFile.getAbsolutePath()+"!"); continue; } int px = 200 + x * 2000; int py = 200 + y * 1400; g2.drawString(imageFile.getName(), px, py - 100); g2.drawImage(img, px, py, px+TILE_WIDTH, py+TILE_HEIGHT, 0, 0, TILE_WIDTH, TILE_HEIGHT, null); g2.drawImage(img, px+1, py, px+1+TILE_WIDTH, py+TILE_HEIGHT, 0, 0, TILE_WIDTH, TILE_HEIGHT, null); g2.drawImage(img, px, py+1, px+TILE_WIDTH, py+1+TILE_HEIGHT, 0, 0, TILE_WIDTH, TILE_HEIGHT, null); g2.drawImage(img, px+1, py+1, px+1+TILE_WIDTH, py+1+TILE_HEIGHT, 0, 0, TILE_WIDTH, TILE_HEIGHT, null); img = null; } // write output File outputfile = new File(dir, "stitched.png"); ImageIO.write(off_Image, "png", outputfile); } }