Quantcast
Viewing all articles
Browse latest Browse all 3693

New Post: Creating an equivalent of a CSS linear gradient from top to bottom

What you could do is this:
int size = 100;

using (MagickImageCollection images = new MagickImageCollection())
{
  images.Add(new MagickImage(new MagickColor("#000000"), size * 2, size * 2));
  images.Add(new MagickImage(new MagickColor("#ffffff"), size * 2, size * 2));

  using (MagickImage image = images.AppendHorizontally())
  {
    image.Rotate(45);

    image.RePage();
    image.Crop(size, size, Gravity.Center);

    image.Write(@"d:\test.png");
  }
}
This will create an image larger than what you want rotate it and then crop it to the size that you want. Not sure if the times 2 approach will work for every situation. Not a math expert here :)

Viewing all articles
Browse latest Browse all 3693

Trending Articles