Free Support Forum - aspose.com

ColorFormatEx copying

Dear support,

I want to copy ColorFormatEx from source object to other object. I created a method provide copying differently depending on source ColorType property values. I tried to find a reference or examples in internet but found nothind. So, could you please look at code below and give a feedback if everythink ok? Thanks.

private static void CopyColor(ColorFormatEx dest, ColorFormatEx source)
{
if (source != null)
{
switch (source.ColorType)
{
case ColorTypeEx.NotDefined:
dest.ColorType = ColorTypeEx.NotDefined;
break;

case ColorTypeEx.Preset:
dest.ColorType = ColorTypeEx.Preset;
dest.PresetColor = source.PresetColor;
break;

case ColorTypeEx.RGB:
dest.ColorType = ColorTypeEx.RGB;
dest.B = source.B;
dest.G = source.G;
dest.R = source.R;
break;

case ColorTypeEx.System:
dest.ColorType = ColorTypeEx.System;
dest.SystemColor = source.SystemColor;
break;

case ColorTypeEx.Scheme:
dest.ColorType = ColorTypeEx.Scheme;
dest.SchemeColor = source.SchemeColor;
break;

case ColorTypeEx.RGBPercentage:
dest.ColorType = ColorTypeEx.RGBPercentage;
dest.FloatB = source.FloatB;
dest.FloatG = source.FloatG;
dest.FloatR = source.FloatR;
break;

case ColorTypeEx.HSL:
dest.ColorType = ColorTypeEx.HSL;
dest.Hue = source.Hue;
dest.Luminance = source.Luminance;
dest.Saturation = source.Saturation;
break;
}

if (source.ColorTransform != null && source.ColorTransform.Count > 0)
{
foreach (ColorOperationEx colorOperation in source.ColorTransform)
{
dest.ColorTransform.Add(colorOperation.OperationType, colorOperation.Parameter);
}
}
}
}

Hi Oleksiy,


Thanks for inquiring Aspose.Slides.

The sample code shared by you seems alright. If there is an issue please feel free to share with us and we will be obliged to help you further.

Many Thanks,