If GradientColorType = OneColor

If GradientColorType = OneColor, how do I get the color it fades to as RGB? Is this even possible? If not, is it possible to grab the FillFormat as an image?

Dear Michael,

Please check FillFormat.GradientDegree.
MS PowerPoint supports only 20 gradations of black and white for gradient.

Yes, I understand that. But if the color is #00CC99 or something like that…how can I get the other color in Hex code. A number of 0-19 doesn’t really help me get there…

Dear Michael,

I thought it’s a very simple mathematic.

int c = 255 * shape.FillFormat.GradientDegree / 19;
Color color = Color.FromArgb(c, c, c);

Hmm, if I have a red value of 0, a green value of 102, and a blue value of 204…and my gradientdegree = .32, how do I get the other color in the gradient…I am not understanding your explanation

Dear Michael,

GradientDegree is Int32 and can be from 0 to 19 only. It can’t be 0.32 or 32!
For example GradientDegree = 8.

Color firstColor = Color.FromArgb(0, 102, 204);

int c = 255 * (8) / 19; // 8 is GradientDegree
Color secondColor = Color.FromArgb(c, c, c);

I;m not getting the right color though. I’m sorry, my gradientDegree was 0.31 after dividing by 19…so really its 6. Even so, the color returned Color(81,81,81) is way off…it should be something totally different.

Why something different? It’s a standard default gray color.

Also you can try to use something like this (I didn’t test it).
It will set second color the same as the first one if gradientdegree = 9.

int gr = GradientDegree;
int r2, g2, b2;
if (gr < 10)
{
r2 = r1 * gr / 9;
g2 = g1 * gr / 9;
b2 = b1 * gr / 9;
}
else
{
r2 = (255 - r1) * (gr - 9) / 10 + r1;
g2 = (255 - g1) * (gr - 9) / 10 + g1;
b2 = (255 - b1) * (gr - 9) / 10 + b1;
}
Color secondColor = Color.FromArgb(r2, g2, b2);

Dear Michael,

I should tell thank you because I used first variant in the GetThumbnail function and second color always was b&w.