PsdImage.Rotate

Rotate(float)

Rotate image around the center.

public override void Rotate(float angle)
ParameterTypeDescription
angleSingleThe rotate angle in degrees. Positive values will rotate clockwise.

Examples

The following code demonstrates ability to rotate the image by specific angle value.

[C#]

string sourceFileName = "TheHat.psd";
var pngOptions = new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha };

// Whole image rotating
using (PsdImage image = (PsdImage)Image.Load(sourceFileName))
{
    for (int i = 0; i < 4; i++)
    {
        int angle = i * 45;
        image.Rotate(angle);

        string outFileName = "TheHatRotated" + angle + ".png";

        image.Save(outFileName, pngOptions);
    }
}

// Layer rotating
using (PsdImage image = (PsdImage)Image.Load(sourceFileName))
{
    for (int i = 0; i < 4; i++)
    {
        int angle = i * 45;
        image.Layers[1].Rotate(angle);

        string outFileName = "TheHatLayerRotated" + angle + ".png";

        image.Save(outFileName, pngOptions);
    }
}

See Also


Rotate(float, bool, Color)

Rotate image around the center.

public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
ParameterTypeDescription
angleSingleThe rotate angle in degrees. Positive values will rotate clockwise.
resizeProportionallyBooleanif set to true you will have your image size changed according to rotated rectangle (corner points) projections in other case that leaves dimensions untouched and only internal image contents are rotated.
backgroundColorColorColor of the background.

See Also