ArrayIndexOutOfBoundsException in PointOpImage#computeTile

View: New views
8 Messages — Rating Filter:   Alert me  

ArrayIndexOutOfBoundsException in PointOpImage#computeTile

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I've run into a ArrayIndexOutOfBoundsException issue that seems already discussed here, but I could not find any resolution, sorry.

The exception happens to me when I try to write a modified image to png format. The debugger shows that the cause of the problem seems to root in  the javax.media.jai.PointOpImage#computeTile code. Namely, the image dimensions are arbitrary, while computeTile tries to generate uniform 512x512 tiles, and that leads to an exception. This happens despite the fact that source cobbling is enabled (by default).

The top-level program flow is very straightforward:
RenderedImage image = imageReader.read (...);
RenderedOp improvedImage = JAI.create ("rescale", parameterBlockRescale);
IIOImage iIOImage = new IIOImage (improvedImage, null, null);
imageWriter.write (null, iIOImage, null);

The exception stack trace is as follows:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
        at sun.awt.image.ByteInterleavedRaster.getByteData(ByteInterleavedRaster.java:432)
        at sun.awt.image.ByteInterleavedRaster.getDataElements(ByteInterleavedRaster.java:347)
        at java.awt.image.BufferedImage.getData(BufferedImage.java:1411)
        at javax.media.jai.RenderedImageAdapter.getData(RenderedImageAdapter.java:158)
        at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:794)
        at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
        at javax.media.jai.OpImage.getTile(OpImage.java:1129)
        at javax.media.jai.PlanarImage.cobbleByte(PlanarImage.java:2850)
        at javax.media.jai.PlanarImage.getData(PlanarImage.java:2169)
        at javax.media.jai.RenderedOp.getData(RenderedOp.java:2276)
        at com.sun.imageio.plugins.png.PNGImageWriter.encodePass(PNGImageWriter.java:806)
        at com.sun.imageio.plugins.png.PNGImageWriter.write_IDAT(PNGImageWriter.java:930)
        at com.sun.imageio.plugins.png.PNGImageWriter.write(PNGImageWriter.java:1146)
        at test.EnhanceContrast.writeResultFile(EnhanceContrast.java:133)
        at test.EnhanceContrast.main(EnhanceContrast.java:197)

Any ideas/comments would be most appreciated.

Regards,
Sergey
[Message sent by forum member 's_ushakov' (s_ushakov)]

http://forums.java.net/jive/thread.jspa?messageID=357362

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: ArrayIndexOutOfBoundsException in PointOpImage#computeTile

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What's inside the parameterBlockRescale  parameter?
[Message sent by forum member 'power3d' (power3d)]

http://forums.java.net/jive/thread.jspa?messageID=357404

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: ArrayIndexOutOfBoundsException in PointOpImage#computeTile

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, sure :)  parameterBlockRescale is as follows:

double [] subtract = new double [1];
subtract [0] = 64.;
double []  divide = new double [1];
divide [0] = 2.;
ParameterBlock parameterBlockRescale = new ParameterBlock ();
parameterBlockRescale.add (divide);
parameterBlockRescale.add (subtract);
parameterBlockRescale.addSource (image);

Thanks,
Sergey
[Message sent by forum member 's_ushakov' (s_ushakov)]

http://forums.java.net/jive/thread.jspa?messageID=357417

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: ArrayIndexOutOfBoundsException in PointOpImage#computeTile

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi again,

well, I've got the answer myself :) There is a bug in JAI 1.1.3, as line 727 in javax.media.jai.PointOpImage reads "if (!cobbleSources) {" while it should be "if (cobbleSources) {". With this line fixed no exceptions do happen.

Regards,
Sergey
[Message sent by forum member 's_ushakov' (s_ushakov)]

http://forums.java.net/jive/thread.jspa?messageID=357531

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: ArrayIndexOutOfBoundsException in PointOpImage#computeTile

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

An easy-to-fix bug was found in JAI 1.1.3. Solution is provided.
[Message sent by forum member 's_ushakov' (s_ushakov)]

http://forums.java.net/jive/thread.jspa?messageID=357532

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: ArrayIndexOutOfBoundsException in PointOpImage#computeTile

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A patch was submitted to the Issue Tracker:
https://jai-core.dev.java.net/issues/show_bug.cgi?id=134
[Message sent by forum member 's_ushakov' (s_ushakov)]

http://forums.java.net/jive/thread.jspa?messageID=357589

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: ArrayIndexOutOfBoundsException in PointOpImage#computeTile

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Very well :D
[Message sent by forum member 'power3d' (power3d)]

http://forums.java.net/jive/thread.jspa?messageID=357702

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: ArrayIndexOutOfBoundsException in PointOpImage#computeTile

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Sergey,

If the change fixes your app that's great, but I'm trying to understand why...

Looking at the code for PointOpImage and OpImage, the original statement:
     if ( !cobbleSources )
seems to me to result in what the method docs advertise. What am I missing ?

cheers
Michael
[Message sent by forum member 'cafeanimal' (cafeanimal)]

http://forums.java.net/jive/thread.jspa?messageID=360197

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...