Click or drag to resize

ImagePixelFormat Enumeration

Specifies the pixel format for the generated images of document pages.

Namespace:  Aspose.Words.Saving
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 21.5.0

ExpandedSyntax

public enum ImagePixelFormat

ExpandedMembers

  Member nameValueDescription
Format16BppRgb5550 16 bits per pixel, RGB.
Format16BppRgb5651 16 bits per pixel, RGB.
Format16BppArgb15552 16 bits per pixel, ARGB.
Format24BppRgb3 24 bits per pixel, RGB.
Format32BppRgb4 32 bits per pixel, RGB.
Format32BppArgb5 32 bits per pixel, ARGB.
Format32BppPArgb6 32 bits per pixel, ARGB, premultiplied alpha.
Format48BppRgb7 48 bits per pixel, RGB.
Format64BppArgb8 64 bits per pixel, ARGB.
Format64BppPArgb9 64 bits per pixel, ARGB, premultiplied alpha.
Format1bppIndexed10 1 bit per pixel, Indexed.

ExpandedExamples

Shows how to select a bit-per-pixel rate with which to render a document to an image.
Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.ParagraphFormat.Style = doc.Styles["Heading 1"];
            builder.Writeln("Hello world!");
            builder.InsertImage(ImageDir + "Logo.jpg");

            Assert.That(20000, Is.LessThan(new FileInfo(ImageDir + "Logo.jpg").Length));

            // When we save the document as an image, we can pass a SaveOptions object to
            // select a pixel format for the image that the saving operation will generate.
            // Various bit per pixel rates will affect the quality and file size of the generated image.
            ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.Png);
            imageSaveOptions.PixelFormat = imagePixelFormat;

            // We can clone ImageSaveOptions instances.
            Assert.AreNotEqual(imageSaveOptions, imageSaveOptions.Clone());

            doc.Save(ArtifactsDir + "ImageSaveOptions.PixelFormat.png", imageSaveOptions);

#if NET462 || JAVA
            switch (imagePixelFormat)
            {
                case ImagePixelFormat.Format1bppIndexed:
                    Assert.That(10000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
                    break;
                case ImagePixelFormat.Format16BppRgb555:
                    Assert.That(80000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
                    break;
                case ImagePixelFormat.Format24BppRgb:
                    Assert.That(125000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
                    break;
                case ImagePixelFormat.Format32BppRgb:
                    Assert.That(150000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
                    break;
                case ImagePixelFormat.Format48BppRgb:
                    Assert.That(200000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
                    break;
            }
#elif NETCOREAPP2_1
            switch (imagePixelFormat)
            {
                case ImagePixelFormat.Format1bppIndexed:
                    Assert.That(10000, Is.AtLeast(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
                    break;
                case ImagePixelFormat.Format24BppRgb:
                    Assert.That(70000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
                    break;
                case ImagePixelFormat.Format16BppRgb555:
                case ImagePixelFormat.Format32BppRgb:
                case ImagePixelFormat.Format48BppRgb:
                    Assert.That(125000, Is.LessThan(new FileInfo(ArtifactsDir + "ImageSaveOptions.PixelFormat.png").Length));
                    break;
            }
#endif

ExpandedSee Also