Package com.lightcrafts.mediax.jai.util

Examples of com.lightcrafts.mediax.jai.util.ImagingException


            stream.read(b);
            stream.read(); // CR
            stream.read(); // LF
        } catch(Exception e) {
            String message = JaiI18N.getString("IIPResolution7");
            listener.errorOccurred(message, new ImagingException(message,e),
                                   IIPResolutionOpImage.class, false);
//            throw new RuntimeException(e.getClass()+" "+e.getMessage());
        }

        return b;
View Full Code Here


                stream.read(); // CR
                stream.read(); // LF
                str = new String(b);
            } catch(Exception e) {
                String message = JaiI18N.getString("IIPResolution7");
                listener.errorOccurred(message, new ImagingException(message,e),
                                       IIPResolutionOpImage.class, false);
//                throw new RuntimeException(e.getClass()+" "+e.getMessage());
            }
        } else {
            StringBuffer buf = new StringBuffer(16);
            try {
                int i;
                while((i = stream.read()) != -1) {
                    char c = (char)(0x000000ff&i);
                    if(c == CR) { // if last byte was CR
                        stream.read(); // LF
                        break;
                    }
                    buf.append(c);
                }
                str = buf.toString();
            } catch(Exception e) {
                String message = JaiI18N.getString("IIPResolution7");
                listener.errorOccurred(message, new ImagingException(message,e),
                                       IIPResolutionOpImage.class, false);
//                throw new RuntimeException(e.getClass()+" "+e.getMessage());
            }
        }
View Full Code Here

                    stream.read(); // CR
                    stream.read(); // LF
                }
            } catch(Exception e) {
                String message = JaiI18N.getString("IIPResolution8");
                listener.errorOccurred(message, new ImagingException(message,e),
                                       IIPResolutionOpImage.class, false);
//                throw new RuntimeException(e.getClass()+" "+e.getMessage());
            }
        } else {
            try {
                int i;
                while((i = stream.read()) != -1) {
                    if((char)(0x000000ff&i) == CR) { // if last byte was CR
                        stream.read(); // LF
                        break;
                    }
                }
            } catch(Exception e) {
                String message = JaiI18N.getString("IIPResolution8");
                listener.errorOccurred(message, new ImagingException(message,e),
                                       IIPResolutionOpImage.class, false);
//                throw new RuntimeException(e.getClass()+" "+e.getMessage());
            }
        }
    }
