Free Support Forum - aspose.com

Need tech help with barcode demo

Received : 2008/01/08 14:51:56

hi, i'm currently testing out your demo to see if your product can solve our barcode generation needs. i've been able to successfully generate a barcode using your toolkit. However, I've noticed that I can only generate this as a java Graphic or image File. I was wondering if there was a direct way to generate the bar code as a byte array. I'm currently using the java toolkit on the 1.5x platform.
This message was posted using Aspose.Live 2 Forum

Hello chromeriver,

Thank you for using Aspose.BarCode!

I'm sorry that I'm not very clear with your requirement, could you please tell me more details? For example, what will the 'byte array' be used for? What type of data should the 'byte array' contain, image(png/jpg...) file stream or what?

Actually the BarCodeBuilder allow you to generate barcode images, paint on the specified Graphics or save to a file. In fact the BarCodeBuilder is able to generate a BufferedImage and you can get all the RGB data into an integer array, here is an example:

//...
BufferedImage bimg = (BufferedImage) b.generateBarCodeImage();
int w = bimg.getWidth();
int h = bimg.getHeight();
int[] rgb = new int[w * h];
bimg.getRGB(0, 0, w, h, rgb, 0, w);
//...

Hi, the purpose for the byte array was so that we could feed that byte array into another one of our software components, which will process the data and generate the barcode within that service.

Though I could simply convert the jpeg file or the buffered image to a byte array, I was wondering if your software provided a direct implementation to pull the data as a byte array.

I hope this clarifies my inquiry. If not, let me know

Hi chromeriver,

I think you should convert the buffered image to a byte array manually, the BarcodeBuilder doesn't have a property that returns a byte array.

Thanks