Free Support Forum - aspose.com

IColorFormat.Color doesn't return effective color when color is scheme type (C# .NET)

Attached presentation has one empty slide with blue background

presentation.Slides[0].LayoutSlide.MasterSlide.Background.Type is OwnBackground, fill format is Solid and SolidFillcolor.Type is Scheme. But when I get SolidFillcolor.Color, it’s value is white (while powerpoint thinks the value is supposed to be blue).

IColorFormat.Color documentation says it
// Returns resulting color (with all color transformations applied).

Is there another way I should be reading Scheme colors?

pptexamples.zip (29.6 KB)

Thanks!

@ezolenko,

I have observed the presentation file shared by you in PowerPoint 365. However, I am unable to observe any blue background in master or any of layout slides. For your kind reference, I have shared the snapshot of the presentation as well. You can observe that it is set on normal slide level. Can you please share the working sample code that you are using to reproduce the issue.

Yeah, that’s what I see in powerpoint too – slide is blue when seen in design mode, but all possible background colors are either not set or are white.

Here is what I see in the code:

var presentation = new Presentation("E:\\ppt\\pptexamples.pptx"))
var slide = presentation.Slides[0];
var ownBackgroundType = slide.Background.Type; // = NotDefined
var layoutBackgroundType = slide.LayoutSlide.Background.Type; // = NotDefined
var masterBackgroundType = slide.LayoutSlide.MasterSlide.Background.Type; // = OwnBackground
var fillType = slide.LayoutSlide.MasterSlide.Background.FillFormat.FillType; // = Solid
var colorType = slide.LayoutSlide.MasterSlide.Background.FillFormat.SolidFillColor.ColorType; // = Scheme
var schemeColor = slide.LayoutSlide.MasterSlide.Background.FillFormat.SolidFillColor.SchemeColor; // = Background1
var effectiveColor = slide.LayoutSlide.MasterSlide.Background.FillFormat.SolidFillColor.Color; // = 255, 255, 255 / white
var thumbnail = slide.GetThumbnail(1, 1);
var actualColor = thumbnail.GetPixel(1, 1); // = 0, 0, 255 / blue

The question is how to get actual color without rendering the slide. Looking at documentation for SolidFillColor.Color, it should be an effective color, but apparently scheme color values are stored somewhere else?

@ezolenko,

I have worked with source files shared by you and have been able to observe the issue. A ticket with ID SLIDESNET-41092 has been created in our issue tracking system to further investigate issue in detail. This thread has been linked with issue so that you may be automatically notified once issue will be fixed.

The issues you have found earlier (filed as SLIDESNET-41092) have been fixed in this update.

I’m trying this in 19.12 and still see the same issue (effective color is white). Do you know what changed in the update? Is there a new API to get scheme colors?

Thanks!

@ezolenko,

We have investigated the issue on our end. Actually, getting effective values is possible only using classes and interfaces ending with ‘EffectiveData’ suffix while classes like FillFormat and Background contain only local values. Also there’s no immediate conversion between ColorFormat.SchemeColor and ColorFormat.Color properties neither after setting ColorFormat.SchemeColor manually nor after reading values from existing presentation file.

However, since Aspose.Slides 19.6, we have made it possible to get effective background data using freshly added IBaseSlide.CreateBackgroundEffective() method. You may try using following sample code on your end.

var presentation = new Presentation("E:\\ppt\\pptexamples.pptx");
var slide = presentation.Slides[0];
var effectiveBackground = slide.CreateBackgroundEffective();
if (effectiveBackground.FillFormat.FillType == FillType.Solid)
{
    var effectiveColor = effectiveBackground.FillFormat.SolidFillColor; // = 0, 0, 255 / blue
    var thumbnail = slide.GetThumbnail(1, 1);
    var actualColor = thumbnail.GetPixel(1, 1); // = 0, 0, 255 / blue
    Console.WriteLine("Effective background color and actual background color are equal: " + (effectiveColor == actualColor));
}
else
{
    Console.WriteLine("Effective background has FillType = " + effectiveBackground.FillFormat.FillType);
}
1 Like

Thanks, works with

Slide.Background.GetEffective()

@ezolenko,

It’s good to know that suggested code has worked on your end.