WebPImage

WebPImage(Stream)

Yeni bir örneğini başlatırWebPImage class akışından.

public WebPImage(Stream stream)
ParametreTipTanım
streamStreamAkış WebP görüntüsü.

Örnekler

Bu örnek, bir WebP görüntüsünün bir dosya akışından nasıl yükleneceğini ve PNG’ye nasıl kaydedileceğini gösterir.

[C#]

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

// Bir dosya akışından bir WebP görüntüsü yükleyin.
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))
{
    // PNG'ye kaydet
    // PNG çok sayfalı bir format olmadığı için yalnızca etkin çerçevenin PNG'ye kaydedileceğini unutmayın.
    webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

Ayrıca bakınız


WebPImage(Stream, LoadOptions)

Yeni bir örneğini başlatırWebPImage stream. sınıfından

public WebPImage(Stream stream, LoadOptions loadOptions)
ParametreTipTanım
streamStreamAkış WebP görüntüsü.
loadOptionsLoadOptionsYük seçenekleri.

Ayrıca bakınız


WebPImage(string)

Yeni bir örneğini başlatırWebPImage dosyadan sınıf.

public WebPImage(string path)
ParametreTipTanım
pathStringWebP Görüntüsü dosya yolu

Örnekler

Bu örnek, bir dosyadan bir WebP görüntüsünün nasıl yükleneceğini ve PNG’ye nasıl kaydedileceğini gösterir.

[C#]

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

// Bir dosyadan bir WebP görüntüsü yükleyin.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(dir + "test.webp"))
{
    // PNG'ye kaydet
    // PNG çok sayfalı bir format olmadığı için yalnızca etkin çerçevenin PNG'ye kaydedileceğini unutmayın.
    webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

Ayrıca bakınız


WebPImage(string, LoadOptions)

Yeni bir örneğini başlatırWebPImage dosyadan sınıf.

public WebPImage(string path, LoadOptions loadOptions)
ParametreTipTanım
pathStringWebP Görüntüsü dosya yolu
loadOptionsLoadOptionsYük seçenekleri.

Ayrıca bakınız


WebPImage(RasterImage)

Yeni bir örneğini başlatırWebPImage rasterImage. ‘den sınıf

public WebPImage(RasterImage rasterImage)
ParametreTipTanım
rasterImageRasterImageRaster görüntü.

Örnekler

Bu örnek, başka bir tarama görüntüsünden bir WebP görüntüsünün nasıl oluşturulacağını gösterir.

[C#]

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

// 100x100 piksellik bir PNG resmi yükleyin.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100))
{
    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);

    // Resmin tamamını kırmızı ile doldurun.
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    graphics.FillRectangle(brush, pngImage.Bounds);

    // PNG görüntüsünü temel alan bir WebP görüntüsü oluşturun.
    using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(pngImage))
    {
        // Varsayılan seçeneklerle bir WebP dosyasına kaydet
        webPImage.Save(dir + "output.webp", new Aspose.Imaging.ImageOptions.WebPOptions());
    }
}

Ayrıca bakınız


WebPImage(RasterImage, LoadOptions)

Yeni bir örneğini başlatırWebPImage rasterImage. ‘den sınıf

public WebPImage(RasterImage rasterImage, LoadOptions loadOptions)
ParametreTipTanım
rasterImageRasterImageRaster görüntü.
loadOptionsLoadOptionsYük seçenekleri.

Ayrıca bakınız


WebPImage(int, int, WebPOptions)

Yeni bir örneğini başlatırWebPImage boş resimli sınıf.

public WebPImage(int width, int height, WebPOptions options)
ParametreTipTanım
widthInt32görüntü genişliği
heightInt32Görüntü yüksekliği.
optionsWebPOptionsSeçenekler.

Örnekler

Bu örnek, sıfırdan belirtilen seçeneklerle bir WebP görüntüsünün nasıl oluşturulacağını gösterir.

[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");

// 100x100 piksellik bir WebP görüntüsü oluşturun.
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);

    // Resmin tamamını kırmızı ile doldurun.
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    graphics.FillRectangle(brush, webPImage.Bounds);

    // Bir WebP dosyasına kaydet
    webPImage.Save(dir + "output.webp");
}

Bu örnek, belirtilen seçeneklerle çok çerçeveli bir animasyonlu WebP görüntüsünün nasıl oluşturulacağını gösterir.

[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();

// Varsayılan çerçeve artı 36 + 36 ek çerçeve.
createOptions.AnimLoopCount = 36 + 36 + 1;

// 100x100 piksellik bir WebP görüntüsü oluşturun.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
{
    // İlk daire kırmızı
    Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);

    // İkinci daire siyah
    Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);

    // Kırmızı yay şeklinin açısını kademeli olarak artırın.
    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);
    }

    // Siyah yayın açısını kademeli olarak artırın ve kırmızı yayı silin.
    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);
    }

    // Bir WebP dosyasına kaydet
    webPImage.Save(dir + "output.webp");
}

Ayrıca bakınız


WebPImage(int, int, WebPOptions, LoadOptions)

Yeni bir örneğini başlatırWebPImage boş resimli sınıf.

public WebPImage(int width, int height, WebPOptions options, LoadOptions loadOptions)
ParametreTipTanım
widthInt32görüntü genişliği
heightInt32Görüntü yüksekliği.
optionsWebPOptionsSeçenekler.
loadOptionsLoadOptionsYük seçenekleri.

Ayrıca bakınız