Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Layers with distort perspective

$
0
0
I got really close with the code below. You only have to fine-tune the distortion values and the position.

I used the following example: http://www.imagemagick.org/Usage/distorts/#affine_examples
// Magick.NET understands the ~ prefix.var first = new MagickImage(@"~\files\house.jpg");
var second = new MagickImage(@"~\files\monkey.jpg");

double[] args =
{
  // I just entered a bunch of numbers till I got close to what you want.
  0,0, 0,0,  0,120, 0,98,  200,0, 65,-50
};

second.HasAlpha = true; // -alpha set
second.VirtualPixelMethod = VirtualPixelMethod.Transparent; // -virtual-pixel transparent
second.Distort(DistortMethod.Affine, args);

// Crop part of the image so it won't overflow 'first'int x = 105;
second.Crop(first.Width - x, second.Height, Gravity.West);
  
// Position the second image
second.Page = new MagickGeometry(x, 55, 0, 0);

using (var images = new MagickImageCollection())
{
  images.Add(first);
  images.Add(second);
  using (var result = images.Merge())
  {
    result.Write(@"(@"~\files\house_with_paint.jpg");
  }
}

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>