Create Shape Thumbnails

Overview

In this topic, we will show how to generate slide thumbnails in different situations:

  • Generating a shape thumbnail inside a slide.
  • Generating a shape thumbnail for a slide shape with user-defined dimensions.
  • Generating a shape thumbnail in the bounds of a shape’s appearance.

Generating Shape Thumbnails from Slides

To generate a shape thumbnail from any slide using Aspose.Slides for Android via Java, do this:

  1. Create an instance of the Presentation class.
  2. Obtain the reference of any slide using its ID or index.
  3. Get the shape thumbnail image of the referenced slide on default scale.
  4. Save the thumbnail image in your preferred image format.

This sample code shows you how to generate a shape thumbnail from a slide:

// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("Thumbnail.pptx");
try {
    // Create a full scale image
    IImage slideImage = pres.getSlides().get_Item(0).getShapes().get_Item(0).getImage();
    
    // Save the image to disk in PNG format
    try {
          slideImage.save("output.png", ImageFormat.Png);
    } finally {
         if (slideImage != null) slideImage.dispose();
    }
} finally {
    if (pres != null) pres.dispose();
}

Generating Shape Thumbnails with User-Defined Scaling Factor

To generate the shape thumbnail of a slide using Aspose.Slides for Android via Java, do this:

  1. Create an instance of the Presentation class.
  2. Obtain the reference of any slide using its ID or index.
  3. Get the shape thumbnail image of the referenced slide with user-defined dimensions.
  4. Save the thumbnail image in your preferred image format.

This sample code shows you how to generate a shape thumbnail based on a defined scaling factor:

// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("Thumbnail.pptx");
try {
    // Create a full scale image
    IImage slideImage = pres.getSlides().get_Item(0).getShapes().get_Item(0).getImage(ShapeThumbnailBounds.Shape, 1, 1);

    // Save the image to disk in PNG format
    try {
          slideImage.save("output.png", ImageFormat.Png);
    } finally {
         if (slideImage != null) slideImage.dispose();
    }
} finally {
    if (pres != null) pres.dispose();
}

Generating Shape Thumbnail of Bounds

This method of creating thumbnails of shapes allows developers to generate a thumbnail in the bounds of the shape’s appearance. It takes into account all the shape effects. The generated shape thumbnail is restricted by the slide bounds. To generate a thumbnail of a slide shape in the bound of its appearance, do this:

  1. Create an instance of the Presentation class.
  2. Obtain the reference of any slide using its ID or index.
  3. Get the thumbnail image of the referenced slide with shape bounds as appearance.
  4. Save the thumbnail image in your preferred image format.

This sample code is based on the steps above:

// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("Thumbnail.pptx");
try {
    // Create a full scale image
    IImage slideImage = pres.getSlides().get_Item(0).getShapes().get_Item(0).getImage(ShapeThumbnailBounds.Appearance, 1, 1);

    // Save the image to disk in PNG format
    try {
          slideImage.save("output.png", ImageFormat.Png);
    } finally {
         if (slideImage != null) slideImage.dispose();
    }
} finally {
    if (pres != null) pres.dispose();
}