anastaciocintra / escpos-coffee

Java library for ESC/POS printer
https://anastaciocintra.github.io/escpos-coffee
MIT License
277 stars 72 forks source link

EscPOSImage(CoffeeImage, Bitonal) Not Woring #57

Closed Dtuzzy closed 3 years ago

Dtuzzy commented 3 years ago

The constructor EscPosImage(BufferedImage, BitonalThreshold) is undefined

This happens when I do this BufferedImage githubBufferedImage = ImageIO.read(new File("pinlogo.gif")); EscPosImage escposImage = new EscPosImage(githubBufferedImage, new BitonalThreshold());

anastaciocintra commented 3 years ago

hi @Dtuzzy, try something like this:

    public void printLogo() throws IOException {
        PrintService printService = PrinterOutputStream.getPrintServiceByName("TM-T20");
        EscPos escpos = new EscPos(new PrinterOutputStream(printService));

        BufferedImage bufferedImage = ImageIO.read(new File("/home/marco/desenv/dog.png"));
        CoffeeImage coffeeImage = new CoffeeImageImpl(bufferedImage);
        Bitonal algorithm = new BitonalOrderedDither();
        GraphicsImageWrapper imageWrapper = new GraphicsImageWrapper();
        imageWrapper.setJustification(EscPosConst.Justification.Center);
        EscPosImage escposImage = new EscPosImage(coffeeImage, algorithm);

        escpos.writeLF("Printing one image");
        escpos.write(imageWrapper, escposImage);
        escpos.feed(3).cut(EscPos.CutMode.FULL);
        escpos.close();
    }
anastaciocintra commented 3 years ago

if you are building for android, take a look at https://github.com/anastaciocintra/escpos-coffee-samples/tree/master/miscellaneous/AndroidImage

anastaciocintra commented 3 years ago

Hi @Dtuzzy , Is all right about this problem?