Class GifOptions
ชื่อพื้นที่: Aspose.Imaging.ImageOptions การประกอบ: Aspose.Imaging.dll (25.4.0)
API for Graphical Interchange Format (GIF) การสร้างไฟล์ภาพแบบสกรูผู้พัฒนาตัวเลือกที่ครอบคลุมสําหรับการสร้างภาพ GIF ด้วยความแม่นยําการควบคุม ด้วยคุณสมบัติในการตั้งค่าสีพื้นหลังสีแพลตฟอร์มสีความละเอียดประเภทการเชื่อมต่อสีโปร่งใสคอนเทนเนอร์ metadata XMP และภาพการบีบอัด API นี้ช่วยให้มีความยืดหยุ่นและมีประสิทธิภาพในการสร้างที่เพิ่มประสิทธิภาพและ GIF ที่ดึงดูดภาพที่กําหนดเองตามความต้องการการใช้งานเฉพาะ
[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 จะถูกโหลดเป็นตัวอย่างของ Image แล้วจะถูกส่งออกไปยังรูปแบบต่างๆ
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));
}
ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการแปลงภาพ vector multipage เป็นรูปแบบ 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);
}
ตัวอย่างนี้แสดงให้เห็นถึงวิธีการโหลดข้อมูล Pixel ใน Array ของ Type Color การจัดการ array และตั้งค่ากลับไปยังภาพ ในการดําเนินการเหล่านี้ ตัวอย่างนี้สร้างไฟล์ภาพใหม่ (ในรูปแบบ 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 background color index
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 บิตต่อสีหลักที่สามารถสร้างได้ภาพนี้ควรตั้งค่าเพื่อแสดงให้เห็นถึงความอุดมสมบูรณ์ของแพลตฟอร์มเดิมแม้ว่าไม่ใช่สีทั้งหมดpalette สามารถใช้ได้บนเครื่องกําเนิด
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 มีสีโปร่งใสหรือไม่หากค่าคืนเงินเป็น 0 0 0, คุณสมบัตินี้ถูกครอบคลุมโดยพื้นฐานของภาพแหล่งที่มา
[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
รับหรือตั้งค่าความแตกต่าง pixel สูงสุดที่อนุญาต หากขนาดใหญ่กว่าศูนย์การบีบอัดการสูญเสียจะใช้คะแนนที่แนะนําสําหรับการบีบอัดการสูญเสียที่ดีที่สุดคือ 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 - ปัจจัยที่ใช้ในการคํานวณการเข้าถึงของความสัมพันธ์ด้านของ pixel ในภาพต้นฉบับ หากหมายเลขที่ 0 หมายเลขที่ 0 หมายเลขที่ 0เป็นคํานวณขึ้นอยู่กับสูตร:Aspect Ratio = (Pixel Aspect Ratio + 15) / 64Pixel Aspect Ratio ได้รับการกําหนดไว้เป็น coeent ของ pixelความกว้างมากกว่าความสูง ความกว้างของมูลค่าในฟิลด์นี้ช่วยให้ข้อมูลจําเพาะของ pixel ที่กว้างที่สุด 4:1 ไปยัง pixel ที่สูงที่สุด1:4 ในการเพิ่มขึ้นของ 1/64thหมายเลข:0 - ไม่มีการแจ้งเตือนเกี่ยวกับความสัมพันธ์ด้านใด ๆ1..255 - ราคาที่ใช้ในการคํานวณ