PNG native acceleration

I am trying native acceleration using JAI and/or Image I/O tools.

I am using the following code:

ImageIO.write(image, "png", outputStream);

So, i installed JAI I/O Tools to my JRE, it works like a charm with native acceleration without any code modification.

Now, I want to start using JAI, so I replaced the code with:

JAI.create("encode", image, outputStream, "png");

So, this time I installed JAI to my JRE, it created the PNG image but without native acceleration. I started to investigate further ... so i tried,

JAI.create("encode", image, outputStream, "jpeg");

JAI.create("encode", image, outputStream, "bmp");

Both the jpeg/bmp formats worked like a charm and with native acceleration.

Does anybody know if "png" native acceleration is supported in JAI (documents says supported)? Or do I have to do something special in order to work with "png" format? Either by changing the code or installing something else?

Thanks!

[1001 byte] By [shahkun3a] at [2007-10-3 7:13:35]
# 1

To enable native acceleration from JAI you need to but the binary libraries in your PATH or LD_LIBRARY_PATH (depending on operating system).

Then you need to use the "ImageWrite" operation to invoke the JAI-ImageIO code. Otherwise you are using the unsupported JAI codecs. Using "ImageWrite" causes JAI to delegate to the ImageIO stuff (Which I believe is what you want).

Cheers

matfud

matfuda at 2007-7-15 2:09:49 > top of Java-index,Security,Cryptography...
# 2

Thanks for the information regarding "ImageWrite"! So, following is what I am doing now and it's working.

ParameterBlock block = new ParameterBlock();

block.add(outputStream);

block.add(IMAGE_TYPE);

block.add(new Boolean(true));

block.add(new Boolean(true));

block.add(new Boolean(true));

block.add(new Boolean(false));

block.add(null);

block.add(null);

block.add(null);

block.add(null);

block.add(null);

block.add(null);

block.add(null);

block.add(null);

block.addSource(image);

JAI.create("ImageWrite", block);

If you are back on this forum, can you please write some tips to improve the following code!

Thanks again!

shahkun3a at 2007-7-15 2:09:49 > top of Java-index,Security,Cryptography...
# 3

You will have to explain how it is not working (no file written, wrong file format, exception thrown). Perhaps post some more code.

In addition you might want to use the ParameterBlockJAI rather then ParameterBlock. It gets all the defaults automatically. You should probably also set parameters on the parameter block by name to make it clearer what you are doing.

cheers

matfud

matfuda at 2007-7-15 2:09:49 > top of Java-index,Security,Cryptography...
# 4

Sorry if I confused you. The above code works.

I was looking for suggestions like you made one, use ParameterBlockJAI. Code looks pretty now!

ParameterBlockJAI block = new ParameterBlockJAI("ImageWrite");

block.setParameter("Output", outputStream);

block.setParameter("Format", IMAGE_TYPE);

block.addSource(image);

JAI.create("ImageWrite", block);

Thanks!

shahkun3a at 2007-7-15 2:09:49 > top of Java-index,Security,Cryptography...
# 5
my pleasurematfud
matfuda at 2007-7-15 2:09:49 > top of Java-index,Security,Cryptography...