This project has moved. For the latest updates, please go here.

rotate top left

Nov 27, 2015 at 12:50 PM
hi, I'm trying to rotate an image in a MagickImageCollection, but i need the rotate center to be top left. I tried rotate command and distort command, but none work.
could you please help?
here's my code
thanks
        var background = new MagickImage("J:/MyGit/Kaos.ImageParser/Kaos.ImageParser/samples/grid.png");
        var images = new MagickImageCollection();
        images.Add(background);

        var img150 = new MagickImage("J:/MyGit/Kaos.ImageParser/Kaos.ImageParser/samples/150100.png");
        img150.BackgroundColor = MagickColor.Transparent;
        img150.Rotate(60);
        //img150.Distort(DistortMethod.ScaleRotateTranslate, 0,0,60);
        var geo150 = new MagickGeometry(100, 100, 0, 0);
        img150.Page = geo150;
        images.Add(img150);
        SampleLoader.Save("collection.png", images.Flatten());
Nov 27, 2015 at 4:35 PM
Hi Arjun,

The SRT distort is the correct method to use. But instead of us 0,0, you need to use a negative value. 0,0 is the center of the image.

So for top left, you need to use this:
img150.Distort(DistortMethod.ScaleRotateTranslate, (0 - (img150.Width / 2)), (0 - (img150.Height / 2)), 60);
Nov 27, 2015 at 8:11 PM
hi nukeation,
thanks for your reply,
I'm still unable to produce the desire result.
using distort produce funny image.
        var img150 = new MagickImage("J:/MyGit/Kaos.ImageParser/Kaos.ImageParser/samples/150100.png");
        img150.BackgroundColor = MagickColor.Transparent;
        img150.Distort(DistortMethod.ScaleRotateTranslate, (0 - (img150.Width / 2)), (0 - (img150.Height / 2)), 60);
        img150.Write("J:/MyGit/Kaos.ImageParser/Kaos.ImageParser/samples/collection-rotate.png");
Original Image
Image

Rotate Image
Image
Nov 28, 2015 at 12:00 PM
what i'm trying to do is to combine 2 images :

without rotate :
Image

expected result :
Image
Dec 1, 2015 at 1:48 PM
Anyone can help ? I've tried various distort params with no luck.
Coordinator
Dec 1, 2015 at 10:27 PM
You could use Composite. But you will need some math to calculate the x and y position.
using (MagickImage logo = new MagickImage("logo:"))
{
  using (MagickImage overlay = new MagickImage("xc:fuchsia", 150, 100))
  {
    overlay.BackgroundColor = MagickColor.Transparent;
    overlay.Rotate(60);

    int x = 200;
    int y = 200;

    logo.Composite(overlay, x, y, CompositeOperator.Over);
  }

  logo.Write(@"C:\test.png");
}