Subj : Re: Printing on Commodore printer without Commodore 64 To : sblen...@gmail.com From : Rami Date : Tue May 08 2018 03:55:12 Awesome! I'll have a look as soon as possible. On Tuesday, May 8, 2018 at 12:35:42 AM UTC+3, sblen...@gmail.com wrote: > Il giorno lunedì 7 maggio 2018 15:54:00 UTC+2, sblen...@gmail.com ha scritto: > > > Printing text is quite simple. > > You can also print graphics. This is an example of what you can do: > https://imgur.com/a/gyxkkqk > > I did it writing a simple "driver" in Java that converts images (for now in black and white, with white background) into commands for the Commodore MPS 803 printer: > > > package eu.sblendorio; > > import javax.imageio.ImageIO; > import java.awt.image.*; > import java.io.File; > import java.io.IOException; > > public class Main { > > public static void main(String[] args) throws IOException { > if (args.length == 0) System.exit(1); > final String filename = args[0]; > File f = new File(filename); > BufferedImage bi = ImageIO.read(f); > > print(bi); > } > > static int getPixel(BufferedImage bi, int x, int y) { > final int w = bi.getWidth(); > final int h = bi.getHeight(); > > if (x >= w || y >= h || x < 0 || y < 0) > return 0; > > final boolean pixel = bi.getRGB(x, y) != -1; > return pixel ? 1 : 0; > } > > static void print(BufferedImage bi) { > final int pow[] = {1, 2, 4, 8, 16, 32, 64}; > final int w = bi.getWidth(); > final int h = bi.getHeight(); > int rows = h / 7 + (h % 7 == 0 ? 0 : 1); > System.out.write(8); > for (int row=0; row for (int x=0; x int code = 128; > for (int dy=0; dy<7; ++dy) { > final int pixel = getPixel(bi, x,(row * 7) + dy); > code += pow[dy]*pixel; > } > System.out.write(code); > } > System.out.write(13); > } > System.out.write(15); > System.out.write(13); > } > } --- SoupGate-Win32 v1.05 * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3) .