Public API Changes in Aspose.Imaging 2.6.0

Added Classes, Enumerations, Constructors and Methods

Classes VectorRasterizationOptions & CadRasterizationOptions Added

The new classes VectorRasterizationOptions and CadRasterizationOptions has been added to the com.aspose.imaging.ImageOptions in order to facilitate the user with CAD to vector & CAD to raster conversion. Moreover, some members of the PdfOptions class has been moved to the aforesaid classes.

With these changes in place, the CAD to PDF conversion can now be achieved as follow.

Java

 Image image = Image.load(sourceFile);

//Create an instance of CadRasterizationOptions and set its various properties

CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();

rasterizationOptions.setBackgroundColor(Color.getWhite());

rasterizationOptions.setPageWidth(1600);

rasterizationOptions.setPageHeight(1600);

rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);

rasterizationOptions.setLayoutName("layout1");

//Create an instance of PdfOptions

PdfOptions pdfOptions = new PdfOptions();

//Set the VectorRasterizationOptions property

pdfOptions.setVectorRasterizationOptions(rasterizationOptions);

//Export the DWG to PDF

image.save(outputFile, pdfOptions);

Support for Binary DXF Format Added

In order to provide the support for Binary DXF file format, Aspose.Imaging for Java 2.6.0 has added the following classes & enumerations to the public API.

  1. Class com.aspose.imaging.fileformats.cad.CadBinaryCodeValue
  2. Class com.aspose.imaging.fileformats.cad.CadConsts.DxfFileFormat
  3. Class com.aspose.imaging.fileformats.cad.CadParameters.CadBinaryParameter
  4. Enum com.aspose.imaging.fileformats.cad.CadConsts.CadGroupCodeTypes

Class TransparentColorSetting Added

A new class, com.aspose.imaging.TransparentColorSetting, assists with the process of specifying transparency for PNG images.

Java

 image.savePixels(new Rectangle(0, 0, w, h), pixel);

PngOptions options = new PngOptions();

options.setTransparentColor(new TransparentColorSetting(Color.getRed()));

image.save(outputFile, options);

Class ResolutionSetting Added

The class com.aspose.imaging.ResolutionSetting has been added to Aspose.Imaging 2.6.0 to assist with the setting vertical & horizontal resolution for images. The members of {{ResolutionSetting }} class are:

  1. com.aspose.imaging.ResolutionSetting.HorizontalResolution: Gets or sets the horizontal resolution.
  2. com.aspose.imaging.ResolutionSetting.VerticalResolution: Gets or sets the vertical resolution.

Java

 image.savePixels(new Rectangle(0, 0, height, width), pixel);

PngOptions options = new PngOptions();

options.setResolutionSettings(new ResolutionSetting(72, 96));

image.save(outputFile, options);

Class DeflateCompressorException Added

The class com.aspose.imaging.exceptions.Compressors.DeflateCompressorException has been added to Aspose.Imaging 2.6.0 to handle possible problems with PNG inner compression.

Constructors Added to PngImage Class

We have added the following constructors to PngImage class in order to assist with the PNG encoding & decoding.

com.aspose.imaging.fileformats.png.PngImage.#ctor(com.aspose.imaging.imageOptions.PngOptions, int, int)

Java

 PngOptions options = new PngOptions();

PngImage image = new PngImage(options, width, height);

com.aspose.imaging.fileformats.png.PngImage.#ctor(com.aspose.imaging.RasterImage, com.aspose.imaging.fileformats.png.PngColorType)

Java

 PngImage pngImage = new PngImage(prevLoadedImage, PngColorType.TruecolorWithAlpha);

com.aspose.imaging.fileformats.png.PngImage.#ctor(int , int, com.aspose.imaging.fileformats.png.PngColorType)

Java

 PngImage pngImage = new PngImage(width, height, PngColorType.TruecolorWithAlpha);

com.aspose.imaging.fileformats.png.PngImage.#ctor(String, com.aspose.imaging.fileformats.png.PngColorType)

Java

 PngImage pngImage = new PngImage("pngimage.png", PngColorType.TruecolorWithAlpha);

Enumeration PngColorType added

The enumeration com.aspose.imaging.fileformats.png.PngColorType has been added to Aspose.Imaging 2.6.0 to specify the PNG color type. Possible values are as follows:

  1. PngColorType.Greyscale: Represents the color type where each pixel is a greyscale sample.
  2. PngColorType.Truecolor: Represents the color type where each pixel is an R,G,B triple.
  3. PngColorType.IndexedColor: Represents the color type where each pixel is a palette index; a PLTE chunk shall appear.
  4. PngColorType.GreyscaleWithAlpha: Represents the color type where each pixel is a greyscale sample followed by an alpha sample.
  5. PngColorType.TruecolorWithAlpha: Represents the color type where each pixel is an R,G,B triple followed by an alpha sample.

