CdrImage

Inheritance: java.lang.Object, com.aspose.imaging.DisposableObject, com.aspose.imaging.DataStreamSupporter, com.aspose.imaging.Image, com.aspose.imaging.VectorImage, com.aspose.imaging.VectorMultipageImage

All Implemented Interfaces: com.aspose.imaging.fileformats.cdr.ICdrImage

public class CdrImage extends VectorMultipageImage implements ICdrImage

The Cdr image.

Constructors

ConstructorDescription
CdrImage(InputStream stream, LoadOptions loadOptions)Initializes a new instance of the CdrImage class.
CdrImage(System.IO.Stream stream, LoadOptions loadOptions)

Methods

MethodDescription
getDefaultPage()Gets the default page.
isCached()Gets a value indicating whether object’s data is cached currently and no data reading is required.
getBitsPerPixel()Gets the image bits per pixel count.
getWidth()Gets the image width.
getHeight()Gets the image height.
getPageCount()Gets the page count.
getPages()Gets the pages.
getCdrDocument()Gets the CDR document.
getFileFormat()Gets a value of file format
getPageExportingAction()Gets the page exporting action.
setPageExportingAction(PageExportingAction value)Sets the page exporting action.
getDefaultOptions(Object[] args)Gets the default options.
cacheData()Caches the data and ensures no additional data loading will be performed from the underlying DataStreamSupporter.DataStreamContainer(DataStreamSupporter.getDataStreamContainer).
resize(int newWidth, int newHeight, int resizeType)Resizes the image.
resize(int newWidth, int newHeight, ImageResizeSettings settings)Resizes the image.
rotateFlip(int rotateFlipType)Rotates, flips, or rotates and flips the image.
setPalette(IColorPalette palette, boolean updateColors)Sets the image palette.

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();
}

CdrImage(InputStream stream, LoadOptions loadOptions)

public CdrImage(InputStream stream, LoadOptions loadOptions)

Initializes a new instance of the CdrImage class.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamThe stream.
loadOptionsLoadOptionsThe load options.

CdrImage(System.IO.Stream stream, LoadOptions loadOptions)

public CdrImage(System.IO.Stream stream, LoadOptions loadOptions)

Parameters:

ParameterTypeDescription
streamcom.aspose.ms.System.IO.Stream
loadOptionsLoadOptions

getDefaultPage()

public Image getDefaultPage()

Gets the default page.

Returns: Image - the default page.

isCached()

public boolean isCached()

Gets a value indicating whether object’s data is cached currently and no data reading is required.

Returns: boolean

getBitsPerPixel()

public int getBitsPerPixel()

Gets the image bits per pixel count.

Returns: int - the image bits per pixel count.

getWidth()

public int getWidth()

Gets the image width.

Returns: int - the image width.

getHeight()

public int getHeight()

Gets the image height.

Returns: int - the image height.

getPageCount()

public final int getPageCount()

Gets the page count.

Returns: int - the page count.

getPages()

public final Image[] getPages()

Gets the pages.

Returns: com.aspose.imaging.Image[] - the pages.

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();
}

getCdrDocument()

public final CdrDocument getCdrDocument()

Gets the CDR document.

Returns: CdrDocument - the CDR document.

getFileFormat()

public long getFileFormat()

Gets a value of file format

Returns: long - a value of file format

getPageExportingAction()

public PageExportingAction getPageExportingAction()

Gets the page exporting action. Please note that setting this method will automatically release page resources after it is executed. It will be executed just before each page is saved.

Value: The page exporting action.

Returns: PageExportingAction - the page exporting action.

setPageExportingAction(PageExportingAction value)

public void setPageExportingAction(PageExportingAction value)

Sets the page exporting action. Please note that setting this method will automatically release page resources after it is executed. It will be executed just before each page is saved.

Value: The page exporting action.

Parameters:

ParameterTypeDescription
valuePageExportingActionthe page exporting action.

getDefaultOptions(Object[] args)

public ImageOptionsBase getDefaultOptions(Object[] args)

Gets the default options.

Parameters:

ParameterTypeDescription
argsjava.lang.Object[]The arguments.

Returns: ImageOptionsBase - Default options

cacheData()

public void cacheData()

Caches the data and ensures no additional data loading will be performed from the underlying DataStreamSupporter.DataStreamContainer(DataStreamSupporter.getDataStreamContainer).

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(int newWidth, int newHeight, int resizeType)

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

Resizes the image.

Parameters:

ParameterTypeDescription
newWidthintThe new width.
newHeightintThe new height.
resizeTypeintThe resize type.

resize(int newWidth, int newHeight, ImageResizeSettings settings)

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

Resizes the image.

Parameters:

ParameterTypeDescription
newWidthintThe new width.
newHeightintThe new height.
settingsImageResizeSettingsThe resize settings.

rotateFlip(int rotateFlipType)

public void rotateFlip(int rotateFlipType)

Rotates, flips, or rotates and flips the image.

Parameters:

ParameterTypeDescription
rotateFlipTypeintType of rotating flip.

setPalette(IColorPalette palette, boolean updateColors)

public void setPalette(IColorPalette palette, boolean updateColors)

Sets the image palette.

Parameters:

ParameterTypeDescription
paletteIColorPaletteThe palette to set.
updateColorsbooleanif 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.