WebPImage

WebPImage(Stream)

Initialisiert eine neue Instanz vonWebPImage class aus stream.

public WebPImage(Stream stream)
ParameterTypBeschreibung
streamStreamDas Stream-WebP-Bild.

Beispiele

Dieses Beispiel zeigt, wie ein WebP-Bild aus einem Dateistream geladen und in PNG gespeichert wird.

[C#]

string dir = "c:\\temp\\";

// Laden Sie ein WebP-Bild aus einem Dateistream.
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "test.webp"))
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(stream))
{
    // Als PNG speichern
    // Beachten Sie, dass nur der aktive Frame in PNG gespeichert wird, da PNG kein mehrseitiges Format ist.
    webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

Siehe auch


WebPImage(Stream, LoadOptions)

Initialisiert eine neue Instanz vonWebPImage Klasse aus stream.

public WebPImage(Stream stream, LoadOptions loadOptions)
ParameterTypBeschreibung
streamStreamDas Stream-WebP-Bild.
loadOptionsLoadOptionsDie Ladeoptionen.

Siehe auch


WebPImage(string)

Initialisiert eine neue Instanz vonWebPImage Klasse aus Datei.

public WebPImage(string path)
ParameterTypBeschreibung
pathStringDer Pfad zur Datei WebP Image

Beispiele

Dieses Beispiel zeigt, wie ein WebP-Bild aus einer Datei geladen und im PNG-Format gespeichert wird.

[C#]

string dir = "c:\\temp\\";

// Laden Sie ein WebP-Bild aus einer Datei.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(dir + "test.webp"))
{
    // Als PNG speichern
    // Beachten Sie, dass nur der aktive Frame in PNG gespeichert wird, da PNG kein mehrseitiges Format ist.
    webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

Siehe auch


WebPImage(string, LoadOptions)

Initialisiert eine neue Instanz vonWebPImage Klasse aus Datei.

public WebPImage(string path, LoadOptions loadOptions)
ParameterTypBeschreibung
pathStringDer Pfad zur Datei WebP Image
loadOptionsLoadOptionsDie Ladeoptionen.

Siehe auch


WebPImage(RasterImage)

Initialisiert eine neue Instanz vonWebPImage Klasse von rasterImage.

public WebPImage(RasterImage rasterImage)
ParameterTypBeschreibung
rasterImageRasterImageDas Rasterbild.

Beispiele

Dieses Beispiel zeigt, wie Sie ein WebP-Bild aus einem anderen Rasterbild erstellen.

[C#]

string dir = "c:\\temp\\";

// Laden Sie ein PNG-Bild mit 100 x 100 Pixel.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100))
{
    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);

    // Das gesamte Bild rot füllen.
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    graphics.FillRectangle(brush, pngImage.Bounds);

    // Erstellen Sie ein WebP-Bild basierend auf dem PNG-Bild.
    using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(pngImage))
    {
        // Speichern in einer WebP-Datei mit Standardoptionen
        webPImage.Save(dir + "output.webp", new Aspose.Imaging.ImageOptions.WebPOptions());
    }
}

Siehe auch


WebPImage(RasterImage, LoadOptions)

Initialisiert eine neue Instanz vonWebPImage Klasse von rasterImage.

public WebPImage(RasterImage rasterImage, LoadOptions loadOptions)
ParameterTypBeschreibung
rasterImageRasterImageDas Rasterbild.
loadOptionsLoadOptionsDie Ladeoptionen.

Siehe auch


WebPImage(int, int, WebPOptions)

Initialisiert eine neue Instanz vonWebPImage Klasse mit leerem Bild.

public WebPImage(int width, int height, WebPOptions options)
ParameterTypBeschreibung
widthInt32Die Bildbreite
heightInt32Die Bildhöhe.
optionsWebPOptionsDie Optionen.

Beispiele

Dieses Beispiel zeigt, wie Sie ein WebP-Image mit den angegebenen Optionen von Grund auf neu erstellen.

[C#]

string dir = "c:\\temp\\";

Aspose.Imaging.ImageOptions.WebPOptions createOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
createOptions.Lossless = true;
createOptions.Quality = 100f;
//createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "output.webp");

// Erstellen Sie ein WebP-Bild mit 100 x 100 Pixel.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
{
    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(webPImage);

    // Das gesamte Bild rot füllen.
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    graphics.FillRectangle(brush, webPImage.Bounds);

    // In einer WebP-Datei speichern
    webPImage.Save(dir + "output.webp");
}

Dieses Beispiel zeigt, wie Sie mit den angegebenen Optionen ein animiertes WebP-Bild mit mehreren Frames erstellen.

[C#]

string dir = "c:\\temp\\";

Aspose.Imaging.ImageOptions.WebPOptions createOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
createOptions.Lossless = true;
createOptions.Quality = 100f;
createOptions.AnimBackgroundColor = (uint)Aspose.Imaging.Color.Gray.ToArgb();

// Der Standardframe plus 36 + 36 zusätzliche Frames.
createOptions.AnimLoopCount = 36 + 36 + 1;

// Erstellen Sie ein WebP-Bild mit 100 x 100 Pixel.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
{
    // Der erste Kreis ist rot
    Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);

    // Der zweite Kreis ist schwarz
    Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);

    // Erhöhen Sie allmählich den Winkel der roten Bogenform.
    for (int angle = 10; angle <= 360; angle += 10)
    {
        Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);
        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
        graphics.FillPie(brush1, block.Bounds, 0, angle);

        webPImage.AddBlock(block);
    }

    // Erhöhen Sie allmählich den Winkel des schwarzen Bogens und löschen Sie den roten Bogen.
    for (int angle = 10; angle <= 360; angle += 10)
    {
        Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);

        Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
        graphics.FillPie(brush2, block.Bounds, 0, angle);
        graphics.FillPie(brush1, block.Bounds, angle, 360 - angle);

        webPImage.AddBlock(block);
    }

    // In einer WebP-Datei speichern
    webPImage.Save(dir + "output.webp");
}

Siehe auch


WebPImage(int, int, WebPOptions, LoadOptions)

Initialisiert eine neue Instanz vonWebPImage Klasse mit leerem Bild.

public WebPImage(int width, int height, WebPOptions options, LoadOptions loadOptions)
ParameterTypBeschreibung
widthInt32Die Bildbreite
heightInt32Die Bildhöhe.
optionsWebPOptionsDie Optionen.
loadOptionsLoadOptionsDie Ladeoptionen.

Siehe auch