0

i have a small problem. I successfully generated a barcode using barbecue library but i'm trying to print on a paper of size 99x210 and unfortunately i can't resize the barcode. It's too big.

I'm generating like this

try {
    Barcode barcode = BarcodeFactory.createCode128("630798898");
    Image image = BarcodeImageHandler.getImage(barcode);
    g2d.drawImage(image, 30,100, this );
} catch (OutputException | BarcodeException e) {
    e.printStackTrace();
}

I used something like this

    BufferedImage buffered = (BufferedImage) image;
                    Scalr.resize(buffered,
                            Scalr.Method.SPEED,
                            Scalr.Mode.AUTOMATIC,
                            50,
                            5);

but its not doing job :/

I tried to set height and width of whole barcode by using setBarHeight, setBarWidth, setResolution but it's working too.

Jim.D
  • 17
  • 7
  • 1
    Convert the `Image` to a `BufferedImage`, [for example](https://stackoverflow.com/questions/13605248/java-converting-image-to-bufferedimage) and [example](https://stackoverflow.com/questions/9132149/how-to-convert-buffered-image-to-image-and-vice-versa); scale the image, [for example](https://stackoverflow.com/questions/11959758/java-maintaining-aspect-ratio-of-jpanel-background-image/11959928#11959928) and [example](https://stackoverflow.com/questions/14115950/quality-of-image-after-resize-very-low-java/14116752#14116752) – MadProgrammer Oct 29 '17 at 21:51
  • Why do it this way? Because the resulting quality of the image is better then simply using something like `Image#getScaledInstance` – MadProgrammer Oct 29 '17 at 21:52

0 Answers0