Class GifOptions
İsim alanı : Aspose.Imaging.ImageOptions Toplantı: Aspose.Imaging.dll (25.4.0)
GIF (Graphical Interchange Format) resim dosyası oluşturma için APIGIF görüntüleri tam olarak oluşturmak için kapsamlı seçenekler geliştiricilerkontrol. arka plan rengi, renk paleti, çözünürlük ayarlamak için özellikleri ile,Kapalı tip, şeffaf renk, XMP metadata konteyner ve görüntüsıkıştırma, bu API optimize oluşturma esnekliği ve verimliliği sağlarve belirli uygulama gereksinimlerine uyarlanmış görsel olarak çekici GIF’ler.
[JsonObject(MemberSerialization.OptIn)]
public class GifOptions : ImageOptionsBase, IDisposable, IHasXmpData, IHasMetadata, ICloneable
Inheritance
object ← DisposableObject ← ImageOptionsBase ← GifOptions
Implements
IDisposable , IHasXmpData , IHasMetadata , ICloneable
mirasçı üyeleri
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
Bu örnek, SaveOptions Namespace’den farklı sınıfların ihracat amaçları için kullanıldığını gösterir.Gif tipi bir görüntü bir görüntü örneğine yüklenir ve daha sonra çeşitli biçimlere ihraç edilir.
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));
}
Aşağıdaki örnek, belirli bir görüntü türüne atıfta bulunmaksızın bir çok sayfa vektör görüntüsünü genel olarak GIF biçimine nasıl dönüştüreceğinizi göstermektedir.
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);
}
Bu örnek, bir Tip Renk aralığında Pixel bilgileri nasıl yükleneceğini gösterir, aralığı manipüle eder ve görüntüye geri koyar. Bu işlemleri gerçekleştirmek için, bu örnek yeni bir Görüntü dosyası (GIF biçiminde) uisng MemoryStream nesnesi oluşturur.
//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 sınıfının yeni bir örneğini başlatır.
[JsonConstructor]
public GifOptions()
GifOptions(GifOptions)
Aspose.Imaging.ImageOptions.GifOptions sınıfının yeni bir örneğini başlatır.
public GifOptions(GifOptions gifOptions)
Parameters
gifOptions
GifOptions
GIF seçenekleri
Properties
BackgroundColor
Arka plan rengi alır veya ayarlar.
[JsonProperty]
public Color BackgroundColor { get; set; }
Mülkiyet Değer
BackgroundColorIndex
GIF arka plan renk endeksini alır veya ayarlar.
public byte BackgroundColorIndex { get; set; }
Mülkiyet Değer
ColorResolution
GIF renk çözünürlüğünü alır veya ayarlar.
public byte ColorResolution { get; set; }
Mülkiyet Değer
Examples
Bu örnek, çeşitli seçenekleri kullanarak bir BMP görüntüsünü GIF biçiminde nasıl kaydedeceğinizi gösterir.
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
Renk Çözünürlüğü - Temel renk başına bit sayısı mevcutturOrijinal görüntüye göre, minus 1. Bu değer,Görüntülerdeki renklerin nereden geldiği tüm paletseçilmiş, aslında grafikte kullanılan renk sayısı değil.Örneğin, bu alanın değeri 3 ise, o zaman paletOrijinal görüntü ana renk başına 4 bit oluşturulabilirBu değer, zenginliğe işaret etmek için ayarlanmalıdır.Orijinal palet, her renk değilse bilePalet kaynağı makinesinde mevcuttur.
DoPaletteCorrection
Palet düzeltme uygulandığını gösteren bir değer alır veya ayarlar.
public bool DoPaletteCorrection { get; set; }
Mülkiyet Değer
Examples
Bu örnek, çeşitli seçenekleri kullanarak bir BMP görüntüsünü GIF biçiminde nasıl kaydedeceğinizi gösterir.
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
Palet düzeltme, görüntü GIF’e ihraç edildiğinde kaynak görüntü renkleri analiz edilecektir anlamına gelir.en iyi eşleşen paleti oluşturmak için (görüntü paleti mevcut değilse veya seçeneklerde belirtilmemiştir).Analiz süreci biraz zaman alır ancak çıkış görüntüsü en iyi renk paletine sahip olacak ve sonuç görsel olarak daha iyidir.
HasTrailer
GIF’in bir trailer olup olmadığını gösteren bir değer alır veya ayarlar.
public bool HasTrailer { get; set; }
Mülkiyet Değer
HasTransparentColor
Bir GIF görüntüsünün şeffaf bir renk olup olmadığını gösteren bir değer alır veya ayarlar.Eğer geri dönüş değeri sıfır, bu mülk kaynağı görüntü bağlamı tarafından aşırılmıştır.
[JsonProperty]
public bool? HasTransparentColor { get; set; }
Mülkiyet Değer
bool ?
Interlaced
Görüntüleri birbirine bağlamalıdır.
public bool Interlaced { get; set; }
Mülkiyet Değer
Examples
Bu örnek, çeşitli seçenekleri kullanarak bir BMP görüntüsünü GIF biçiminde nasıl kaydedeceğinizi gösterir.
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
Palet girişlerinin sıralanmış olup olmadığını gösteren bir değer alır veya ayarlar.
public bool IsPaletteSorted { get; set; }
Mülkiyet Değer
LoopsCount
Alınan veya ayarlanan yuvarlak sayısı (Default 1 yuvarlak)
public int LoopsCount { get; set; }
Mülkiyet Değer
MaxDiff
Maksimum izin verilen piksel farkı alır veya ayarlar. sıfırdan daha büyük ise, kayıp kompresyonu kullanılır.Optimal kayıp kompresyon için tavsiye edilen değeri 80. 30 çok hafif kompresyon, 200 ağırdır.Sadece küçük kayıplar yerleştirildiğinde en iyi şekilde çalışır ve kompresyon algoritmasının sınırlaması nedeniyle çok yüksek kayıp seviyeleri o kadar çok kazanç vermez.İzin verilen değer aralığı 0, 1000’dir.
public int MaxDiff { get; set; }
Mülkiyet Değer
Examples
Bu örnek, çeşitli seçenekleri kullanarak bir BMP görüntüsünü GIF biçiminde nasıl kaydedeceğinizi gösterir.
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 piksel yönü oranı alır veya ayarlar.
public byte PixelAspectRatio { get; set; }
Mülkiyet Değer
Remarks
Pixel Aspect Ratio - Yaklaşım hesaplamak için kullanılan faktörOrijinal resimdeki piksel oranı. eğeralanın değeri 0 değildir, bu yaklaşım yön oranıFormülün temelinde hesaplanır:Aspect Ratio = (Pixel Aspect Ratio + 15) / 64Pixel Aspect Ratio Pixel Aspect Ratio Pixel Aspect Ratio Pixel Aspect Ratio Pixel Aspectyüksekliğinden daha geniş. bu alandaki değer aralığıen geniş piksel 4:1’den en yüksek piksel’e kadar1:4 ve 1/64 artışları.Değerleri :0 - Hiçbir faktör oranı bilgileri verilmez.1..255 - Hesaplamada kullanılan değer.