Class GifOptions
Το όνομα: Aspose.Imaging.ImageOptions Συγκέντρωση: Aspose.Imaging.dll (25.4.0)
Το API για τη δημιουργία αρχείων γραφικών (GIF) προσφέρειπρογραμματιστές ολοκληρωμένες επιλογές για τη δημιουργία εικόνων GIF με ακρίβειαμε χαρακτηριστικά για να ρυθμίσετε το χρώμα του φόντου, την παλέτα χρώματος, την ανάλυση,διασυνδεδεμένο τύπο, διαφανές χρώμα, 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 φορτώνεται σε μια περίπτωση εικόνας και στη συνέχεια εξάγεται σε διάφορες μορφές.
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);
}
Αυτό το παράδειγμα δείχνει πώς να φορτώσετε πληροφορίες Pixel σε μια σειρά τύπου χρώματος, χειριστεί τη σειρά και να την τοποθετήσετε πίσω στην εικόνα. Για να εκτελέσετε αυτές τις εργασίες, αυτό το παράδειγμα δημιουργεί ένα νέο αρχείο εικόνας (σε μορφή 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
Χρωματική ανάλυση - Αριθμός bit ανά πρωτότυπο χρώμα διαθέσιμοστην αρχική εικόνα, minus 1.Αυτή η τιμή αντιπροσωπεύει το μέγεθος τηςΟλόκληρη η παλέτα από την οποία τα χρώματα στο γραφείο ήτανεπιλεγμένο, όχι τον αριθμό των χρωμάτων που χρησιμοποιούνται πραγματικά στο γραφικό.Για παράδειγμα, εάν η τιμή σε αυτό το πεδίο είναι 3, τότε η παλέταΗ αρχική εικόνα είχε 4 bit ανά πρωτότυπο χρώμα διαθέσιμη για τη δημιουργίαΗ τιμή αυτή θα πρέπει να καθορίζεται για να υποδεικνύει τον πλούτο τηςτο πρωτότυπο παλέτα, ακόμη και αν όχι κάθε χρώμα από το σύνολοΗ παλέτα είναι διαθέσιμη στη μηχανή πηγής.
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 έχει trailer.
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
Αποκτήστε ή τοποθετήστε τον αριθμό των ρυτίδων (Default 1 loop)
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 pixel aspect ratio.
public byte PixelAspectRatio { get; set; }
Αξία ιδιοκτησίας
Remarks
Pixel Aspect Ratio - Ο παράγοντας που χρησιμοποιείται για τον υπολογισμό μιας προσέγγισηςαπό την αναλογία πτυχίου του pixel στην αρχική εικόνα.η τιμή του πεδίου δεν είναι 0, αυτή η προσέγγιση της αναλογίας πτυχίουΥπολογίζεται με βάση τη φόρμουλα:Aspect Ratio = (Pixel Aspect Ratio + 15) / 64Το Pixel Aspect Ratio ορίζεται ως το ποσοστό του pixel.Το εύρος της αξίας σε αυτό το πεδίο επιτρέπειτο μεγαλύτερο pixel από το 4:1 έως το υψηλότερο pixel1:4 σε αύξηση του 1/64.Αξίες :0 - Δεν παρέχονται πληροφορίες αναλογισμού πτυχών.1..255 - Αξία που χρησιμοποιείται στον υπολογισμό.