View Full Code Here

        } catch(Exception e) {

            ImagingListener listener =
                ImageUtil.getImagingListener(renderHints);
            listener.errorOccurred(JaiI18N.getString("IIPResolutionOpImage3"),
                                   new ImagingException(e),
                                   this, false);
/*
            String msg = JaiI18N.getString("IIPResolutionOpImage3")+" "+
                e.getMessage();
            throw new RuntimeException(msg);
View Full Code Here

        try {
            this.i_transform = transform.createInverse();
        } catch (Exception e) {
            String message = JaiI18N.getString("AffineOpImage0");
            listener.errorOccurred(message,
                                   new ImagingException(message, e),
                                   this, false);
//            throw new RuntimeException(JaiI18N.getString("AffineOpImage0"));
        }
        this.f_transform = (AffineTransform)transform.clone();
View Full Code Here

        try {
            at.preConcatenate(scale.createInverse());
        } catch(Exception e) {
            String message = JaiI18N.getString("IIPCRIF6");
            listener.errorOccurred(message,
                                   new ImagingException(message, e),
                                   this, false);
//            throw new RuntimeException(JaiI18N.getString("IIPCRIF6"));
        }

        // Compose the inverse residual mapping with the renderable
        // transform.
        AffineTransform afn =
            (AffineTransform)paramBlock.getObjectParameter(6);
        try {
            afn.preConcatenate(at.createInverse());
        } catch(Exception e) {
            String message = JaiI18N.getString("IIPCRIF6");
            listener.errorOccurred(message,
                                   new ImagingException(message, e),
                                   this, false);
//            throw new RuntimeException(JaiI18N.getString("IIPCRIF6"));
        }

        if(isFull) {
            // Append the WID and HEI composed image command modifiers using
            // the dimensions of the rendered destination region of interest.
            buf.append("&WID="+dstROI.width+"&HEI="+dstROI.height);
            /* XXX Begin suppressed section.
        } else if((opMask & MASK_TRANSFORM) != 0) {
            Point2D[] dstPts =
                new Point2D[] {new Point2D.Double(rgn.getMinX(),
                                                  rgn.getMinY()),
                                   new Point2D.Double(rgn.getMaxX(),
                                                      rgn.getMinY()),
                                   new Point2D.Double(rgn.getMinX(),
                                                      rgn.getMaxY())};
            Point2D[] srcPts = new Point2D[3];
            afn.transform(dstPts, 0, srcPts, 0, 3);

            double LLeft = srcPts[0].distance(srcPts[2]);
            double LTop = srcPts[0].distance(srcPts[1]);

            int[] maxSize = (int[])lowRes.getProperty("max-size");

            double H = maxSize[1]*LLeft;
            double W = maxSize[1]*LTop;

            double m = Math.max(H, W*(double)maxSize[1]/(double)maxSize[0]);

            int Hp = (int)(m + 0.5);
            int Wp = (int)(m*(double)maxSize[0]/(double)maxSize[1] + 0.5);
            System.out.println("Estimated dimensions = "+Wp+" x "+Hp);

            AffineTransform scl =
                AffineTransform.getScaleInstance(dstROI.getWidth()/Wp,
                                                 dstROI.getHeight()/Hp);
            System.out.println("scl = "+scl);
            afn.preConcatenate(scl);
            End suppressed section. XXX */
        }


        // Append the affine tranform composed image command.
        double[] matrix = new double[6];
        afn.getMatrix(matrix);
        buf.append("&AFN="+
                   matrix[0]+","+matrix[2]+",0,"+matrix[4]+","+
                   matrix[1]+","+matrix[3]+",0,"+matrix[5]+
                   ",0,0,1,0,0,0,0,1");

        // Destination aspect ratio.
        if((opMask & MASK_ASPECT_RATIO) != 0) {
            buf.append("&RAR="+paramBlock.getFloatParameter(7));
        }

        // Destination rectangle of interest.
        if((opMask & MASK_ROI_DESTINATION) != 0) {
            Rectangle2D dstRGN =
                (Rectangle2D)paramBlock.getObjectParameter(8);
            buf.append("&RGN="+dstRGN.getX()+","+ dstRGN.getY()+","+
                       dstRGN.getWidth()+","+dstRGN.getHeight());
        }

        // Rotation and mirroring.
        if(isFull) {
            if((opMask & MASK_ROTATION) != 0 ||
               (opMask & MASK_MIRROR_AXIS) != 0) {
                buf.append("&RFM="+paramBlock.getIntParameter(9));
                if((opMask & MASK_MIRROR_AXIS) != 0) {
                    String axis = (String)paramBlock.getObjectParameter(10);
                    if(axis.equalsIgnoreCase("x")) {
                        buf.append(",0");
                    } else {
                        buf.append(",90");
                    }
                }
            }
        }

        // ICC profile.
        if((opMask & MASK_ICC_PROFILE) != 0) {
            // According to the IIP specification this is not supported
            // over HTTP connections and that is all that is available from
            // the vendors right now, i.e., no socket connections are
            // available (includes LivePicture and TrueSpectra).
        }

        // JPEG quality and compression group index.
        if(isJPEG) {
            if((opMask & MASK_JPEG_QUALITY) != 0) {
                buf.append("&QLT="+paramBlock.getIntParameter(12));
            }

            if((opMask & MASK_JPEG_TABLE) != 0) {
                buf.append("&CIN="+paramBlock.getIntParameter(13));
            }
        }

        // Set the format string.
        String format = isJPEG ? "JPEG" : "FPX";

        // Append the CVT command.
        buf.append("&CVT="+format);

        // Create a URL with the CVT string, open a stream from it, and
        // decode the image using the appropriate decoder.
        InputStream stream = null;
        RenderedImage rendering = null;
        try {
            URL url = new URL(buf.toString());
            stream = url.openStream();
            MemoryCacheSeekableStream sStream =
                new MemoryCacheSeekableStream(stream);
            rendering = JAI.create(format, sStream);
        } catch(Exception e) {
            String message =
                JaiI18N.getString("IIPCRIF7") + " " + buf.toString();
            listener.errorOccurred(message,
                                   new ImagingException(message, e),
                                   this, false);
//            throw new RuntimeException(e.getClass()+" "+e.getMessage());
        }

        // If WID and HEI modifiers are unavailable add scale.
View Full Code Here

                    try {
                    at = at.createInverse();
                    } catch(Exception e) {
                        String message = JaiI18N.getString("IIPCRIF6");
                        listener.errorOccurred(message,
                                               new ImagingException(message, e),
                                               this, false);

//                        throw new RuntimeException(JaiI18N.getString("IIPCRIF6"));
                    }
                }
View Full Code Here

TOP

Related Classes of com.lightcrafts.mediax.jai.util.ImagingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.