Package com.lightcrafts.image

Examples of com.lightcrafts.image.BadImageFileException


                    && image.getTileHeight() == JAIContext.TILE_HEIGHT;

            return image;
        }
        catch ( LCImageLibException e ) {
            throw new BadImageFileException( imageInfo.getFile(), e );
        }
    }
View Full Code Here


        catch ( Exception e ) {
            //
            // Assume that any exception generated by the above is because the
            // image is corrupt.
            //
            throw new BadImageFileException( e );
        }
        final InputStream is = new ByteArrayInputStream( imageBuf );
        return getImageFromInputStream( is, cs, maxWidth, maxHeight );
    }
View Full Code Here

        catch ( Exception e ) {
            //
            // Assume that any other exception generated by the above is
            // because the image is corrupt.
            //
            throw new BadImageFileException( e );
        }
    }
View Full Code Here

     * @param imageInfo The image to read the metadata from.
     */
    public void readMetadata( ImageInfo imageInfo )
        throws BadImageFileException, IOException, UnknownImageTypeException
    {
        BadImageFileException exceptionOnHold = null;

        ////////// EXIF

        final ByteBuffer exifSegBuf = getFirstSegment(
            imageInfo, JPEG_APP1_MARKER, new EXIFJPEGSegmentFilter()
View Full Code Here

     * header isn't as it's expected to be.
     */
    protected void readHeader() throws BadImageFileException, IOException {
        m_buf.position( 0 );
        if ( m_buf.remaining() < TIFF_HEADER_SIZE )
            throw new BadImageFileException( m_imageInfo.getFile() );
        final int byteOrder = m_buf.getShort();
        if ( byteOrder == TIFF_LITTLE_ENDIAN )
            m_buf.order( ByteOrder.LITTLE_ENDIAN );
        else if ( byteOrder == TIFF_BIG_ENDIAN )
            m_buf.order( ByteOrder.BIG_ENDIAN );
        else
            throw new BadImageFileException( m_imageInfo.getFile() );
        //
        // The TIFF/EP specification allows values >= 42.
        //
        if ( m_buf.getUnsignedShort() < TIFF_MAGIC_NUMBER )
            throw new BadImageFileException( m_imageInfo.getFile() );
    }
View Full Code Here

            FileChannel c = s.getChannel();

            if (file.length() != totalData + c.position()) {
                c.close();
                throw new BadImageFileException(file);
            }

            ByteBuffer bb = c.map(FileChannel.MapMode.READ_ONLY, c.position(), totalData);

            if (dataType == DataBuffer.TYPE_USHORT) {
                bb.order(ByteOrder.BIG_ENDIAN);
                bb.asShortBuffer().get((short[]) imageData.data);
            } else
                bb.get((byte[]) imageData.data);

            if (bb instanceof DirectBuffer)
                ((DirectBuffer) bb).cleaner().clean();

            c.close();
        } catch (Exception e) {
            e.printStackTrace();
            s.close();
            throw new BadImageFileException(file, e);
        } finally {
            s.close();
        }

        return imageData;
View Full Code Here

            System.out.println("dcraw value: " + m_error);

            if (m_error > 0) {
                of.delete();
                throw new BadImageFileException(of);
            }

            if (!ofName.equals(of.getPath())) {
                of.delete();
                of = new File(ofName);
            }

            if (of.getName().endsWith(".jpg") || of.getName().endsWith(".tiff")) {
                if (of.getName().endsWith(".jpg")) {
                    try {
                        LCJPEGReader jpegReader = new LCJPEGReader(of.getPath());
                        result = jpegReader.getImage();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    try {
                        LCTIFFReader tiffReader = new LCTIFFReader(of.getPath());
                        result = tiffReader.getImage(null);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                long t2 = System.currentTimeMillis();

                int totalData = result.getWidth() *
                                result.getHeight() *
                                result.getColorModel().getNumColorComponents() *
                                (result.getColorModel().getTransferType() == DataBuffer.TYPE_BYTE ? 1 : 2);

                System.out.println("Read " + totalData + " bytes in " + (t2 - t1) + "ms");
            } else {
                ImageData imageData;
                try {
                    imageData = readPPM(of);
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new BadImageFileException(of, e);
                }

                // do not change the initial image geometry
                // m_width = Math.min(m_width, imageData.width);
                // m_height = Math.min(m_height, imageData.height);
View Full Code Here

TOP

Related Classes of com.lightcrafts.image.BadImageFileException

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.