java.lang.Object
com.aspose.words.ImageColorMode
public class ImageColorMode
- extends java.lang.Object
Utility class containing constants.
Specifies the color mode for the generated images of document pages.
Example:
Shows how to set a color mode when rendering documents.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.getParagraphFormat().setStyle(doc.getStyles().get("Heading 1"));
builder.writeln("Hello world!");
builder.insertImage(getImageDir() + "Logo.jpg");
Assert.assertTrue(new File(getImageDir() + "Logo.jpg").length() < 20200);
// When we save the document as an image, we can pass a SaveOptions object to
// select a color mode for the image that the saving operation will generate.
// If we set the "ImageColorMode" property to "ImageColorMode.BlackAndWhite",
// the saving operation will apply grayscale color reduction while rendering the document.
// If we set the "ImageColorMode" property to "ImageColorMode.Grayscale",
// the saving operation will render the document into a monochrome image.
// If we set the "ImageColorMode" property to "None", the saving operation will apply the default method
// and preserve all the document's colors in the output image.
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.PNG);
imageSaveOptions.setImageColorMode(imageColorMode);
doc.save(getArtifactsDir() + "ImageSaveOptions.ColorMode.png", imageSaveOptions);
switch (imageColorMode) {
case ImageColorMode.NONE:
Assert.assertTrue(new File(getArtifactsDir() + "ImageSaveOptions.ColorMode.png").length() < 156000);
break;
case ImageColorMode.GRAYSCALE:
Assert.assertTrue(new File(getArtifactsDir() + "ImageSaveOptions.ColorMode.png").length() < 84000);
break;
case ImageColorMode.BLACK_AND_WHITE:
Assert.assertTrue(new File(getArtifactsDir() + "ImageSaveOptions.ColorMode.png").length() <= 20000);
break;
}
Field Summary |
static final int | NONE = 0 | |
The pages of the document will be rendered as color images.
|
static final int | GRAYSCALE = 1 | |
The pages of the document will be rendered as grayscale images.
|
static final int | BLACK_AND_WHITE = 2 | |
The pages of the document will be rendered as black and white images.
|
NONE = 0 | |
public static final int NONE |
-
The pages of the document will be rendered as color images.
GRAYSCALE = 1 | |
public static final int GRAYSCALE |
-
The pages of the document will be rendered as grayscale images.
BLACK_AND_WHITE = 2 | |
public static final int BLACK_AND_WHITE |
-
The pages of the document will be rendered as black and white images.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.