RE: Speeding up Image generating rate.

"Yossi Baram" <[email protected]>
Newsgroups gmane.comp.krysalis.devel
Message-ID <[email protected]>
 Jeremias,
I take it back.
The changes you advised me of made agreat change with speed.
Thanks a lot mate.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jeremias Maerki
Sent: Wednesday, June 02, 2004 13:32
To: [email protected]
Cc: [email protected]
Subject: Re: Speeding up Image generating rate.

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
_______________________________________________
Krysalis-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/krysalis-developers




-------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.