WebPImage

WebPImage(Stream)

يقوم بتهيئة مثيل جديد لملفWebPImage class من تيار .

public WebPImage(Stream stream)
معامليكتبوصف
streamStreamصورة تيار WebP.

أمثلة

يوضح هذا المثال كيفية تحميل صورة WebP من دفق ملف وحفظها في PNG.

[C#]

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

// تحميل صورة WebP من دفق ملف.
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
    // لاحظ أنه سيتم تخزين الإطار النشط فقط في PNG ، نظرًا لأن PNG ليس تنسيقًا متعدد الصفحات.
    webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

أنظر أيضا


WebPImage(Stream, LoadOptions)

يقوم بتهيئة مثيل جديد لملفWebPImage فئة من تيار .

public WebPImage(Stream stream, LoadOptions loadOptions)
معامليكتبوصف
streamStreamصورة تيار WebP.
loadOptionsLoadOptionsخيارات التحميل.

أنظر أيضا


WebPImage(string)

يقوم بتهيئة مثيل جديد لملفWebPImage فئة من ملف .

public WebPImage(string path)
معامليكتبوصف
pathStringمسار ملف WebP Image

أمثلة

يوضح هذا المثال كيفية تحميل صورة WebP من ملف وحفظها في PNG.

[C#]

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

// تحميل صورة WebP من ملف.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(dir + "test.webp"))
{
    // حفظ في PNG
    // لاحظ أنه سيتم تخزين الإطار النشط فقط في PNG ، نظرًا لأن PNG ليس تنسيقًا متعدد الصفحات.
    webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

أنظر أيضا


WebPImage(string, LoadOptions)

يقوم بتهيئة مثيل جديد لملفWebPImage فئة من ملف .

public WebPImage(string path, LoadOptions loadOptions)
معامليكتبوصف
pathStringمسار ملف WebP Image
loadOptionsLoadOptionsخيارات التحميل.

أنظر أيضا


WebPImage(RasterImage)

يقوم بتهيئة مثيل جديد لملفWebPImage فئة من الصورة النقطية.

public WebPImage(RasterImage rasterImage)
معامليكتبوصف
rasterImageRasterImageالصورة النقطية.

أمثلة

يوضح هذا المثال كيفية إنشاء صورة WebP من صورة نقطية أخرى.

[C#]

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

// قم بتحميل صورة PNG بحجم 100 × 100 بكسل.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100))
{
    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);

    // املأ الصورة بأكملها باللون الأحمر.
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    graphics.FillRectangle(brush, pngImage.Bounds);

    // قم بإنشاء صورة WebP بناءً على صورة PNG.
    using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(pngImage))
    {
        // حفظ في ملف WebP بالخيارات الافتراضية
        webPImage.Save(dir + "output.webp", new Aspose.Imaging.ImageOptions.WebPOptions());
    }
}

أنظر أيضا


WebPImage(RasterImage, LoadOptions)

يقوم بتهيئة مثيل جديد لملفWebPImage فئة من الصورة النقطية.

public WebPImage(RasterImage rasterImage, LoadOptions loadOptions)
معامليكتبوصف
rasterImageRasterImageالصورة النقطية.
loadOptionsLoadOptionsخيارات التحميل.

أنظر أيضا


WebPImage(int, int, WebPOptions)

يقوم بتهيئة مثيل جديد لملفWebPImage فئة مع صورة فارغة.

public WebPImage(int width, int height, WebPOptions options)
معامليكتبوصف
widthInt32عرض الصورة
heightInt32ارتفاع الصورة.
optionsWebPOptionsالخيارات.

أمثلة

يوضح هذا المثال كيفية إنشاء صورة WebP بالخيارات المحددة من البداية.

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

// قم بإنشاء صورة WebP بحجم 100 × 100 بكسل.
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);

    // املأ الصورة بأكملها باللون الأحمر.
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    graphics.FillRectangle(brush, webPImage.Bounds);

    // حفظ في ملف WebP
    webPImage.Save(dir + "output.webp");
}

يوضح هذا المثال كيفية إنشاء صورة WebP متحركة متعددة الإطارات باستخدام الخيارات المحددة.

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

// الإطار الافتراضي بالإضافة إلى 36 + 36 إطارًا إضافيًا.
createOptions.AnimLoopCount = 36 + 36 + 1;

// قم بإنشاء صورة WebP بحجم 100 × 100 بكسل.
using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
{
    // الدائرة الأولى حمراء
    Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);

    // الدائرة الثانية سوداء
    Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);

    // زد زاوية شكل القوس الأحمر تدريجيًا.
    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);
    }

    // زد زاوية القوس الأسود تدريجيًا وامسح القوس الأحمر.
    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);
    }

    // حفظ في ملف WebP
    webPImage.Save(dir + "output.webp");
}

أنظر أيضا


WebPImage(int, int, WebPOptions, LoadOptions)

يقوم بتهيئة مثيل جديد لملفWebPImage فئة مع صورة فارغة.

public WebPImage(int width, int height, WebPOptions options, LoadOptions loadOptions)
معامليكتبوصف
widthInt32عرض الصورة
heightInt32ارتفاع الصورة.
optionsWebPOptionsالخيارات.
loadOptionsLoadOptionsخيارات التحميل.

أنظر أيضا