Class GifOptions
A név: Aspose.Imaging.ImageOptions Összefoglaló: Aspose.Imaging.dll (25.4.0)
Az API a Graphical Interchange Format (GIF) raster képfájl létrehozására kínálfejlesztők átfogó lehetőségeket generálni GIF képek pontosfunkciókkal a háttérszín, színpaletta, felbontás beállítása,összekapcsolt típus, átlátszó szín, XMP metadata tartály és képkompresszió, ez az API biztosítja a rugalmasságot és a hatékonyságot a létrehozás optimalizáltés vizuálisan vonzó GIF-k, amelyek megfelelnek a speciális alkalmazási követelményeknek.
[JsonObject(MemberSerialization.OptIn)]
public class GifOptions : ImageOptionsBase, IDisposable, IHasXmpData, IHasMetadata, ICloneable
Inheritance
object ← DisposableObject ← ImageOptionsBase ← GifOptions
Implements
IDisposable , IHasXmpData , IHasMetadata , ICloneable
Örökletes tagok
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
Ez a példa azt mutatja, hogy a különböző osztályok használata a SaveOptions Namespace export célokra. A Gif típusú képet egy kép példájába töltjük le, majd több formátumra exportáljuk.
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));
}
Az alábbi példa azt mutatja, hogyan lehet egy többoldalú vektor képet általános módon GIF formátumra átalakítani anélkül, hogy egy adott képtípusra utalna.
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);
}
Ez a példa azt mutatja, hogyan kell feltölteni a Pixel információt egy Type Color Array, manipulálja a array és helyezze vissza a képet. Ahhoz, hogy ezeket a műveleteket, ez a példány hoz létre egy új Image fájlt (GIF formátumban) uisng MemoryStream objektum.
//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()
Kezdeményez egy új példát a Aspose.Imaging.ImageOptions.GifOption osztály.
[JsonConstructor]
public GifOptions()
GifOptions(GifOptions)
Kezdeményez egy új példát a Aspose.Imaging.ImageOptions.GifOption osztály.
public GifOptions(GifOptions gifOptions)
Parameters
gifOptions
GifOptions
A GIF opciók.
Properties
BackgroundColor
Megkapja vagy beállítja a háttér színét.
[JsonProperty]
public Color BackgroundColor { get; set; }
ingatlan értéke
BackgroundColorIndex
Megkapja vagy beállítja a GIF háttérszín indexet.
public byte BackgroundColorIndex { get; set; }
ingatlan értéke
ColorResolution
Megkapja vagy beállítja a GIF színes felbontást.
public byte ColorResolution { get; set; }
ingatlan értéke
Examples
Ez a példa azt mutatja, hogyan lehet menteni egy BMP képet a GIF formátumban különböző opciók segítségével.
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
Színfelbontás - Az elsődleges színenként elérhető bitek számaaz eredeti képhez, minus 1. Ez az érték aaz egész palettát, amelyből a grafikon színeikiválasztott, nem a színek száma ténylegesen használt a grafika.Például, ha az értéke ebben a mezőben 3, akkor a palettaAz eredeti kép 4 bites volt az elsődleges színre.a kép. ez az érték kell beállítani, hogy jelezze a gazdagságaz eredeti palettát, még akkor is, ha nem minden szín az egészA palettát a forrásgépen kapjuk.
DoPaletteCorrection
Megkap egy értéket vagy beállít egy értéket, amely jelzi, hogy a palettás korrekciót alkalmazzák-e.
public bool DoPaletteCorrection { get; set; }
ingatlan értéke
Examples
Ez a példa azt mutatja, hogyan lehet menteni egy BMP képet a GIF formátumban különböző opciók segítségével.
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
A palettamegoldás azt jelenti, hogy amikor a képet exportálják a GIF-be, a forráskép színeit elemzik.annak érdekében, hogy a legjobb illeszkedő palettát (ha a kép palettája nem létezik vagy nem szerepel az opciókban).Az elemzési folyamat időt vesz igénybe, de a kimeneti kép a legjobb illeszkedő színpalettával rendelkezik, és az eredmény vizuálisan jobb.
HasTrailer
Megkap egy értéket vagy beállítást, amely jelzi, hogy a GIF-nek van-e trailerje.
public bool HasTrailer { get; set; }
ingatlan értéke
HasTransparentColor
Megkapja vagy beállítja azt a értéket, amely jelzi, hogy egy GIF-kép átlátszó színű-e.Amennyiben a visszatérítési érték Null, ezt a tulajdonságot a forrása kép kontextus túlterjedt.
[JsonProperty]
public bool? HasTransparentColor { get; set; }
ingatlan értéke
bool ?
Interlaced
Igaz, ha a képet össze kell kapcsolni.
public bool Interlaced { get; set; }
ingatlan értéke
Examples
Ez a példa azt mutatja, hogyan lehet menteni egy BMP képet a GIF formátumban különböző opciók segítségével.
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
Megkap egy értéket vagy beállít egy értéket, amely jelzi, hogy a palettájú bejegyzéseket sorolják-e.
public bool IsPaletteSorted { get; set; }
ingatlan értéke
LoopsCount
Megkapja vagy beállítja a lapok számát (Default 1 lap)
public int LoopsCount { get; set; }
ingatlan értéke
MaxDiff
Megkapja vagy beállítja a maximális megengedett pixel különbséget. ha nagyobb, mint nulla, a veszteség kompressziót fogják használni.Az optimális veszteségkompresszió ajánlott értéke 80. 30 nagyon könnyű kompresszió, 200 nehéz.Ez a legjobban működik, amikor csak egy kis veszteséget vezet be, és a kompressziós algoritmus korlátozásának köszönhetően a nagyon magas veszteségszintek nem adnak annyi nyereséget.A megengedett értékek tartalma [0, 1000].
public int MaxDiff { get; set; }
ingatlan értéke
Examples
Ez a példa azt mutatja, hogyan lehet menteni egy BMP képet a GIF formátumban különböző opciók segítségével.
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
Megkapja vagy beállítja a GIF pixel aspektus arányát.
public byte PixelAspectRatio { get; set; }
ingatlan értéke
Remarks
Pixel Aspect Ratio – a megközelítés kiszámítására használt tényezőa pixel arányát az eredeti képben. ha aa mező értéke nem 0, ez a szempont arányának megközelítéseA számítás a képlet alapján történik:Aspect Ratio = (Pixel Aspect Ratio + 15) / 64A Pixel Aspect Ratio-t úgy határozzák meg, hogy a pixelszélesebb, mint a magasság. Az értéktér ebben a mezőben lehetővé teszi, hogya legszélesebb pixel 4:1 a legmagasabb pixel1:4 az 1/64-es növekedésben.Az értékek:0 - Nincs adva aspektus arányú információt.1..255 - A számításban használt érték.