java.lang.ArithmeticException: / by zero issue.

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

java.lang.ArithmeticException: / by zero issue.

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

Reply to Author | View Threaded | Show Only this Message

Hi,

I got the following exception when i tried to create the multi page tiff file.
This error is not consistent for all images. But it is consistent for few files.

code is like this:

file = new File("sample.tif");
RenderedOp op = JAI.create("fileload", file.getAbsolutePath());
ParameterBlock pb1 = new ParameterBlock();
pb1.removeParameters();
pb1.removeSources();
pb1.addSource(op);
pb1.add((op.getWidth() * xratio) / op.getWidth());
pb1.add((op.getHeight() * yratio) / op.getHeight());
pb1.add(0.0F);
pb1.add(0.0F);
pb1.add(new InterpolationNearest());
RenderedOp rp = JAI.create("scale", pb1, null);
BufferedImage image = rp.getAsBufferedImage();

Exception:

Error: One factory fails for the operation "scale"
Occurs in: javax.media.jai.ThreadSafeOperationRegistry
java.lang.reflect.InvocationTargetException
        at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at javax.media.jai.FactoryCache.invoke(FactoryCache.java:122)
        at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1674)
        at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:473)
        at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:332)
        at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:819)
        at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)
        at javax.media.jai.RenderedOp.getColorModel(RenderedOp.java:2242)
        at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2498)
        at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2546)
        at com.hp.emsi.ftp.MultiTiff.getBufferedImage(MultiTiff.java:140)
        at com.hp.emsi.ftp.MultiTiff.createMultiPage(MultiTiff.java:76)
        at com.hp.emsi.ftp.MultiTiff.main(MultiTiff.java:244)
Caused by: java.lang.ArithmeticException: / by zero
        at com.sun.media.jai.util.Rational.ceil(Rational.java:242)
        at javax.media.jai.ScaleOpImage.layoutHelper(ScaleOpImage.java:318)
        at javax.media.jai.ScaleOpImage.<init>(ScaleOpImage.java:427)
        at com.sun.media.jai.opimage.ScaleNearestBinaryOpImage.<init>(ScaleNearestBinaryOpImage.java:68)
        at com.sun.media.jai.opimage.ScaleCRIF.create(ScaleCRIF.java:116)
        ... 15 more

Please help me to solve this issue.

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

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

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


Re: java.lang.ArithmeticException: / by zero issue.

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

Reply to Author | View Threaded | Show Only this Message

Have you look up what is in op?
Do a System.out.println(op.getWidth()) for instance.
[Message sent by forum member 'power3d' (power3d)]

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

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


Re: java.lang.ArithmeticException: / by zero issue.

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

Reply to Author | View Threaded | Show Only this Message

The op.getWidth() value of the corrupted image was 1248.
[Message sent by forum member 'sassubra' (sassubra)]

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

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


Re: java.lang.ArithmeticException: / by zero issue.

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

Reply to Author | View Threaded | Show Only this Message

pb1.add((op.getWidth() * xratio) / op.getWidth());

is the same as having

pb1.add(xratio);

because op.getWidth()/op.getWidth() equals to 1,

so you are just adding to the pb xratio and yratio.
[Message sent by forum member 'power3d' (power3d)]

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

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