public final class AiRasterImageSection extends Object
The AI Raster Image Section
An example of exporting an AI file that contains layers to other file formats. The program loads predefined AI file and verifies one before further exporting.
class LocalScopeExtension { void assertIsTrue(boolean condition, String message) { if (!condition) { throw new FormatException(message); } } } LocalScopeExtension $ = new LocalScopeExtension(); String inAiFilePath = "form_8_2l3_7.ai"; String outPsdFilePath = "form_8_2l3_7_export.psd"; String outPngFilePath = "form_8_2l3_7_export.png"; // Load an AI file containing predefined layers AiImage aiImage = (AiImage)Image.load(inAiFilePath); try { // Check that AI layers were read correctly AiLayerSection layer0 = aiImage.getLayers()[0]; $.assertIsTrue(layer0 != null, "Layer 0 should be not null."); $.assertIsTrue(layer0.getName().equals("Layer 4"), "The Name property of the layer 0 should be `Layer 4`"); $.assertIsTrue(!layer0.isTemplate(), "The IsTemplate property of the layer 0 should be false."); $.assertIsTrue(layer0.isLocked(), "The IsLocked property of the layer 0 should be true."); $.assertIsTrue(layer0.isShown(), "The IsShown property of the layer 0 should be true."); $.assertIsTrue(layer0.isPrinted(), "The IsPrinted property of the layer 0 should be true."); $.assertIsTrue(!layer0.isPreview(), "The IsPreview property of the layer 0 should be false."); $.assertIsTrue(layer0.isImagesDimmed(), "The IsImagesDimmed property of the layer 0 should be true."); $.assertIsTrue(layer0.getDimValue() == 51, "The DimValue property of the layer 0 should be 51."); $.assertIsTrue(layer0.getColorNumber() == 0, "The ColorNumber property of the layer 0 should be 0."); $.assertIsTrue(layer0.getRed() == 79, "The Red property of the layer 0 should be 79."); $.assertIsTrue(layer0.getGreen() == 128, "The Green property of the layer 0 should be 128."); $.assertIsTrue(layer0.getBlue() == 255, "The Blue property of the layer 0 should be 255."); $.assertIsTrue(layer0.getRasterImages().length == 0, "The pixels length property of the raster image in the layer 0 should equals 0."); AiLayerSection layer1 = aiImage.getLayers()[1]; $.assertIsTrue(layer1 != null, "Layer 1 should be not null."); $.assertIsTrue(layer1.getName().equals("Layer 1"), "The Name property of the layer 1 should be `Layer 1`"); $.assertIsTrue(layer1.getRasterImages().length == 1, "The length property of the raster images in the layer 1 should equals 1."); AiRasterImageSection rasterImage = layer1.getRasterImages()[0]; $.assertIsTrue(rasterImage != null, "The raster image in the layer 1 should be not null."); $.assertIsTrue(rasterImage.getPixels() != null, "The pixels property of the raster image in the layer 1 should be not null."); $.assertIsTrue("".equals(rasterImage.getName()), "The Name property of the raster image in the layer 1 should be empty"); $.assertIsTrue(rasterImage.getPixels().length == 100, "The pixels length property of the raster image in the layer 1 should equals 100."); // Export to a PSD file aiImage.save(outPsdFilePath, new PsdOptions()); // Export to a PNG file with a white background PngOptions pngOptions = new PngOptions(); pngOptions.setColorType(PngColorType.TruecolorWithAlpha); aiImage.save(outPngFilePath, pngOptions); } finally { aiImage.dispose(); }
Modifier and Type | Method and Description |
---|---|
double |
getAngle()
Gets the angle.
|
double |
getHeight()
Gets the height.
|
Rectangle |
getImageRectangle()
Gets the image rectangle.
|
double |
getLeftBottomShift()
Gets the left bottom shift.
|
String |
getName()
Gets the name of the raster image.
|
double |
getOffsetX()
Gets the offset X.
|
double |
getOffsetY()
Gets the offset Y.
|
int[] |
getPixels()
Gets the array of int color pixels.
|
double |
getWidth()
Gets the width.
|
public final String getName()
Gets the name of the raster image.
Value: The name of the raster image.public final int[] getPixels()
Gets the array of int color pixels.
Value: The array of int color pixels.public final double getOffsetX()
Gets the offset X.
Value: The offset X.public final double getOffsetY()
Gets the offset Y.
Value: The offset Y.public final double getWidth()
Gets the width.
Value: The width.public final double getAngle()
Gets the angle.
Value: The angle.public final double getLeftBottomShift()
Gets the left bottom shift.
Value: The left bottom shift.public final double getHeight()
Gets the height.
Value: The height.public final Rectangle getImageRectangle()
Gets the image rectangle.
Value: The image rectangle.