Class GifOptions
اسم الفضاء : Aspose.Imaging.ImageOptions تجميع: Aspose.Imaging.dll (25.4.0)
توفر API for Graphical Interchange Format (GIF) لإنشاء ملف الصورةتطوير خيارات شاملة لإنتاج صور GIF بدقةمع ميزات لتعيين لون الخلفية، لوحة الألوان، القرار،النوع المترابط ، اللون الشفاف ، حاوية البيانات الميتا XMP ، والصورةضغط، هذا API يضمن المرونة والكفاءة في إنشاء تحسينو GIFs جذابة بصريًا مخصصة لمتطلبات التطبيق المحددة.
[JsonObject(MemberSerialization.OptIn)]
public class GifOptions : ImageOptionsBase, IDisposable, IHasXmpData, IHasMetadata, ICloneable
Inheritance
object ← DisposableObject ← ImageOptionsBase ← GifOptions
Implements
IDisposable , IHasXmpData , IHasMetadata , ICloneable
الأعضاء الموروثين
ImageOptionsBase.Clone() , ImageOptionsBase.ReleaseManagedResources() , ImageOptionsBase.KeepMetadata , ImageOptionsBase.XmpData , ImageOptionsBase.Source , ImageOptionsBase.Palette , ImageOptionsBase.ResolutionSettings , ImageOptionsBase.VectorRasterizationOptions , ImageOptionsBase.BufferSizeHint , ImageOptionsBase.MultiPageOptions , ImageOptionsBase.FullFrame , ImageOptionsBase.ProgressEventHandler , DisposableObject.Dispose() , DisposableObject.ReleaseManagedResources() , DisposableObject.ReleaseUnmanagedResources() , DisposableObject.VerifyNotDisposed() , DisposableObject.Disposed , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
هذا المثال يظهر استخدام الفصول المختلفة من SaveOptions Namespace لأغراض التصدير. يتم تحميل صورة من نوع Gif في مثال من الصورة ثم يتم تصديرها إلى عدة تنسيقات.
string dir = "c:\\temp\\";
//Load an existing image (of type Gif) in an instance of Image class
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
//Export to BMP file format using the default options
image.Save(dir + "output.bmp", new Aspose.Imaging.ImageOptions.BmpOptions());
//Export to JPEG file format using the default options
image.Save(dir + "output.jpg", new Aspose.Imaging.ImageOptions.JpegOptions());
//Export to PNG file format using the default options
image.Save(dir + "output.png", new Aspose.Imaging.ImageOptions.PngOptions());
//Export to TIFF file format using the default options
image.Save(dir + "output.tif", new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default));
}
يظهر المثال التالي كيفية تحويل صورة فيكتور متعددة الصفحات إلى تنسيق GIF بشكل عام دون الإشارة إلى نوع صورة معين.
string dir = "C:\\aspose.imaging\\net\\misc\\ImagingReleaseQATester\\Tests\\testdata\\2548";
string inputFilePath = System.IO.Path.Combine(dir, "Multipage.cdr");
string outputFilePath = System.IO.Path.Combine(dir, "Multipage.cdr.gif");
Aspose.Imaging.ImageOptionsBase exportOptions = new Aspose.Imaging.ImageOptions.GifOptions();
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFilePath))
{
exportOptions.MultiPageOptions = null;
// Export only first two pages. These pages will be presented as animated frames in the output GIF.
Aspose.Imaging.IMultipageImage multipageImage = image as Aspose.Imaging.IMultipageImage;
if (multipageImage != null && (multipageImage.Pages != null && multipageImage.PageCount > 2))
{
exportOptions.MultiPageOptions = new Aspose.Imaging.ImageOptions.MultiPageOptions(new Aspose.Imaging.IntRange(0, 2));
}
if (image is Aspose.Imaging.VectorImage)
{
exportOptions.VectorRasterizationOptions = (Aspose.Imaging.ImageOptions.VectorRasterizationOptions)image.GetDefaultOptions(new object[] { Aspose.Imaging.Color.White, image.Width, image.Height });
exportOptions.VectorRasterizationOptions.TextRenderingHint = Aspose.Imaging.TextRenderingHint.SingleBitPerPixel;
exportOptions.VectorRasterizationOptions.SmoothingMode = Aspose.Imaging.SmoothingMode.None;
}
image.Save(outputFilePath, exportOptions);
}
يظهر هذا المثال كيفية تحميل معلومات بيكسيل في سلسلة من نوع اللون، وتلاعب السلسلة وإعادتها إلى الصورة.لإجراء هذه العمليات، يخلق هذا المثال ملف صورة جديد (في تنسيق GIF) uisng كائن MemoryStream.
//Create an instance of MemoryStream
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
//Create an instance of GifOptions and set its various properties including the Source property
Aspose.Imaging.ImageOptions.GifOptions gifOptions = new Aspose.Imaging.ImageOptions.GifOptions();
gifOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);
//Create an instance of Image
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(gifOptions, 500, 500))
{
//Get the pixels of image by specifying the area as image boundary
Aspose.Imaging.Color[] pixels = image.LoadPixels(image.Bounds);
//Loop over the Array and sets color of alrenative indexed pixel
for (int index = 0; index < pixels.Length; index++)
{
if (index % 2 == 0)
{
//Set the indexed pixel color to yellow
pixels[index] = Aspose.Imaging.Color.Yellow;
}
else
{
//Set the indexed pixel color to blue
pixels[index] = Aspose.Imaging.Color.Blue;
}
}
//Apply the pixel changes to the image
image.SavePixels(image.Bounds, pixels);
// save all changes.
image.Save();
}
// Write MemoryStream to File
using (System.IO.FileStream fileStream = new System.IO.FileStream(@"C:\temp\output.gif", System.IO.FileMode.Create))
{
stream.WriteTo(fileStream);
}
}
Constructors
GifOptions()
يبدأ مثالًا جديدًا من فئة Aspose.Imaging.ImageOptions.GifOptions.
[JsonConstructor]
public GifOptions()
GifOptions(GifOptions)
يبدأ مثالًا جديدًا من فئة Aspose.Imaging.ImageOptions.GifOptions.
public GifOptions(GifOptions gifOptions)
Parameters
gifOptions
GifOptions
خيارات GIF
Properties
BackgroundColor
يحصل أو يضع لون الخلفية.
[JsonProperty]
public Color BackgroundColor { get; set; }
قيمة الممتلكات
BackgroundColorIndex
يحصل أو يضع مؤشر الألوان الخلفية GIF.
public byte BackgroundColorIndex { get; set; }
قيمة الممتلكات
ColorResolution
يحصل أو يضع حل الألوان GIF.
public byte ColorResolution { get; set; }
قيمة الممتلكات
Examples
هذا المثال يظهر كيفية حفظ صورة BMP إلى تنسيق GIF باستخدام خيارات مختلفة.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(1000, 1000))
{
// Fill the entire image with the blue-yellow gradient.
Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
new Aspose.Imaging.Point(0, 0),
new Aspose.Imaging.Point(bmpImage.Width, bmpImage.Height),
Aspose.Imaging.Color.Blue,
Aspose.Imaging.Color.Yellow);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(bmpImage);
graphics.FillRectangle(gradientBrush, bmpImage.Bounds);
Aspose.Imaging.ImageOptions.GifOptions saveOptions = new Aspose.Imaging.ImageOptions.GifOptions();
// The number of bits required to store a color, minus 1.
saveOptions.ColorResolution = 7;
// Palette correction means that whenever image is exported to GIF the source image colors will be analyzed
// in order to build the best matching palette (in case image Palette does not exist or not specified in the options)
saveOptions.DoPaletteCorrection = true;
// Load a GIF image in a progressive way.
// An interlaced GIF doesn't display its scanlines linearly from top to bottom, but instead reorders it
// so the content of the GIF becomes clear even before it finishes loading.
saveOptions.Interlaced = true;
// Save as a lossless GIF.
using (System.IO.Stream stream = System.IO.File.OpenWrite(dir + "output.gif"))
{
bmpImage.Save(stream, saveOptions);
System.Console.WriteLine("The size of the lossless GIF: {0} bytes.", stream.Length);
}
// Set the maximum allowed pixel difference. If greater than zero, lossy compression will be used.
// The recommended value for optimal lossy compression is 80. 30 is very light compression, 200 is heavy.
saveOptions.MaxDiff = 80;
// Save as a lossy GIF.
using (System.IO.Stream stream = System.IO.File.OpenWrite(dir + "output.lossy.gif"))
{
bmpImage.Save(stream, saveOptions);
System.Console.WriteLine("The size of the lossy GIF: {0} bytes.", stream.Length);
}
}
//The output may look like this:
//The size of the lossless GIF: 212816 bytes.
//The size of the lossy GIF: 89726 bytes.
Remarks
حل الألوان - عدد البيتات لكل لون رئيسي متاحإلى الصورة الأصلية، minus 1.هذه القيمة تمثل حجمكل اللوحة التي كانت الألوان الموجودة في الرسوماتاختيار، وليس عدد الألوان المستخدمة في الواقع في الرسم البياني.على سبيل المثال، إذا كان القيمة في هذا المجال 3، ثم لوحةكانت الصورة الأصلية لديها 4 بت لكل لون رئيسي متوفرة لإنشاءهذه القيمة يجب أن تكون محددة لإشارة إلى ثروةاللوحة الأصلية ، حتى لو لم تكن كل لون من كلالبلاط متوفر على آلة المصدر.
DoPaletteCorrection
يحصل أو يضع قيمة تشير إلى ما إذا كان يتم تطبيق تصحيح الباليه.
public bool DoPaletteCorrection { get; set; }
قيمة الممتلكات
Examples
هذا المثال يظهر كيفية حفظ صورة BMP إلى تنسيق GIF باستخدام خيارات مختلفة.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(1000, 1000))
{
// Fill the entire image with the blue-yellow gradient.
Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
new Aspose.Imaging.Point(0, 0),
new Aspose.Imaging.Point(bmpImage.Width, bmpImage.Height),
Aspose.Imaging.Color.Blue,
Aspose.Imaging.Color.Yellow);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(bmpImage);
graphics.FillRectangle(gradientBrush, bmpImage.Bounds);
Aspose.Imaging.ImageOptions.GifOptions saveOptions = new Aspose.Imaging.ImageOptions.GifOptions();
// The number of bits required to store a color, minus 1.
saveOptions.ColorResolution = 7;
// Palette correction means that whenever image is exported to GIF the source image colors will be analyzed
// in order to build the best matching palette (in case image Palette does not exist or not specified in the options)
saveOptions.DoPaletteCorrection = true;
// Load a GIF image in a progressive way.
// An interlaced GIF doesn't display its scanlines linearly from top to bottom, but instead reorders it
// so the content of the GIF becomes clear even before it finishes loading.
saveOptions.Interlaced = true;
// Save as a lossless GIF.
using (System.IO.Stream stream = System.IO.File.OpenWrite(dir + "output.gif"))
{
bmpImage.Save(stream, saveOptions);
System.Console.WriteLine("The size of the lossless GIF: {0} bytes.", stream.Length);
}
// Set the maximum allowed pixel difference. If greater than zero, lossy compression will be used.
// The recommended value for optimal lossy compression is 80. 30 is very light compression, 200 is heavy.
saveOptions.MaxDiff = 80;
// Save as a lossy GIF.
using (System.IO.Stream stream = System.IO.File.OpenWrite(dir + "output.lossy.gif"))
{
bmpImage.Save(stream, saveOptions);
System.Console.WriteLine("The size of the lossy GIF: {0} bytes.", stream.Length);
}
}
//The output may look like this:
//The size of the lossless GIF: 212816 bytes.
//The size of the lossy GIF: 89726 bytes.
Remarks
تصحيح الألواح يعني أنه في كل مرة يتم فيها تصدير الصورة إلى GIF ، سيتم تحليل ألوان الصورة المصدريةلإنشاء أفضل لوحة مطابقة (في حالة لوحة الصورة لا توجد أو غير محددة في الخيارات).وتستغرق عملية التحليل بعض الوقت على الرغم من أن الصورة الناتجة ستحصل على أفضل لوحة الألوان المطابقة والنتيجة أفضل بصريا.
HasTrailer
يحصل أو يضع قيمة تشير إلى ما إذا كان GIF لديه متصفح.
public bool HasTrailer { get; set; }
قيمة الممتلكات
HasTransparentColor
يحصل أو يضع قيمة تشير إلى ما إذا كانت صورة GIF لها لون شفاف.إذا كانت قيمة العائد صفرهذه الممتلكات تتجاوزها السياق المصدر للصورة.
[JsonProperty]
public bool? HasTransparentColor { get; set; }
قيمة الممتلكات
bool ?
Interlaced
صحيح إذا كان الصورة يجب أن تكون مترابطة.
public bool Interlaced { get; set; }
قيمة الممتلكات
Examples
هذا المثال يظهر كيفية حفظ صورة BMP إلى تنسيق GIF باستخدام خيارات مختلفة.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(1000, 1000))
{
// Fill the entire image with the blue-yellow gradient.
Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
new Aspose.Imaging.Point(0, 0),
new Aspose.Imaging.Point(bmpImage.Width, bmpImage.Height),
Aspose.Imaging.Color.Blue,
Aspose.Imaging.Color.Yellow);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(bmpImage);
graphics.FillRectangle(gradientBrush, bmpImage.Bounds);
Aspose.Imaging.ImageOptions.GifOptions saveOptions = new Aspose.Imaging.ImageOptions.GifOptions();
// The number of bits required to store a color, minus 1.
saveOptions.ColorResolution = 7;
// Palette correction means that whenever image is exported to GIF the source image colors will be analyzed
// in order to build the best matching palette (in case image Palette does not exist or not specified in the options)
saveOptions.DoPaletteCorrection = true;
// Load a GIF image in a progressive way.
// An interlaced GIF doesn't display its scanlines linearly from top to bottom, but instead reorders it
// so the content of the GIF becomes clear even before it finishes loading.
saveOptions.Interlaced = true;
// Save as a lossless GIF.
using (System.IO.Stream stream = System.IO.File.OpenWrite(dir + "output.gif"))
{
bmpImage.Save(stream, saveOptions);
System.Console.WriteLine("The size of the lossless GIF: {0} bytes.", stream.Length);
}
// Set the maximum allowed pixel difference. If greater than zero, lossy compression will be used.
// The recommended value for optimal lossy compression is 80. 30 is very light compression, 200 is heavy.
saveOptions.MaxDiff = 80;
// Save as a lossy GIF.
using (System.IO.Stream stream = System.IO.File.OpenWrite(dir + "output.lossy.gif"))
{
bmpImage.Save(stream, saveOptions);
System.Console.WriteLine("The size of the lossy GIF: {0} bytes.", stream.Length);
}
}
//The output may look like this:
//The size of the lossless GIF: 212816 bytes.
//The size of the lossy GIF: 89726 bytes.
IsPaletteSorted
يحصل أو يضع قيمة تشير إلى ما إذا كانت إدخالات الباليه يتم تصنيفها.
public bool IsPaletteSorted { get; set; }
قيمة الممتلكات
LoopsCount
يحصل أو يحدد عدد الأقواس (الحد الأدنى 1)
public int LoopsCount { get; set; }
قيمة الممتلكات
MaxDiff
يحصل أو يحدد الحد الأقصى المسموح به الفرق بين البكسل.إذا كان أكبر من الصفر، وسيتم استخدام ضغط الخسارة.القيمة الموصى بها للحصول على ضغط الخسارة الأمثل هي 80. 30 ضغط خفيف جدا، 200 ثقيل.يعمل بشكل أفضل عندما يتم إدخال خسارة صغيرة فقط ، وبسبب الحد من خوارزمية الضغط ، فإن مستويات الخسارة العالية للغاية لن تعطي الكثير من الأرباح.نطاق القيم المسموح بها هو [0, 1000].
public int MaxDiff { get; set; }
قيمة الممتلكات
Examples
هذا المثال يظهر كيفية حفظ صورة BMP إلى تنسيق GIF باستخدام خيارات مختلفة.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(1000, 1000))
{
// Fill the entire image with the blue-yellow gradient.
Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
new Aspose.Imaging.Point(0, 0),
new Aspose.Imaging.Point(bmpImage.Width, bmpImage.Height),
Aspose.Imaging.Color.Blue,
Aspose.Imaging.Color.Yellow);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(bmpImage);
graphics.FillRectangle(gradientBrush, bmpImage.Bounds);
Aspose.Imaging.ImageOptions.GifOptions saveOptions = new Aspose.Imaging.ImageOptions.GifOptions();
// The number of bits required to store a color, minus 1.
saveOptions.ColorResolution = 7;
// Palette correction means that whenever image is exported to GIF the source image colors will be analyzed
// in order to build the best matching palette (in case image Palette does not exist or not specified in the options)
saveOptions.DoPaletteCorrection = true;
// Load a GIF image in a progressive way.
// An interlaced GIF doesn't display its scanlines linearly from top to bottom, but instead reorders it
// so the content of the GIF becomes clear even before it finishes loading.
saveOptions.Interlaced = true;
// Save as a lossless GIF.
using (System.IO.Stream stream = System.IO.File.OpenWrite(dir + "output.gif"))
{
bmpImage.Save(stream, saveOptions);
System.Console.WriteLine("The size of the lossless GIF: {0} bytes.", stream.Length);
}
// Set the maximum allowed pixel difference. If greater than zero, lossy compression will be used.
// The recommended value for optimal lossy compression is 80. 30 is very light compression, 200 is heavy.
saveOptions.MaxDiff = 80;
// Save as a lossy GIF.
using (System.IO.Stream stream = System.IO.File.OpenWrite(dir + "output.lossy.gif"))
{
bmpImage.Save(stream, saveOptions);
System.Console.WriteLine("The size of the lossy GIF: {0} bytes.", stream.Length);
}
}
//The output may look like this:
//The size of the lossless GIF: 212816 bytes.
//The size of the lossy GIF: 89726 bytes.
PixelAspectRatio
يحصل أو يضع نسبة الجانب GIF بكسل.
public byte PixelAspectRatio { get; set; }
قيمة الممتلكات
Remarks
Pixel Aspect Ratio - العامل المستخدم لحساب مقارنةمن النسبة الجانبية للبكسل في الصورة الأصلية.إذا كانقيمة الحقل ليست 0، هذا التقارب من نسبة الجانبيتم حسابها على أساس الصيغة:Aspect Ratio = (Pixel Aspect Ratio + 15) / 64يتم تعريف نسبة Pixel Aspect على أنها نسبة Pixel Aspect.عرض فوق ارتفاعها.مجموعة القيمة في هذا المجال تسمحتخصيص أوسع بكسل من 4:1 إلى أعلى بكسل من1:4 في زيادة 1/64th.القيم :0 - لا يتم إعطاء أي معلومات نسبة الجانب.1..255 - القيمة المستخدمة في الحسابات.