Re: Speeding up Image generating rate.
Jeremias Maerki <[email protected]>
| Newsgroups | gmane.comp.krysalis.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Yossi,
I see three easy possibilities:
1. Buffer your FileOutputStream by wrapping it in a BufferedOutputStream.
2. Don't recreate the configuration and logger each time you create a
barcode. And you can reuse the BarcodeGenerator instance. Only the
CanvasProvider has to be recreated.
3. Use a different output format than JPEG which is quite slow. JPEG
uses a lossy compression algorithm which results in less-than-ideal
quality of the generated barcodes. I'd use PNG, TIFF or GIF.
Then you could modify the source code to cache the BufferedImage
instances. If you create 20'000 images you allocate and dismiss a lot of
memory.
If you really want to squeeze out everything you will have to use a
profiler to narrow down any other opportunities for improvement. I will
gladly incorporate any improvements you find into the package.
I hope this helps.
On 02.06.2004 11:51:08 Yossi Baram wrote:
> hi,
> I have a function that creates a barcode image.
>
>
> public boolean setBarcodeImage(String imgStr,int barCodeType,String imageName){
> boolean succeed=true;
> try {
> DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
> Configuration cfg = builder.buildFromFile(new File("barcode-EAN13-cfg.xml"));
> Logger log = new NullLogger();
> BarcodeGenerator gen = BarcodeUtil.getInstance().createBarcodeGenerator( cfg, log );
> OutputStream out = new FileOutputStream(new File(imageName));
> BitmapCanvasProvider provider = new BitmapCanvasProvider(
> out, "image/jpeg", 100, BufferedImage.TYPE_BYTE_GRAY, true);
>
> if(imgStr.equals(null))
> {
> imgStr = "0000000000000";
> }
> gen.generateBarcode(provider, imgStr);
> provider.finish();
> } catch (Exception e) {
> succeed=false;
> System.out.println("Error creating Image: " + e);
> }
> return succeed;
> }
>
> My big problem is the speed.
> The rate of borcode images generation is 200 for 1 min.
> It is very slow(I have ~ 20,000 images and more to create for integrating into a report).
> Can I speed up the proccess?
> Please advise.
Jeremias Maerki
-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504