I'm currently writing a C# application which should print (wordwrapped) text over a predefined height and width where the extreme edges should fade into transparency.
I am using the latest C# MagickImage package (AnyCpu, Q8, 7.5.0) at the time of writing.
These parameters are provided (shortened to the ones needed for this question):
PointY (int)
MaxHeight (int)
FadeHeight (int)
Now let's say PointY is zero, MaxHeight is 100 and FadeHeight is 120.
What this means is that the text should be shown up until 120 pixels down, while height 100 to 120 should fade from completely visible to completely transparent.
Here is some ASCII representation of my goal (the blabla parts that are losing letters ==> more transparent)
Code: Select all
PointY ._____________________
^ |blablablablablablabla|
MaxHeight | |blablablablablablabla|
| |blablablablablablabla|
v |blablablablablablabla|
^ |blabl blabl blabl bla|
FadeHeight | |b abl b abl b abl b a|
| |b l a b l a|
v |_____________________|
I have tried some code, but I have no idea how to translate this into valid Magick.NET code and I think I'm going about it all wrong.
Code: Select all
using (var image = new MagickImage(MagickColor.FromRgb(0, 159, 227), 320, 240))
{
text = "caption:This is a very long test string aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
using (var completeMask = new MagickImage(MagickColors.Black, 100, 120))
{
using (var maskTransparent = new MagickImage($"gradient:black-white", 100, 20))
completeMask.Composite(maskTransparent, 0, 100);
using (var mText = new MagickImage(MagickColors.Transparent, 100, 120))
{
mText.Read(text);
mText.Composite(completeMask, 0, 0 CompositeOperator.Dissolve, "100");
image.Composite(mText, 0, 0, CompositeOperator.Dissolve, "100");
}
}
}