GifImage

GifImage(GifFrameBlock, IColorPalette)

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

public GifImage(GifFrameBlock firstFrame, IColorPalette globalPalette)
معامليكتبوصف
firstFrameGifFrameBlockالإطار الأول لتهيئة صورة gif به.
globalPaletteIColorPaletteاللوحة العالمية المراد استخدامها. لاحظ إذا كان كلاهماfirstFrame وglobalPalette فارغة ثم يتم استخدام لوحة الألوان العامة الافتراضية.

استثناءات

استثناءحالة
ArgumentNullExceptionلا يمكن أن يكون الإطار فارغًا ؛ FirstFrame
ArgumentExceptionالإطار الأول ينتمي بالفعل إلى بعض الصور الأخرى. تحقق من خاصية الحاوية. ؛ FirstFrame
GifImageExceptionيجب أن تحتوي اللوحة المحددة على عدد إدخالات يساوي قوة 2. الحد الأدنى لحجم اللوحة هو 2 ، والحد الأقصى هو 256.

أمثلة

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

[C#]

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

// قم بإنشاء كتلة إطار GIF بحجم 100 × 100 بكسل.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
    // املأ الكتلة بالكامل باللون الأحمر.
    Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    gr.FillRectangle(brush, firstBlock.Bounds);

    // استخدم لوحة 4 بت لتقليل حجم الصورة. يمكن أن تسوء الجودة.
    Aspose.Imaging.IColorPalette palette = Aspose.Imaging.ColorPaletteHelper.Create4Bit();

    using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock, palette))
    {
        gifImage.Save(dir + "output.gif");
    }
}

أنظر أيضا


GifImage(GifFrameBlock)

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

public GifImage(GifFrameBlock firstFrame)
معامليكتبوصف
firstFrameGifFrameBlockالإطار الأول لتهيئة صورة gif به.

استثناءات

استثناءحالة
ArgumentNullExceptionلا يمكن أن يكون الإطار فارغًا ؛ FirstFrame
ArgumentExceptionالإطار الأول ينتمي بالفعل إلى بعض الصور الأخرى. تحقق من خاصية الحاوية. ؛ FirstFrame
GifImageExceptionيجب أن تحتوي اللوحة المحددة على عدد إدخالات يساوي قوة 2. الحد الأدنى لحجم اللوحة هو 2 ، والحد الأقصى هو 256.

أمثلة

يوضح هذا المثال كيفية إنشاء صورة GIF وحفظها في ملف.

[C#]

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

// قم بإنشاء كتلة إطار GIF بحجم 100 × 100 بكسل.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
    // املأ الكتلة بالكامل باللون الأحمر.
    Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    gr.FillRectangle(brush, firstBlock.Bounds);

    using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
    {
        gifImage.Save(dir + "output.gif");
    }
}

يوضح المثال التالي كيفية إنشاء صورة GIF متحركة من كتل GIF فردية.

[C#]

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

// أنشئ صورة بتنسيق GIF 100 × 100 بكسل.
// الكتلة الأولى سوداء بالكامل بشكل افتراضي.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
    // الدائرة الأولى حمراء
    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.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);

        Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
        gr.FillPie(brush1, block.Bounds, 0, angle);

        gifImage.AddBlock(block);
    }

    // زد زاوية القوس الأسود تدريجيًا وامسح القوس الأحمر.
    for (int angle = 10; angle <= 360; angle += 10)
    {
        Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);

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

        gifImage.AddBlock(block);
    }

    gifImage.Save(dir + "animated_radar.gif");
}

أنظر أيضا


GifImage(GifFrameBlock, IColorPalette, bool, byte, byte, byte, bool)

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

public GifImage(GifFrameBlock firstFrame, IColorPalette globalPalette, bool isPaletteSorted, 
    byte paletteColorResolution, byte paletteBackgroundColorIndex, byte aspectRatio, 
    bool hasTrailer)
معامليكتبوصف
firstFrameGifFrameBlockالإطار الأول لتهيئة صورة gif به.
globalPaletteIColorPaletteاللوحة العالمية المراد استخدامها. لاحظ إذا كان كلاهماfirstFrame وglobalPalette فارغة ثم يتم استخدام لوحة الألوان العامة الافتراضية.
isPaletteSortedBooleanإذا تم التعيين علىحقيقي يتم فرز اللوحة. لاحظ استخدام المعلمة عندماglobalPalette هو ليس لاشيء.
paletteColorResolutionByteدقة لون اللوحة. لاحظ استخدام المعلمة عندماglobalPalette هو ليس لاشيء.
paletteBackgroundColorIndexByteفهرس لون خلفية اللوحة.
aspectRatioByteنسبة العرض إلى الارتفاع.
hasTrailerBooleanإذا تم التعيين علىحقيقي صورة gif لها مقطع دعائي وإلا فلن يتم كتابة مقطع دعائي في نهاية البث.

استثناءات

استثناءحالة
ArgumentNullExceptionلا يمكن أن يكون الإطار فارغًا ؛ FirstFrame
ArgumentExceptionالإطار الأول ينتمي بالفعل إلى بعض الصور الأخرى. تحقق من خاصية الحاوية. ؛ FirstFrame
GifImageExceptionيجب أن تحتوي اللوحة المحددة على عدد إدخالات يساوي قوة 2. الحد الأدنى لحجم اللوحة هو 2 ، والحد الأقصى هو 256.

أنظر أيضا