How Is an Image Overlaid on the Slide in PPT? Composition Type?

Hi,

I have a PPT slide which has a solid blue fill background. On top it has two pictures. One of the picture is blended in with the background, such that it does not replace the background color underneath. While the other picture is rendered in PPT UI such that it completely masks/replaces the background blue color underneath.

How does PPT UI decide how to blend an image over the background ? Can Aspose provide this information ?

Thanks

@bhav

In PowerPoint, the way an image is overlaid on a slide and how it interacts with the background is determined by the image’s fill type and blending options. When you have a solid background color, images can either blend with this background or completely mask it, depending on their properties.

  1. Blending with Background: An image can be blended with the background if it has a certain transparency or blending mode applied. This allows the background color to show through the image, creating a seamless integration. The PowerPoint UI uses these properties to determine how much of the background is visible through the image.

  2. Masking the Background: Conversely, if an image is set to fully opaque, it will completely cover the background color, effectively masking it. This is typically the default behavior for images unless transparency is specifically applied.

To programmatically access and manipulate these properties using Aspose.Slides, you can retrieve the effective background values of a slide. For example, you can check the fill type of the background and determine if it is solid or another type. Here’s a code snippet that demonstrates how to get the effective background values:

import com.aspose.slides.FillType;
import com.aspose.slides.IBackgroundEffectiveData;
import com.aspose.slides.Presentation;

public class GetBackgroundEffectiveValues {
    public static void main(String[] args) {
        // Instantiate the Presentation class that represents the presentation file
        Presentation pres = new Presentation("SamplePresentation.pptx");
        try {
            IBackgroundEffectiveData effBackground = pres.getSlides().get_Item(0).getBackground().getEffective();
            if (effBackground.getFillFormat().getFillType() == FillType.Solid) {
                System.out.println("Fill color: " + effBackground.getFillFormat().getSolidFillColor());
            } else {
                System.out.println("Fill type: " + effBackground.getFillFormat().getFillType());
            }
        } finally {
            if (pres != null) pres.dispose();
        }
    }
}

This code will help you understand the background fill type and color, which can be useful in determining how images are rendered over the background in your PowerPoint slides.

If you need more specific details about blending modes or other advanced features, I recommend checking the Aspose.Slides documentation or exploring additional examples related to image manipulation and background settings.

Sources:
[1]: GetBackgroundEffectiveValues.java

Thanks. But, how does PPT know image’s fill type and blending options? Is it mentioned in the PPTX xml ? Is there any way to get this from Aspose ?

in my slide I have a pictureframe shape. It does not have a fill type. But, in pptx xml i can see that its transparency is set via <a:alphaModFix amt=“37000”/>
How do i get this transparency value from Aspose ?

@bhav,
You can use the IImageTransformOperationCollection interface to extract the Alpha Modulate Fixed effect from an image. The following code example shows how to do this:

using var presentation = new Presentation("sample.pptx");
var slide = presentation.Slides[0];

var imageTransform = slide.Background.FillFormat.PictureFillFormat.Picture.ImageTransform;

foreach (var operation in imageTransform)
{
    if (operation is IAlphaModulateFixed alphaModulateFixed)
    {
        var transparencyValue = 100 - alphaModulateFixed.Amount;
        Console.WriteLine($"AlphaModulateFixed: {transparencyValue}");
    }
}

Presentation Background|Aspose.Slides Documentation

Hello Andrey,

Thanks for your response. But, in my case, the slide has a solid fill with blue color. On the slide, there is a shape of type PictureFrame. For this picture, i see in the PPTX XML that there is 37% transparency. The PPT UI renders this picture on top of the blue background in such a way that the blue color can also be seen underneath. When using Aspose Slides for .NET, how can I get this transparency information for this picture shape ? Pls see the PPT attached.

<p:pic>
    <p:nvPicPr>
        <p:cNvPr id="6" name="Bild 5" descr="blue-wavy-background_s.jpg">
            <a:extLst>
                <a:ext uri="{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}">
                    <a16:creationId
                            xmlns:a16="http://schemas.microsoft.com/office/drawing/2014/main"
                            id="{A5AD43C2-BF8B-C363-08B7-1522F56594E9}"/>
                </a:ext>
            </a:extLst>
        </p:cNvPr>
        <p:cNvPicPr>
            <a:picLocks noChangeAspect="1"/>
        </p:cNvPicPr>
        <p:nvPr/>
    </p:nvPicPr>
    <p:blipFill rotWithShape="1">
        <a:blip r:embed="rId3" cstate="print">
            **<a:alphaModFix amt="37000"/>**
            <a:extLst>
                <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
                    <a14:useLocalDpi
                            xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main"
                            val="0"/>
                </a:ext>
            </a:extLst>
        </a:blip>
        <a:srcRect t="21832" b="24421"/>
        <a:stretch/>
    </p:blipFill>
    <p:spPr>
        <a:xfrm flipV="1">
            <a:off x="-683673" y="-75800"/>
            <a:ext cx="12192038" cy="4368537"/>
        </a:xfrm>
        <a:prstGeom prst="rect">
            <a:avLst/>
        </a:prstGeom>
        <a:effectLst>
            **<a:softEdge rad="1270000"/>**
        </a:effectLst>
    </p:spPr>
</p:pic>

Thanks,
@bhav
sample.7z (876.4 KB)

@bhav,
I’m sorry for the missunderstanding. The transparency of the image can be extracted in a similar way:

using var presentation = new Presentation("sample.pptx");
var slide = presentation.Slides[0];
var shape = slide.Shapes[0] as IPictureFrame;

var imageTransform = shape.PictureFormat.Picture.ImageTransform;

foreach (var operation in imageTransform)
{
    if (operation is IAlphaModulateFixed alphaModulateFixed)
    {
        Console.WriteLine($"AlphaModulateFixed: {alphaModulateFixed.Amount}");
    }
}

Output:

AlphaModulateFixed: 37

More examples:
Picture Frame|Aspose.Slides Documentation

Fantastic Andrey. Thank you !

@bhav

Hi Andrey,

Do we know how Powerpoint renders this image on the slide blue background ? I am trying to render this slide on HTML canvas. I first draw the blue background, then this image using default “source-over” composite mode. But, in this mode, the image completely replaces the blue background beneath, while in PPTX UI I see that the image blends in with the blue background. How can I achieve similar effect on HTML canvas ? Any insights would help, thanks !

@bhav

@bhav,
We need more details to investigate the case. Could you please share step-by-step instructions on how to reproduce the issue? We will do our best to help you.