Package com.lightcrafts.image.types

Examples of com.lightcrafts.image.types.ImageType


            }
        }
        if (file.isFile()) {
            try {
                ImageInfo info = ImageInfo.getInstanceFor(file);
                ImageType type = info.getImageType();
                if (type instanceof RawImageType) {
                    ImageMetadata meta = info.getMetadata();
                    String make = meta.getCameraMake(true);
                    System.out.println(file.getName() + ": |" + make + "|");
                }
View Full Code Here


            //
            // We didn't get the dimensions from metadata so try to get them
            // from the image directly.
            //
            try {
                final ImageType t = imageInfo.getImageType();
                final Dimension d = t.getDimension( imageInfo );
                if ( d != null ) {
                    width = d.width;
                    height = d.height;
                }
            }
View Full Code Here

    public static ImageExportOptions read( XmlNode node )
        throws XMLException
    {
        node = node.getChild( ExportOptionsTag );
        final String typeName = node.getAttribute( TypeTag );
        final ImageType type = ImageType.getImageTypeByName( typeName );
        if ( type == null ) {
            throw new XMLException( "Unrecognized image export type" );
        }
        final ImageExportOptions options = type.newExportOptions();
        options.restore( node );
        if ( node.hasAttribute( FileTag ) ) {
            options.m_exportFile = new File( node.getAttribute( FileTag ) );
        }
        return options;
View Full Code Here

    public static Interpretation read(File file) {
        XmlDocument xmlDoc = null;
        File imageFile = null;

        ImageInfo info = ImageInfo.getInstanceFor(file);
        ImageType type;
        try {
            type = info.getImageType();
        }
        catch (IOException e) {
            return null;
View Full Code Here

    // Export an image rendering to a file
    public void write( ProgressThread thread,
                       ImageExportOptions exportOptions ) throws IOException {
        final ImageFileExportOptions fileOptions =
            (ImageFileExportOptions)exportOptions;
        final ImageType exportType = exportOptions.getImageType();
        final int exportWidth = fileOptions.resizeWidth.getValue();
        final int exportHeight = fileOptions.resizeHeight.getValue();

        final String exportProfileName = fileOptions.colorProfile.getValue();
        ICC_Profile profile =
            ColorProfileInfo.getExportICCProfileFor( exportProfileName );
        if ( profile == null )
            profile = JAIContext.sRGBExportColorProfile;

        // LZN editor state data
        final byte[] lzn = exportOptions.getAuxData();

        PlanarImage exportImage = getRendering(
            new Dimension( exportWidth, exportHeight ), profile,
            exportType instanceof JPEGImageType ||
                exportOptions.getIntValueOf(BitsPerChannelOption.NAME) == 8
        );

        // Never uprez output images.  See bug 1443.

//        double scale = Math.min(exportWidth / (double) exportImage.getWidth(),
//                                exportHeight / (double) exportImage.getHeight());
//
//        if (scale > 1) {
//            AffineTransform xform = AffineTransform.getScaleInstance(scale, scale);
//
//            RenderingHints formatHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_COPY));
//
//            Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BICUBIC_2);
//            ParameterBlock params = new ParameterBlock();
//            params.addSource(exportImage);
//            params.add(xform);
//            params.add(interp);
//            exportImage = JAI.create("Affine", params, formatHints);
//        }

        // Make sure that if uprezzing was requested and denied, the metadata
        // reflect the actual output image size
        if (fileOptions.resizeWidth.getValue() > exportImage.getWidth()) {
            fileOptions.resizeWidth.setValue(exportImage.getWidth());
        }
        if (fileOptions.resizeHeight.getValue() > exportImage.getHeight()) {
            fileOptions.resizeHeight.setValue(exportImage.getHeight());
        }
       
        if ( exportImage instanceof RenderedOp ) {
            final RenderedOp rop = (RenderedOp) exportImage;
            rop.setProperty(JAIContext.PERSISTENT_CACHE_TAG, Boolean.TRUE);
        }

        if (m_exportInfo != null) {
            exportType.putImage(
                m_exportInfo, exportImage, exportOptions, lzn, thread
            );
        }
        else {
            exportType.putImage(
                m_imageInfo, exportImage, exportOptions, lzn, thread
            );
        }
    }
View Full Code Here

     * @return Returns a new {@link ImageExportOptions}.
     */
    public ImageExportOptions readAll() throws IOException {
        final String typeName =
            m_parent.getAttribute( ImageExportOptionXMLWriter.TypeTag );
        final ImageType type = ImageType.getImageTypeByName( typeName );
        if ( type == null )
            throw new XMLException(
                "Unrecognized image export type: \"" + typeName + '"'
            );
        final ImageExportOptions options = type.newExportOptions();
        if ( m_parent.hasAttribute( ImageExportOptionXMLWriter.FileTag ) ) {
            final String exportFileName =
                m_parent.getAttribute( ImageExportOptionXMLWriter.FileTag );
            final File exportFile = new File( exportFileName );
            options.setExportFile( exportFile );
View Full Code Here

    /**
     * Tell if the given ImageMetadata points to a File containing RAW
     * image data.  Only RAW files cna have default Documents.
     */
    private static boolean isRaw(ImageMetadata meta) {
        ImageType type = meta.getImageType();
        return (type instanceof RawImageType);
    }
View Full Code Here

    private static SaveOptions createTemplateSaveOptions(
        Document doc, ImageFileExportOptions export, boolean ignoreResize
    ) {
        ImageMetadata meta = doc.getMetadata();
        File file = meta.getFile();
        ImageType type = export.getImageType();
        String ext = type.getExtensions()[0];
        file = ExportNameUtility.setFileExtension(file, ext);
        file = ExportNameUtility.ensureNotExists(file);
        if (type == LZNImageType.INSTANCE) {
            SaveOptions options = SaveOptions.createLzn(file);
            return options;
        }
        SaveOptions options;
        Engine engine = doc.getEngine();
        Dimension size = engine.getNaturalSize();

        if (type instanceof TIFFImageType) {
            options = SaveOptions.createSidecarTiff(export);
        }
        else if (type instanceof JPEGImageType) {
            options = SaveOptions.createSidecarJpeg(export);
        }
        else {
            throw new IllegalArgumentException(
                "Can't save to image type \"" + type.getName() + "\""
            );
        }
        if (ignoreResize) {
            export.resizeWidth.setValue(size.width);
            export.resizeHeight.setValue(size.height);
View Full Code Here

                                       ImageInfo imageInfo,
                                       Dimension saveSize )
        throws IOException, LightCraftsException
    {
        final ImageMetadata metadata = imageInfo.getMetadata();
        final ImageType t = imageInfo.getImageType();

        options.setExportFile( imageInfo.getFile() );

        try {
            final ICC_Profile profile = t.getICCProfile( imageInfo );
            if ( profile != null ) {
                final String profileName =
                    ColorProfileInfo.getNameOf( profile );
                options.colorProfile.setValue( profileName );
            }
View Full Code Here

        ExportFilter defaultFilter = null;

        // Set up all the image format options:
        List<ExportFilter> filters = getAllFilters();
        ImageType defaultType = options.getImageType();

        // Update the file's suffix and options when the filter changes:
        addPropertyChangeListener(
            new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent event) {
                    if (event.getPropertyName().equals(
                        JFileChooser.FILE_FILTER_CHANGED_PROPERTY
                    )) {
                        ExportFilter oldFilter =
                            (ExportFilter) event.getOldValue();
                        ExportFilter newFilter =
                            (ExportFilter) event.getNewValue();
                        fileFilterChanged(oldFilter, newFilter);
                    }
                }
            }
        );
        // Initialize all the image type filters:
        for (ExportFilter filter : filters) {
            ImageExportOptions filterOptions = filter.getExportOptions();
            ImageType filterType = filterOptions.getImageType();
            if (defaultType.equals(filterType)) {
                // For the default filter, use the default options:
                filter = new ExportFilter(options);
                defaultFilter = filter;
            }
View Full Code Here

TOP

Related Classes of com.lightcrafts.image.types.ImageType

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.