Rotate or Flip images in C# .NET

Das Aspose.Imaging Image Rotate Plugin für .NET ist eine hochwirksame und budgetfreundliche Lösung für programmatisch rotierende und flipping Bilder. Dieses vielseitige Plugin ermöglicht es Ihnen, Bilder in verschiedenen Winkel zu rotieren und sogar rotation mit flipping zu kombinieren, was es eine ideale Wahl für Entwickler und Freelancers macht. Mit Aspose’s Ruf für Exzellenz, können Sie Ihre Anwendung Workflows verbessern, ohne Ihr Budget zu überschreiten. Ob Sie Bilder auf 90, 180 oder 270 Grad rotieren müssen, oder Sie horizontale oder vertikale flipping anwenden möchten, dieses Plugin verbessert den Prozess. In diesem Artikel finden Sie **Wie Sie Bilder in C# mit Aspose.Imaging für .NET, die Premiere Image Rotation Biblioth.

Themen abgedeckt:

C# API zum Rotieren von Bildern

To effectively rotate and flip images, we will utilize Aspose.Imaging für .NET. Diese leistungsstarke .NET Image Manipulation Bibliothek unterstützt eine breite Palette von Raster- und Vektorbildformaten. Sie können es einfach in Ihr Projekt über NuGet integrieren oder indem Sie seine DLL herunterladen.

PM> Install-Package Aspose.Imaging

Schritte, um ein Bild in C# zu drehen

To rotate an image, specify the rotation angle; commonly used angles include 90, 180, and 270 degrees. Additionally, you can rotate and flip an image simultaneously. Aspose.Imaging for .NET provides the RotateFlipType enum to define both the rotation angle and flip type. The following image rotation types are available:

  • nur Routen
  • Zwei Rotate und Flip

Hier ist eine einfache Übersicht der Schritte, um ein Bild in C# zu drehen#:

  • Laden Sie das Bild vom Disk herunter.
  • Angeben Sie den Rotationstyp und drehen Sie das Bild.
  • Speichern Sie das aktualisierte Bild.

Hier ist das Bild, das wir zur Demonstration der Bildrotation verwenden werden:

Image for rotation and flipping

Drehen Sie ein Bild in C#

Lassen Sie uns untersuchen, wie man ein Bild dreht, ohne es zu fliegen. Die folgenden Optionen ermöglichen Rotation ohne fliegen:

  • Rotate180FlipNone: 180 Grad Rotation ohne Flipping
  • Rotate270FlipNone: 270 Grad Rotation ohne Flipping
  • Rotate90FlipNone: 90 Grad Rotation ohne Flipping

Um die Rotation eines Bildes in C# durchzuführen, folgen Sie diesen Schritten:

Hier ist ein Code-Snippet, der zeigt, wie man ein Bild zu einem bestimmten Winkel dreht:

// Load the image file
using (var image = Aspose.Imaging.Image.Load("input.jpg"))
{
    // Rotate the image by 270 degrees
    image.RotateFlip(Aspose.Imaging.RotateFlipType.Rotate270FlipNone);
    
    // Save the updated image
    image.Save("rotated.jpg");
}

Dies ist das resultierende rotierte Bild nach dem Ausführen des Codes:

rotate an image in C#

Rotate an Image

C# Drehen Sie ein Bild mit Flipping

Danach sehen wir, wie man Bilder gleichzeitig dreht und flip – keine zusätzlichen Codelinien erforderlich sind. Verwenden Sie einfach eines der folgenden Mitglieder aus dem RotateFlipType enum:

  • Rotate180FlipX: 180 Grad Rotation mit horizontaler Flipping
  • Rotate180FlipXY: 180 Grad Rotation mit horizontaler und vertikaler Flipping
  • Rotate180FlipY: 180 Grad Rotation mit vertikaler Flipping
  • Rotate270FlipX: 270 Grad Rotation mit horizontaler Flipping
  • Rotate270FlipXY: 270 Grad Rotation mit horizontaler und vertikaler Flipping
  • Rotate270FlipY: 270 Grad Rotation mit vertikaler Flipping
  • Rotate90FlipX: 90 Grad Rotation mit horizontaler Flipping
  • Rotate90FlipXY: 90 Grad Rotation mit horizontaler und vertikaler Flipping
  • Rotate90FlipY: 90 Grad Rotation mit vertikaler Flipping

Um ein Bild in C# zu drehen und zu flippen, folgen Sie diesen Schritten:

Das folgende Code-Snippet illustriert, wie man ein Bild gleichzeitig dreht und flipt:

// Load the image file
using (var image = Aspose.Imaging.Image.Load("input.jpg"))
{
    // Rotate the image by 180 degrees and flip horizontally
    image.RotateFlip(Aspose.Imaging.RotateFlipType.Rotate180FlipX);
    
    // Save the updated image
    image.Save("rotated-flipped.jpg");
}

Das Bild nach der Anwendung der Rotation und Flipping sieht wie folgt aus:

Rotate and flip an image in C#

Rotate and Flip an Image

C# Rotate Bilder mit einer kostenlosen Lizenz

You can Erhalten Sie eine freie vorübergehende Lizenz to rotate images without any evaluation limitations.

Schlussfolgerungen

In this article, you learned how to programmatically rotate images in C# using the $99 Aspose.Imaging plugin. You also explored the functionality to rotate and flip images simultaneously while maintaining the quality of the output. For more insights into .NET image processing libraries, including a comparison of available .NET image manipulation libraries, check out the Dokumentation. You can also download the source code samples of the API from GitHub. If you have any queries, feel free to reach us at our Forum.

Sehen Sie auch

More in this category