Java

 PngOptions options = new PngOptions();

options.setColorType(PngColorType.Greyscale);

Field PixelFormat.BGR Added

The field/enumeration com.aspose.imaging.PixelFormat.BGR has been added to distinguish the PNG RGB color order from BMP BGR color order. The sample code below returns RGB color order:

Java

 PngImage image = new PngImage(sourceFile);

Color[] pixels = image.loadPixels(image.getBounds());

System.out.println(image.getRawDataFormat().getPixelFormat());

Sample code returns BGR color order.

Java

 BmpImage image = new BmpImage(sourceFile);

Color[] pixels = image.loadPixels(image.getBounds());

System.out.println(image.getRawDataFormat().getPixelFormat());

Methods resizeWidthProportionally & resizeHeightProportionally Added

The com.aspose.imaging.Image class has now exposed the resizeWidthProportionally and resizeHeightProportionally with the release of Aspose.Imaging 2.6.0 to assist with the re-sizing operation while keeping the aspect ratio. The aforesaid methods requires only one parameter (either Height or Width) and automatically calculates the other value.

Methods getProportionalWidth & getProportionalHeight Added

The class com.aspose.imaging.Image has exposed getProportionalWidth & getProportionalHeight methods to calculate proportional width or height.

Java

 int newHeight = Image.getProportionalHeight(150, 120, 100);  // 80

int newWIdth = Image.getProportionalWidth(150, 120, 60);  // 75

Method RasterCachedImage.rotate Added

The method com.aspose.imaging.RasterCachedImage.rotate has been added with version 2.6.0 to make it possible to specify a custom angle for image rotation.

Java

 //Load an image in an instance of RasterImage class

RasterImage image = (RasterImage)Image.load(sourceFile);

//Specify rotate angle in degrees. Positive values will rotate clockwise

float rotateAngle = 10;

//If set to true you will have your image size changed according to rotated rectangle (corner points) projections in other case that leaves dimensions untouched and only internal image contents are rotated

Boolean resizeProportionally = true;

//Background color

Color backgroundColor = Color.getDarkRed();

//Rotate the image at specified angle

image.rotate(rotateAngle, resizeProportionally, backgroundColor);

//Save result

image.save(outputFile);

Property PngImage.RawDataFormat Added

The property com.aspose.imaging.fileformats.png.PngImage.RawDataFormat has been added with version 2.6.0 to help with PNG raw data format.

Java

 PngImage pngImage = new PngImage("png.png");

System.out.println(pngImage.getRawDataFormat().getPixelFormat());

Property ResolutionSettings Added

The property ResolutionSettings has been added to the com.aspose.imaging.ImageOptionsBase class in order to make it accessible through all the options classes.

Java

 TiffOptions options = new TiffOptions();

options.setResolutionSettings(new ResolutionSetting(72, 96));

Properties Added to ExifData Class

Following properties have been added to the com.aspose.imaging.exif.ExifData class.

  1. Property ExifData.CommonTags
  2. Property ExifData.ExifTags
  3. Property ExifData.GPSTags

Properties Added to PngOptions Class

Following properties have been added to the com.aspose.imaging.imageoptions.PngOptions class.

  1. Property PngOptions.ColorType
  2. Property PngOptions.Progressive
  3. Property PngOptions.TransparentColor

Properties Added to PixelDataFormat Class

Following properties have been added to the com.aspose.imaging.PixelDataFormat class.

  1. Property PixelDataFormat.GrayscaleAlpha
  2. Property PixelDataFormat.Rgb24BppPng
  3. Property PixelDataFormat.Rgba32Bpp

Removed Classes and Methods

Methods Removed from PngImage Class

Following methods have been removed from the com.aspose.imaging.fileformats.png.PngImage class. It is advised to use the same methods of the base class instead.

  1. Method PngImage.cacheData.
  2. Method PngImage.crop(Rectangle).
  3. Method PngImage.resize(int, int, ResizeType)
  4. Method PngImage.rotateFlip(RotateFlipType).
  5. Method PngImage.setResolution(double, double).

Unused CAD Classes Removed

The following classes have been removed with version 2.6.0 of Aspose.Imaging for Java as they were of no use.

  1. Class com.aspose.imaging.fileformats.cad.CadObjects.CadInvisibleObject.
  2. Class com.aspose.imaging.fileformats.cad.CadObjects.CadMesh.
  3. Class com.aspose.imaging.fileformats.cad.CadObjects.CadProxyEntity.
  4. Class com.aspose.imaging.fileformats.cad.CadObjects.CadSectionEntity.