Packages

 

com.aspose.imaging.fileformats.cdr

Class CdrImage

  • All Implemented Interfaces:
    ICdrImage, IMultipageImage, IObjectWithSizeF, IObjectWithBounds, com.aspose.internal.progressmanagement.IProgressEventHandler, com.aspose.internal.progressmanagement.IProgressInformer, com.aspose.ms.System.IDisposable, Closeable, AutoCloseable


    public class CdrImage
    extends VectorMultipageImage
    implements ICdrImage

    The Cdr image.

    See Also:
    Image, ICdrImage
    Code example:

    The following example shows how to cache all pages of a CDR image.


    String dir = "c:\\temp\\";
    
    // Load an image from a CDR file.
    com.aspose.imaging.fileformats.cdr.CdrImage image = (com.aspose.imaging.fileformats.cdr.CdrImage) com.aspose.imaging.Image.load(dir + "sample.cdr");
    try {
        // This call caches only the default page.
        image.cacheData();
    
        // Cache all pages so that no additional data loading will be performed from the underlying data stream.
        for (com.aspose.imaging.fileformats.cdr.CdrImagePage page : image.getPages()) {
            page.cacheData();
        }
    } finally {
        image.dispose();
    }
    

    • Constructor Detail

      • CdrImage

        public CdrImage(InputStream stream,
                        LoadOptions loadOptions)

        Initializes a new instance of the CdrImage class.

        Parameters:
        stream - The stream.
        loadOptions - The load options.
        Throws:
        com.aspose.ms.System.IndexOutOfRangeException - This document not be contained pages
      • CdrImage

        public CdrImage(com.aspose.ms.System.IO.Stream stream,
                        LoadOptions loadOptions)
    • Method Detail

      • isCached

        public boolean isCached()

        Gets a value indicating whether object's data is cached currently and no data readig is required.

        Overrides:
        isCached in class VectorMultipageImage
        Returns:
        a value indicating whether object's data is cached currently and no data reading is required.
      • getBitsPerPixel

        public int getBitsPerPixel()

        Gets the image bits per pixel count.

        Overrides:
        getBitsPerPixel in class VectorMultipageImage
        Returns:
        the image bits per pixel count.
      • getPages

        public final Image[] getPages()

        Gets the pages.

        Specified by:
        getPages in interface IMultipageImage
        Specified by:
        getPages in class VectorMultipageImage
        Returns:
        the pages.
        Code example:

        The following example shows how to export a single page of CDR document to PDF.


        int pageNumber = 0;
        String dir = "c:\\aspose.imaging\\java\\issues\\1445'\\";
        String inputCdrFileName = dir + "tiger.cdr";
        String outputPdfFileName = dir + "tiger.cdr.page" + pageNumber + ".pdf";
        
        com.aspose.imaging.fileformats.cdr.CdrImage image = (com.aspose.imaging.fileformats.cdr.CdrImage) com.aspose.imaging.Image.load(inputCdrFileName);
        try {
            com.aspose.imaging.Image imagePage = image.getPages()[pageNumber];
        
            com.aspose.imaging.imageoptions.PdfOptions pdfOptions = new com.aspose.imaging.imageoptions.PdfOptions();
            com.aspose.imaging.imageoptions.CdrRasterizationOptions rasterizationOptions = new com.aspose.imaging.imageoptions.CdrRasterizationOptions();
            rasterizationOptions.setTextRenderingHint(com.aspose.imaging.TextRenderingHint.SingleBitPerPixel);
            rasterizationOptions.setSmoothingMode(com.aspose.imaging.SmoothingMode.None);
            rasterizationOptions.setPageWidth(image.getWidth());
            rasterizationOptions.setPageHeight(image.getHeight());
        
            pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
        
            imagePage.save(outputPdfFileName, pdfOptions);
        }
        finally {
            image.close();
        }
        

      • getFileFormat

        public long getFileFormat()

        Gets a value of file format

        Overrides:
        getFileFormat in class Image
        Returns:
        a value of file format
      • cacheData

        public void cacheData()

        Caches the data and ensures no additional data loading will be performed from the underlying DataStreamSupporter.DataStreamContainer(DataStreamSupporter.getDataStreamContainer()/DataStreamSupporter.setDataStreamContainer_internalized(com.aspose.imaging.StreamContainer)).

        Overrides:
        cacheData in class VectorMultipageImage
        Code example:

        The following example shows how to cache all pages of a CDR image.


        String dir = "c:\\temp\\";
        
        // Load an image from a CDR file.
        com.aspose.imaging.fileformats.cdr.CdrImage image = (com.aspose.imaging.fileformats.cdr.CdrImage) com.aspose.imaging.Image.load(dir + "sample.cdr");
        try {
            // This call caches only the default page.
            image.cacheData();
        
            // Cache all pages so that no additional data loading will be performed from the underlying data stream.
            for (com.aspose.imaging.fileformats.cdr.CdrImagePage page : image.getPages()) {
                page.cacheData();
            }
        } finally {
            image.dispose();
        }
        

      • resize

        public void resize(int newWidth,
                           int newHeight,
                           int resizeType)

        Resizes the image.

        Overrides:
        resize in class VectorMultipageImage
        Parameters:
        newWidth - The new width.
        newHeight - The new height.
        resizeType - The resize type.
        Throws:
        com.aspose.ms.System.NotImplementedException - method is not supported
      • resize

        public void resize(int newWidth,
                           int newHeight,
                           ImageResizeSettings settings)

        Resizes the image.

        Overrides:
        resize in class VectorMultipageImage
        Parameters:
        newWidth - The new width.
        newHeight - The new height.
        settings - The resize settings.
        Throws:
        com.aspose.ms.System.NotImplementedException - method is not supported
      • rotateFlip

        public void rotateFlip(int rotateFlipType)

        Rotates, flips, or rotates and flips the image.

        Overrides:
        rotateFlip in class VectorMultipageImage
        Parameters:
        rotateFlipType - Type of the rotate flip.
        Throws:
        com.aspose.ms.System.NotImplementedException - method is not supported
      • setPalette

        public void setPalette(IColorPalette palette,
                               boolean updateColors)

        Sets the image palette.

        Overrides:
        setPalette in class VectorMultipageImage
        Parameters:
        palette - The palette to set.
        updateColors - if set to true colors will be updated according to the new palette; otherwise color indexes remain unchanged. Note that unchanged indexes may crash the image on loading if some indexes have no corresponding palette entries.
        Throws:
        com.aspose.ms.System.NotImplementedException - method is not supported