Class GifImage
ชื่อพื้นที่: Aspose.Imaging.FileFormats.Gif การประกอบ: Aspose.Imaging.dll (25.4.0)
API for Graphical Interchange Format (GIF) ไฟล์ภาพผู้พัฒนาที่มีเครื่องมือที่หลากหลายสําหรับการประมวลผลภาพสกรูที่บีบอัดและGIF animated. ให้คุณสมบัติเช่นการจัดการ metadata XMP, palette สีการตั้งค่าพื้นหลังและการควบคุมสีที่โปร่งใสการตั้งค่าความผิดปกติการรีไซเคิลcrop, การประยุกต์ใช้กรอง, การแก้ไข gamma, การปรับความต้านทาน, grayscaleการแปลงและการแปลงไปยังรูปแบบอื่น ๆ API นี้ช่วยให้ไม่มีการเชื่อมต่อการจัดการและการปรับปรุงภาพ GIF สําหรับการใช้งานที่หลากหลาย
[JsonObject(MemberSerialization.OptIn)]
public sealed class GifImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImageExt, IMultipageImage
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← RasterImage ← RasterCachedImage ← RasterCachedMultipageImage ← GifImage
Implements
IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasXmpData , IHasMetadata , IMultipageImageExt , IMultipageImage
อนุญาโตตุลาการ
RasterCachedMultipageImage.AdjustBrightness(int) , RasterCachedMultipageImage.AdjustContrast(float) , RasterCachedMultipageImage.AdjustGamma(float, float, float) , RasterCachedMultipageImage.AdjustGamma(float) , RasterCachedMultipageImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedMultipageImage.BinarizeFixed(byte) , RasterCachedMultipageImage.BinarizeBradley(double, int) , RasterCachedMultipageImage.BinarizeBradley(double) , RasterCachedMultipageImage.BinarizeOtsu() , RasterCachedMultipageImage.Crop(Rectangle) , RasterCachedMultipageImage.Crop(int, int, int, int) , RasterCachedMultipageImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedMultipageImage.Grayscale() , RasterCachedMultipageImage.NormalizeHistogram() , RasterCachedMultipageImage.Rotate(float, bool, Color) , RasterCachedMultipageImage.RotateFlip(RotateFlipType) , RasterCachedMultipageImage.RotateFlipAll(RotateFlipType) , RasterCachedMultipageImage.Resize(int, int, ResizeType) , RasterCachedMultipageImage.Resize(int, int, ImageResizeSettings) , RasterCachedMultipageImage.ResizeWidthProportionally(int, ResizeType) , RasterCachedMultipageImage.ResizeHeightProportionally(int, ResizeType) , RasterCachedMultipageImage.ReplaceColor(int, byte, int) , RasterCachedMultipageImage.ReplaceNonTransparentColors(int) , RasterCachedMultipageImage.Filter(Rectangle, FilterOptionsBase) , RasterCachedMultipageImage.NormalizeAngle(bool, Color) , RasterCachedMultipageImage.CacheData() , RasterCachedMultipageImage.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , RasterCachedMultipageImage.Height , RasterCachedMultipageImage.Width , RasterCachedMultipageImage.BitsPerPixel , RasterCachedMultipageImage.IsCached , RasterCachedMultipageImage.PageCount , RasterCachedMultipageImage.Pages , RasterCachedMultipageImage.HasAlpha , RasterCachedMultipageImage.HasTransparentColor , RasterCachedMultipageImage.ImageOpacity , RasterCachedMultipageImage.BackgroundColor , RasterCachedMultipageImage.XmpData , RasterCachedMultipageImage.PageExportingAction , RasterCachedImage.CacheData() , RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedImage.Resize(int, int, ResizeType) , RasterCachedImage.Resize(int, int, ImageResizeSettings) , RasterCachedImage.RotateFlip(RotateFlipType) , RasterCachedImage.Rotate(float, bool, Color) , RasterCachedImage.Crop(Rectangle) , RasterCachedImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedImage.Grayscale() , RasterCachedImage.NormalizeHistogram() , RasterCachedImage.BinarizeFixed(byte) , RasterCachedImage.BinarizeOtsu() , RasterCachedImage.BinarizeBradley(double, int) , RasterCachedImage.BinarizeBradley(double) , RasterCachedImage.AdjustBrightness(int) , RasterCachedImage.AdjustContrast(float) , RasterCachedImage.AdjustGamma(float, float, float) , RasterCachedImage.AdjustGamma(float) , RasterCachedImage.IsCached , RasterImage.RemoveMetadata() , RasterImage.Save(Stream, ImageOptionsBase, Rectangle) , RasterImage.GetModifyDate(bool) , RasterImage.Dither(DitheringMethod, int) , RasterImage.Dither(DitheringMethod, int, IColorPalette) , RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) , RasterImage.GetDefaultArgb32Pixels(Rectangle) , RasterImage.GetDefaultRawData(Rectangle, RawDataSettings) , RasterImage.GetArgb32Pixel(int, int) , RasterImage.GetPixel(int, int) , RasterImage.SetArgb32Pixel(int, int, int) , RasterImage.SetPixel(int, int, Color) , RasterImage.ReadScanLine(int) , RasterImage.ReadArgb32ScanLine(int) , RasterImage.WriteScanLine(int, Color[]) , RasterImage.WriteArgb32ScanLine(int, int[]) , RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader) , RasterImage.LoadArgb32Pixels(Rectangle) , RasterImage.LoadArgb64Pixels(Rectangle) , RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader) , RasterImage.LoadPixels(Rectangle) , RasterImage.LoadCmykPixels(Rectangle) , RasterImage.LoadCmyk32Pixels(Rectangle) , RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings) , RasterImage.SaveArgb32Pixels(Rectangle, int[]) , RasterImage.SavePixels(Rectangle, Color[]) , RasterImage.SaveCmykPixels(Rectangle, CmykColor[]) , RasterImage.SaveCmyk32Pixels(Rectangle, int[]) , RasterImage.SetResolution(double, double) , RasterImage.SetPalette(IColorPalette, bool) , RasterImage.Resize(int, int, ImageResizeSettings) , RasterImage.Rotate(float, bool, Color) , RasterImage.Rotate(float) , RasterImage.BinarizeFixed(byte) , RasterImage.BinarizeOtsu() , RasterImage.BinarizeBradley(double) , RasterImage.BinarizeBradley(double, int) , RasterImage.Blend(Point, RasterImage, Rectangle, byte) , RasterImage.Blend(Point, RasterImage, byte) , RasterImage.Grayscale() , RasterImage.NormalizeHistogram() , RasterImage.AdjustBrightness(int) , RasterImage.AdjustContrast(float) , RasterImage.AdjustGamma(float, float, float) , RasterImage.AdjustGamma(float) , RasterImage.GetSkewAngle() , RasterImage.NormalizeAngle() , RasterImage.NormalizeAngle(bool, Color) , RasterImage.Filter(Rectangle, FilterOptionsBase) , RasterImage.ReplaceColor(Color, byte, Color) , RasterImage.ReplaceColor(int, byte, int) , RasterImage.ReplaceNonTransparentColors(Color) , RasterImage.ReplaceNonTransparentColors(int) , RasterImage.ToBitmap() , RasterImage.PremultiplyComponents , RasterImage.UseRawData , RasterImage.UpdateXmpData , RasterImage.XmpData , RasterImage.RawIndexedColorConverter , RasterImage.RawCustomColorConverter , RasterImage.RawFallbackIndex , RasterImage.RawDataSettings , RasterImage.UsePalette , RasterImage.RawDataFormat , RasterImage.RawLineSize , RasterImage.IsRawDataAvailable , RasterImage.HorizontalResolution , RasterImage.VerticalResolution , RasterImage.HasTransparentColor , RasterImage.HasAlpha , RasterImage.TransparentColor , RasterImage.ImageOpacity , Image.CanLoad(string) , Image.CanLoad(string, LoadOptions) , Image.CanLoad(Stream) , Image.CanLoad(Stream, LoadOptions) , Image.Create(ImageOptionsBase, int, int) , Image.Create(Image[]) , Image.Create(MultipageCreateOptions) , Image.Create(string[], bool) , Image.Create(string[]) , Image.Create(Image[], bool) , Image.GetFileFormat(string) , Image.GetFileFormat(Stream) , Image.GetFittingRectangle(Rectangle, int, int) , Image.GetFittingRectangle(Rectangle, int[], int, int) , Image.Load(string, LoadOptions) , Image.Load(string) , Image.Load(Stream, LoadOptions) , Image.Load(Stream) , Image.GetProportionalWidth(int, int, int) , Image.GetProportionalHeight(int, int, int) , Image.RemoveMetadata() , Image.CanSave(ImageOptionsBase) , Image.Resize(int, int) , Image.Resize(int, int, ResizeType) , Image.Resize(int, int, ImageResizeSettings) , Image.GetDefaultOptions(object[]) , Image.GetOriginalOptions() , Image.ResizeWidthProportionally(int) , Image.ResizeHeightProportionally(int) , Image.ResizeWidthProportionally(int, ResizeType) , Image.ResizeHeightProportionally(int, ResizeType) , Image.ResizeWidthProportionally(int, ImageResizeSettings) , Image.ResizeHeightProportionally(int, ImageResizeSettings) , Image.RotateFlip(RotateFlipType) , Image.Rotate(float) , Image.Crop(Rectangle) , Image.Crop(int, int, int, int) , Image.Save() , Image.Save(string) , Image.Save(string, ImageOptionsBase) , Image.Save(string, ImageOptionsBase, Rectangle) , Image.Save(Stream, ImageOptionsBase) , Image.Save(Stream, ImageOptionsBase, Rectangle) , Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , Image.SetPalette(IColorPalette, bool) , Image.BitsPerPixel , Image.Bounds , Image.Container , Image.Height , Image.Palette , Image.UsePalette , Image.Size , Image.Width , Image.InterruptMonitor , Image.BufferSizeHint , Image.AutoAdjustPalette , Image.HasBackgroundColor , Image.FileFormat , Image.BackgroundColor , DataStreamSupporter.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , DisposableObject.Dispose() , DisposableObject.Disposed , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
การส่งออกส่วนของภาพเคลื่อนไหวจากภาพ GIF ตามช่วงเวลา
using (var image = Image.Load("Animation.gif"))
{
var options = new GifOptions
{
FullFrame = true,
MultiPageOptions = new MultiPageOptions
{
Mode = MultiPageMode.TimeInterval,
TimeInterval = new TimeInterval(0, 400)
}
};
image.Save("PartOfAnimation.gif", options);
}
ตัวอย่างนี้แสดงให้เห็นวิธีการสร้างภาพ GIF และบันทึกไว้ในไฟล์
string dir = "c:\\temp\\";
// Create a GIF Frame block of 100x100 px.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
// Fill the entire block in red.
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
gr.FillRectangle(brush, firstBlock.Bounds);
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
gifImage.Save(dir + "output.gif");
}
}
สร้างภาพ GIF มัลติหน้าโดยใช้ภาพ raster หน้าเดียว
static void Main(string[] args)
{
// Load frames
var frames = LoadFrames("Animation frames").ToArray();
// Create GIF image using the first frame
using (var image = new GifImage(new GifFrameBlock(frames[0])))
{
// Add frames to the GIF image using the AddPage method
for (var index = 1; index < frames.Length; index++)
{
image.AddPage(frames[index]);
}
// Save GIF image
image.Save("Multipage.gif");
}
}
private static IEnumerable<rasterimage> LoadFrames(string directory)
{
foreach (var filePath in Directory.GetFiles(directory))
{
yield return (RasterImage)Image.Load(filePath);
}
}</rasterimage>
Constructors
GifImage(GifFrameBlock, IColorPalette)
เปิดตัว Aspose.Imaging.FileFormats.Gif.GifImage วัตถุใหม่ที่มีพารามิเตอร์ที่ระบุสําหรับหน้าแรกและแพลตฟอร์มทั่วโลก เริ่มจัดการภาพ GIF ได้อย่างรวดเร็วเพื่อให้แน่ใจว่าการแสดงผลที่แม่นยําพร้อมการตั้งค่าที่กําหนดเองเพื่อผลลัพธ์ที่ดีที่สุด
public GifImage(GifFrameBlock firstFrame, IColorPalette globalPalette)
Parameters
firstFrame
GifFrameBlock
รอบแรกเพื่อเริ่มต้นภาพ GIF กับ
globalPalette
IColorPalette
โปรดทราบว่าถ้าทั้ง firstFrame’ และ
globalPalette’ เป็น null จากนั้นพาเลททั่วโลกแบบกําหนดเองจะใช้
Examples
ตัวอย่างนี้แสดงให้เห็นวิธีการสร้างภาพ GIF ด้วยแพลตฟอร์มที่กําหนดเองและบันทึกไว้ในไฟล์
string dir = "c:\\temp\\";
// Create a GIF Frame block of 100x100 px.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
// Fill the entire block in red.
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
gr.FillRectangle(brush, firstBlock.Bounds);
// Use 4-bit palette to reduce the image size. The quality can get worse.
Aspose.Imaging.IColorPalette palette = Aspose.Imaging.ColorPaletteHelper.Create4Bit();
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock, palette))
{
gifImage.Save(dir + "output.gif");
}
}
Exceptions
firstFrame’ ไม่สามารถเป็น null
firstFrame’ อยู่ในภาพอื่น ๆ ตรวจสอบคุณสมบัติของคอนเทนเนอร์
globalPalette’ ที่ระบุไว้ควรมีจํานวนรายการเท่ากับพลังงานของ 2. ขนาดแพลตฟอร์มขั้นต่ําคือ 2, สูงสุดคือ 256.
GifImage(GifFrameBlock)
การสร้างภาพ GIF จะกลายเป็นเรื่องยากกับ Aspose.Imaging.FileFormats.Gif.GifImageconstructor. ด้วยเพียงพารามิเตอร์เฟรมแรกเท่านั้นมันจะเข้าสู่โลกของไดนามิกการสื่อสารภาพ
public GifImage(GifFrameBlock firstFrame)
Parameters
firstFrame
GifFrameBlock
รอบแรกเพื่อเริ่มต้นภาพ GIF กับ
Examples
ตัวอย่างนี้แสดงให้เห็นวิธีการสร้างภาพ GIF และบันทึกไว้ในไฟล์
string dir = "c:\\temp\\";
// Create a GIF Frame block of 100x100 px.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
{
// Fill the entire block in red.
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
gr.FillRectangle(brush, firstBlock.Bounds);
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
gifImage.Save(dir + "output.gif");
}
}
ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการประกอบภาพ GIF ที่เคลื่อนไหวจากบล็อก GIF แต่ละตัว
string dir = "c:\\temp\\";
// Create a GIF image 100 x 100 px.
// The first block is fully black by default.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
// The first circle is red
Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
// The second circle is black
Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);
// Gradually inscrease the angle of the red arc shape.
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush1, block.Bounds, 0, angle);
gifImage.AddBlock(block);
}
// Gradually inscrease the angle of the black arc and wipe out the red arc.
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush2, block.Bounds, 0, angle);
gr.FillPie(brush1, block.Bounds, angle, 360 - angle);
gifImage.AddBlock(block);
}
gifImage.Save(dir + "animated_radar.gif");
}
Exceptions
firstFrame’ ไม่สามารถเป็น null
firstFrame’ อยู่ในภาพอื่น ๆ ตรวจสอบคุณสมบัติของคอนเทนเนอร์
แพลิเคชันที่ระบุจะต้องมีจํานวนรายการเท่ากับพลังงานของ 2. ขนาดพลิเคชันขั้นต่ําคือ 2, สูงสุดคือ 256.
GifImage(GifFrameBlock, IColorPalette, bool, byte, byte, byte, bool)
เริ่มต้นได้อย่างง่ายดายด้วย Aspose.Imaging.FileFormats.Gif.GifImage constructorวิธีที่เรียบง่ายคุณสามารถเพลิดเพลินไปกับการสร้าง GIF ที่เคลื่อนไหวได้อย่างง่ายดาย เพียงแค่ให้firstFrame, globalPalette, paletteColorResolution, aspectRatio, และอื่น ๆพารามิเตอร์และคุณพร้อมที่จะนําภาพของคุณไปสู่ชีวิต
public GifImage(GifFrameBlock firstFrame, IColorPalette globalPalette, bool isPaletteSorted, byte paletteColorResolution, byte paletteBackgroundColorIndex, byte aspectRatio, bool hasTrailer)
Parameters
firstFrame
GifFrameBlock
รอบแรกเพื่อเริ่มต้นภาพ GIF กับ
globalPalette
IColorPalette
โปรดทราบว่าถ้าทั้ง firstFrame’ และ
globalPalette’ เป็น null จากนั้นพาเลททั่วโลกแบบกําหนดเองจะใช้
isPaletteSorted
bool
ถ้าตั้งค่าเป็น “จริง” แพลิเคชันจะถูกจัดอันดับ โปรดทราบว่าพารามิเตอร์จะถูกใช้เมื่อ globalPalette" ไม่เป็น null
paletteColorResolution
byte
โซลูชันสีแพลตฟอร์ม โปรดทราบว่าพารามิเตอร์จะใช้เมื่อ globalPalette’ ไม่เป็น null
paletteBackgroundColorIndex
byte
แพลิเคชันพื้นหลัง Color Index
aspectRatio
byte
อัตราส่วน
hasTrailer
bool
ถ้าตั้งไว้เพื่อ ‘จริง’ ภาพ GIF มี trailer ไม่ว่าไม่มี trailer ที่เขียนในตอนท้ายของ Stream.
Exceptions
firstFrame’ ไม่สามารถเป็น null
firstFrame’ อยู่ในภาพอื่น ๆ ตรวจสอบคุณสมบัติของคอนเทนเนอร์
globalPalette’ ที่ระบุไว้ควรมีจํานวนรายการเท่ากับพลังงานของ 2. ขนาดแพลตฟอร์มขั้นต่ําคือ 2, สูงสุดคือ 256.
Properties
ActiveFrame
การจัดการและจัดการเฟรมที่มีคุณสมบัตินี้เพื่อให้สามารถนําทางได้อย่างราบรื่นและเปลี่ยนกรอบที่ใช้งานภายในภาพ GIF
public GifFrameBlock ActiveFrame { get; set; }
คุณสมบัติมูลค่า
Examples
ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการลบบล็อกทั้งหมดจากภาพ GIF
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
if (gifImage.ActiveFrame != null)
{
System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
}
else
{
System.Console.WriteLine("Active frame is not set");
}
System.Console.WriteLine("Clear all the blocks");
gifImage.ClearBlocks();
if (gifImage.ActiveFrame != null)
{
System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
}
else
{
System.Console.WriteLine("Active frame is not set");
}
}
// The output looks like this:
// Active frame size: { Width = 100, Height = 100}
// Clear all the blocks
// Active frame is not set
BackgroundColor
การจัดการสีพื้นหลังของภาพ GIF ด้วยคุณสมบัตินี้ คุณสามารถตั้งค่าหรือรับสีพื้นหลังเพื่อให้มั่นใจถึงความสม่ําเสมอและเพิ่มความสนใจภาพ
public override Color BackgroundColor { get; set; }
คุณสมบัติมูลค่า
BackgroundColorIndex
ตรวจสอบ index สีพื้นหลังของภาพ GIF ด้วยคุณสมบัตินี้ การตั้งค่าหรือรับดัชนีเพื่อรักษาความสม่ําเสมอหรือบรรลุผลลัพธ์ภาพที่ต้องการ
public byte BackgroundColorIndex { get; set; }
คุณสมบัติมูลค่า
Blocks
รับการเข้าถึงบล็อก GIF โดยไม่มีการเชื่อมต่อกับคุณสมบัตินี้ทําให้ง่ายขึ้นการกู้คืนและจัดการโครงสร้างข้อมูลพื้นฐานของภาพ
public IGifBlock[] Blocks { get; }
คุณสมบัติมูลค่า
IGifBlock [ ]
FileFormat
ปรับปรุงรูปแบบไฟล์ได้อย่างง่ายดายด้วยคุณสมบัตินี้ มันเป็นคุณ Go-to Sourceสําหรับการระบุรูปแบบของไฟล์ของคุณ การบูรณาการได้อย่างราบรื่นในกระบวนการทํางานของคุณมันให้ข้อมูลที่สําคัญโดยไม่ต้องกังวลใด ๆ
public override FileFormat FileFormat { get; }
คุณสมบัติมูลค่า
HasBackgroundColor
คุณสมบัตินี้กําหนดว่าภาพ GIF มีสีพื้นหลังหรือไม่จริง ๆ มันหมายความว่าภาพรวมถึงสีพื้นหลัง
public override bool HasBackgroundColor { get; }
คุณสมบัติมูลค่า
HasTrailer
จัดการปรากฏตัวของ trailer ในไฟล์ GIF ของคุณ ด้วยคุณสมบัตินี้ หรือไม่จําเป็นต้องตรวจสอบว่ามี trailer หรือตั้งค่าความปรากฏตัวของมันคุณสมบัตินี้ทําให้ง่ายต่อการใช้งานกระบวนการ การรักษาไฟล์ GIF ของคุณโครงสร้างและสอดคล้องกับฟังก์ชั่นที่ใช้งานง่ายนี้
public bool HasTrailer { get; set; }
คุณสมบัติมูลค่า
HasTransparentColor
ตรวจสอบว่ากรอบที่ใช้งานของภาพ GIF มีสีโปร่งใสหรือไม่คุณสมบัตินี้เป็นวิธีที่สะดวกในการตรวจสอบความโปร่งใสภายในภาพ
public override bool HasTransparentColor { get; set; }
คุณสมบัติมูลค่า
ImageOpacity
ปรับปรุงความต้านทานของกรอบที่ใช้งานภายในภาพให้เห็นถึงระดับความโปร่งใสของมัน คุณสมบัตินี้เป็นประโยชน์โดยเฉพาะอย่างยิ่งในการเข้าใจระดับความโปร่งใสหรือเงียบของกรอบที่ใช้งานในภาพ
public override float ImageOpacity { get; }
คุณสมบัติมูลค่า
IsInterlaced
กําหนดว่าภาพจะถูกเชื่อมต่อซึ่งส่งผลกระทบต่อการแสดงผลของมันในระหว่างการโหลดคุณสมบัติให้ความเข้าใจในพฤติกรรมการแสดงภาพซึ่งเป็นสิ่งสําคัญสําหรับการเพิ่มประสิทธิภาพของกลยุทธ์การโหลดและการปรับปรุงประสบการณ์การดูโดยรวม
public bool IsInterlaced { get; }
คุณสมบัติมูลค่า
IsPaletteSorted
ตรวจสอบการจัดอันดับของแพลตฟอร์มในภาพ GIF ของคุณโดยใช้คุณสมบัตินี้ หรือไม่คุณต้องตรวจสอบว่าแพลตฟอร์มจะจัดประเภทหรือกําหนดพฤติกรรมจัดประเภทนี้คุณสมบัติให้วิธีที่เรียบง่ายในการจัดการองค์กรในแพลตฟอร์มของคุณไฟล์ GIF
public bool IsPaletteSorted { get; set; }
คุณสมบัติมูลค่า
LoopsCount
รับคํานวณล็อปได้อย่างง่ายดายด้วยคุณสมบัตินี้ หากภาพ GIF ของคุณรวมถึงข้อมูลล็อคคุณสมบัตินี้ช่วยให้คุณสามารถเข้าถึงการคํานวณล็อคได้อย่างรวดเร็วคุณสามารถจัดการพฤติกรรม looping ในไฟล์ GIF ของคุณได้อย่างราบรื่น
public int LoopsCount { get; set; }
คุณสมบัติมูลค่า
PageCount
ปรับปรุงจํานวนหน้าทั้งหมดที่อยู่ในภาพนี้คุณสมบัติที่เรียบง่าย เหมาะสําหรับการประเมินความกว้างของเนื้อหาภาพได้อย่างรวดเร็ว
public override int PageCount { get; }
คุณสมบัติมูลค่า
Pages
ได้รับการเข้าถึงหน้าภายในภาพผ่านคุณสมบัติที่สะดวกนี้ช่วยให้การ navigation และ manipulation ของแต่ละหน้าเป็นไปตามความต้องการ
public override Image[] Pages { get; }
คุณสมบัติมูลค่า
Image [ ]
PaletteColorResolutionBits
การจัดการความละเอียดสีของภาพ GIF ของคุณด้วยคุณสมบัตินี้ การปรับแต่งจํานวนบิตที่ใช้ในการแสดงสีในแพลตฟอร์มให้การควบคุมที่ดีความลึกของสีและคุณภาพของภาพ
public byte PaletteColorResolutionBits { get; set; }
คุณสมบัติมูลค่า
PixelAspectRatio
การจัดการความสัมพันธ์ด้านพิกเซลของภาพ GIF กับคุณสมบัตินี้ การตั้งค่าหรือรับความสัมพันธ์ด้านเพื่อให้แน่ใจว่าการแสดงผลที่แม่นยําและรักษาความซื่อสัตย์ภาพ
public byte PixelAspectRatio { get; set; }
คุณสมบัติมูลค่า
TransparentColor
รับสีที่โปร่งใสของกรอบที่ใช้งานในภาพ GIF คุณสมบัตินี้ช่วยให้คุณสามารถเข้าถึงสีที่เฉพาะเจาะจงที่ระบุไว้เป็นโปร่งใสภายในกรอบที่ใช้งานในปัจจุบัน
public override Color TransparentColor { get; }
คุณสมบัติมูลค่า
XmpData
การจัดการ metadata XMP ด้วยคุณสมบัตินี้ ไม่ว่าคุณจะได้รับ metadata ที่มีอยู่หรืออัปเดตมันด้วยข้อมูลใหม่คุณสมบัตินี้ทําให้กระบวนการรุนแรงmetadata ของคุณได้รับการจัดระเบียบและสามารถเข้าถึงได้เพื่อให้แน่ใจว่าไฟล์ของคุณประกอบด้วยข้อมูลที่เกี่ยวข้องที่คุณต้องการ
public override XmpPacketWrapper XmpData { get; set; }
คุณสมบัติมูลค่า
Methods
AddBlock(บล็อก)
การเพิ่มบล็อก GIF ใหม่ช่วยให้คุณสามารถรวมข้อมูลเพิ่มเติมภายในภาพวิธีนี้ช่วยให้คุณสามารถเพิ่มบล็อกที่กําหนดเองไปยังภาพ GIF ซึ่งสามารถมีข้อมูลประเภทต่างๆ
public void AddBlock(IGifBlock block)
Parameters
block
IGifBlock
บล็อก GIF ที่จะเพิ่ม
Examples
ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการประกอบภาพ GIF ที่เคลื่อนไหวจากบล็อก GIF แต่ละตัว
string dir = "c:\\temp\\";
// Create a GIF image 100 x 100 px.
// The first block is fully black by default.
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
// The first circle is red
Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
// The second circle is black
Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);
// Gradually inscrease the angle of the red arc shape.
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush1, block.Bounds, 0, angle);
gifImage.AddBlock(block);
}
// Gradually inscrease the angle of the black arc and wipe out the red arc.
for (int angle = 10; angle <= 360; angle += 10)
{
Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
gr.FillPie(brush2, block.Bounds, 0, angle);
gr.FillPie(brush1, block.Bounds, angle, 360 - angle);
gifImage.AddBlock(block);
}
gifImage.Save(dir + "animated_radar.gif");
}
AddPage(RasterImage)
ใส่หน้าใหม่ลงในภาพที่มีอยู่โดยไม่มีรอยต่อการปรับปรุงเนื้อหาและขยายช่วงของวิธีการนี้เพิ่มการเก็บรวบรวมภาพด้วยเพิ่มเติมเนื้อหาส่งเสริมความคิดสร้างสรรค์และความยืดหยุ่นในการจัดการภาพและการประกอบ
public void AddPage(RasterImage page)
Parameters
page
RasterImage
หน้าที่เพิ่ม
Examples
สร้างภาพ GIF มัลติหน้าโดยใช้ภาพ raster หน้าเดียว
static void Main(string[] args)
{
// Load frames
var frames = LoadFrames("Animation frames").ToArray();
// Create GIF image using the first frame
using (var image = new GifImage(new GifFrameBlock(frames[0])))
{
// Add frames to the GIF image using the AddPage method
for (var index = 1; index < frames.Length; index++)
{
image.AddPage(frames[index]);
}
// Save GIF image
image.Save("Multipage.gif");
}
}
private static IEnumerable<rasterimage> LoadFrames(string directory)
{
foreach (var filePath in Directory.GetFiles(directory))
{
yield return (RasterImage)Image.Load(filePath);
}
}</rasterimage>
Exceptions
page’ is null.
AdjustBrightness(int)
ปรับความสว่างของภาพตามพารามิเตอร์ความสว่างที่ระบุ วิธีการนี้ปรับความสว่างของภาพทั้งหมดอย่างสม่ําเสมอเพิ่มหรือลดความสว่างโดยรวมเพื่อให้บรรลุผลที่ต้องการ
public override void AdjustBrightness(int brightness)
Parameters
brightness
int
ความสว่าง
Examples
ตัวอย่างต่อไปนี้จะดําเนินการการแก้ไขความสว่างของภาพ GIF
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Set the brightness value. The accepted values of brightness are in the range [-255, 255].
gifImage.AdjustBrightness(50);
gifImage.Save(dir + "sample.AdjustBrightness.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustContrast(เฟอร์รี่)
ปรับความแตกต่างของภาพเพิ่มขึ้นหรือลดความแตกต่างในภาพความสว่างระหว่างพิกเซล วิธีการนี้เปลี่ยนช่วงเสียงทั้งหมดของภาพทําให้พื้นที่ที่เข้มเข้มและพื้นที่ที่สดใสขึ้นเพื่อปรับปรุงความชัดเจนภาพและรายละเอียด
public override void AdjustContrast(float contrast)
Parameters
contrast
float
คะแนนความต้านทาน (ในช่วง [-100; 100])
Examples
ตัวอย่างต่อไปนี้ดําเนินการการแก้ไขข้อตกลงของภาพ GIF
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
gifImage.AdjustContrast(50f);
gifImage.Save(dir + "sample.AdjustContrast.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Exceptions
ไม่สามารถเปลี่ยนความต้านทาน ไม่สามารถเปลี่ยนความต้านทาน ไม่สามารถเปลี่ยนความต้านทาน ไม่สามารถเปลี่ยนความต้านทาน ไม่สามารถเปลี่ยนความต้านทาน ไม่สามารถเปลี่ยนความต้านทาน
AdjustGamma(เฟอร์รี่)
ปรับปรุงคุณภาพของภาพโดยใช้การแก้ไข gamma วิธีนี้ปรับสีGamma ของภาพเพื่อให้ได้ความชัดเจนภาพที่ดีที่สุด มันเปลี่ยนค่า Gammaของแต่ละพิกเซลซึ่งนําไปสู่การปรับปรุงการแสดงผลสีและรูปลักษณ์ภาพโดยรวม
public override void AdjustGamma(float gamma)
Parameters
gamma
float
GAMMA สําหรับช่องแดงสีเขียวและสีน้ําเงิน
Examples
ตัวอย่างต่อไปนี้ทําการแก้ไขรูป GIF
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Set gamma coefficient for red, green and blue channels.
gifImage.AdjustGamma(2.5f);
gifImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustGamma(เฟอร์รี่, เฟอร์รี่, เฟอร์รี่)
การแก้ไขกราฟิกของภาพใช้การปรับไม่แนวนอนกับค่าพิกเซลปรับปรุงหรือลดความสว่างขึ้นอยู่กับอัตราส่วนที่ระบุสําหรับสีแดงช่องสีเขียวและสีน้ําเงิน วิธีนี้ช่วยให้ความสมดุลสีและแสงของภาพปรับปรุงลักษณะโดยรวมและคุณภาพภาพ
public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
float
Gamma สําหรับช่องแดง Coefficient
gammaGreen
float
Gamma สําหรับ Coefficient ช่องสีเขียว
gammaBlue
float
Gamma สําหรับ Coefficient ช่องสีฟ้า
Examples
ตัวอย่างต่อไปนี้จะดําเนินการการแก้ไขรูป GIF โดยใช้ koeficients ที่แตกต่างกันสําหรับองค์ประกอบสี
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Set individual gamma coefficients for red, green and blue channels.
gifImage.AdjustGamma(1.5f, 2.5f, 3.5f);
gifImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeBradley(คู่)
การไบนารายการของภาพโดยใช้แอลกอริทึมข้อ จํากัด ที่ปรับแต่งของ Bradleyรอบภาพแบบบูรณาการเป็นวิธีการแปลงภาพสีเทาเป็นภาพรูปแบบไบนารี อัลgorithm นี้คํานวณขอบเขตท้องถิ่นสําหรับแต่ละพิกเซลตามความเข้มเฉลี่ยของ pixels รอบภายในหน้าต่างที่ระบุ โดยการปรับขอบเขตตามความเข้มของพิกเซลในท้องถิ่น Bradleyวิธีการมีประสิทธิภาพในการจัดการความแตกต่างของแสงและความต้านทานทั่วภาพ
public override void BinarizeBradley(double brightnessDifference)
Parameters
brightnessDifference
double
ความแตกต่างของแสงระหว่างพิกเซลและเฉลี่ยของหน้าต่าง s x s ของพิกเซลที่มุ่งเน้นรอบพิกเซลนี้
BinarizeFixed(บิต)
การไบนารีของภาพที่มีเส้นผ่าศูนย์กลางที่กําหนดไว้จะแปลงสีเทาหรือสีภาพเป็นภาพไบนารีซึ่งแต่ละพิกเซลได้รับการจัดอันดับเป็นสีดําหรือสีขาวขึ้นอยู่กับว่าค่าความเข้มของมันเกินข้อ จํากัด ที่กําหนดหรือไม่
public override void BinarizeFixed(byte threshold)
Parameters
threshold
byte
หมายเลข จํากัด หากหมายเลขสีเทาของพิกเซลที่ตรงกันข้ามสูงกว่าหมายเลข จํากัด หมายเลข 255 จะถูกกําหนดให้เป็นหมายเลข 0 ฯลฯ
Examples
ตัวอย่างต่อไปนี้ไบนารีภาพ GIF กับข้อ จํากัด ที่กําหนดไว้ ภาพไบนารีมีเพียง 2 สี - สีดําและสีขาว
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage djvuImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Binarize the image with a threshold value of 127.
// If a corresponding gray value of a pixel is greater than 127, a value of 255 will be assigned to it, 0 otherwise.
djvuImage.BinarizeFixed(127);
djvuImage.Save(dir + "sample.BinarizeFixed.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeOtsu()
การไบนารีของภาพด้วย Otsu thresholding เป็นวิธีการที่ใช้โดยอัตโนมัติกําหนดค่าข้อ จํากัด ที่เหมาะสมสําหรับการแปลงภาพสีเทาเป็นภาพรูปภาพไบนารี อัลgorithm Otsu อะไหล่คํานวณขอบเขตที่minimizes การเปลี่ยนแปลงภายในชั้นของความเข้มของ pixel ในสองผลลัพธ์คลาส (พื้นหลังและพื้นหลัง) เทคนิคนี้มีประโยชน์โดยเฉพาะอย่างยิ่งเมื่อหมายเลขข้อ จํากัด ที่เหมาะสมไม่ทราบและต้องกําหนดตามการปรับแต่งในภาพของ histogram
public override void BinarizeOtsu()
Examples
ตัวอย่างต่อไปนี้มีรูปภาพ GIF กับ Otsu ขนดก รูปภาพแบบไบนารีมีเพียง 2 สี - สีดําและสีขาว
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Binarize the image with Otsu thresholding.
gifImage.BinarizeOtsu();
gifImage.Save(dir + "sample.BinarizeOtsu.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ClearBlocks()
การทําความสะอาดบล็อก GIF ทั้งหมดจะลบข้อมูลที่มีอยู่ใด ๆ ที่เก็บไว้ภายในภาพการดําเนินงานนี้จะรีไซเคิลภาพได้อย่างมีประสิทธิภาพไปยังสถานะว่างเปล่าและลบภาพใด ๆบล็อกที่เพิ่มก่อนหน้านี้ ใช้วิธีการนี้เมื่อคุณต้องการที่จะเริ่มต้นใหม่ด้วยการทําความสะอาดslate เพื่อสร้างหรือแก้ไขภาพ GIF
public void ClearBlocks()
Examples
ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการลบบล็อกทั้งหมดจากภาพ GIF
using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
{
if (gifImage.ActiveFrame != null)
{
System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
}
else
{
System.Console.WriteLine("Active frame is not set");
}
System.Console.WriteLine("Clear all the blocks");
gifImage.ClearBlocks();
if (gifImage.ActiveFrame != null)
{
System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
}
else
{
System.Console.WriteLine("Active frame is not set");
}
}
// The output looks like this:
// Active frame size: { Width = 100, Height = 100}
// Clear all the blocks
// Active frame is not set
Crop(Rectangle)
พืชภาพโดยใช้พื้นที่ตรงที่กําหนด การดําเนินการนี้จะลบด้านนอกส่วนของภาพออกจากพื้นที่ที่กําหนดโดยตรงเท่านั้น
public override void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
ตุ๊กตา
Examples
ตัวอย่างต่อไปนี้จะปลูกภาพ GIF พื้นที่ปลูกจะระบุผ่าน Aspose.Imaging.Rectangle
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Crop the image. The cropping area is the rectangular central area of the image.
Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(gifImage.Width / 4, gifImage.Height / 4, gifImage.Width / 2, gifImage.Height / 2);
gifImage.Crop(area);
// Save the cropped image to PNG
gifImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Dither(DitheringMethod, int, IColorPalette)
ใช้ไทเทเนียมกับภาพปัจจุบัน กระบวนการนี้ปรับปรุงคุณภาพภาพโดยลดการเชื่อมต่อสีและปรับปรุงการเปลี่ยนแปลงสีซึ่งจะนําไปสู่ความเรียบง่ายมากขึ้นการปรากฏตัว
public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethod
วิธีการไดร์เวอร์
bitsCount
int
บิตสุดท้ายคํานวณสําหรับ dithering
customPalette
IColorPalette
แพลิเคชันที่กําหนดเองสําหรับ dithering
Examples
ตัวอย่างต่อไปนี้โหลดภาพ GIF และดําเนินการขอบเขตและลอย dithering โดยใช้ความลึกของแถบที่แตกต่างกัน
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Perform threshold dithering using 4-bit color palette which contains 16 colors.
// The more bits specified the higher quality and the bigger size of the output image.
// Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
gifImage.Dither(Aspose.Imaging.DitheringMethod.ThresholdDithering, 4, null);
gifImage.Save(dir + "sample.ThresholdDithering4.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Perform floyd dithering using 1-bit color palette which contains only 2 colors - black and white.
// The more bits specified the higher quality and the bigger size of the output image.
// Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
gifImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1, null);
gifImage.Save(dir + "sample.FloydSteinbergDithering1.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Filter(Rectangle, FilterOptionsBase)
ใช้ตัวกรองที่เฉพาะเจาะจงไปยังพื้นที่ที่กําหนดของภาพเพื่อปรับปรุงภาพของภาพคุณภาพหรือเปลี่ยนรูปร่างตามที่ต้องการ วิธีนี้จะดําเนินการตามที่เลือกพิกเซลภายในมุมตรงที่กําหนดเพื่อให้การปรับเป้าหมายสามารถทําได้ในขณะที่รักษาความสมบูรณ์ของข้อมูลภาพรอบ ๆ
public override void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
Rectangle
ตุ๊กตา
options
FilterOptionsBase
ตัวเลือก
Examples
ตัวอย่างต่อไปนี้ใช้ประเภทต่างๆของกรองสําหรับภาพ GIF
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a median filter with a rectangle size of 5 to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MedianFilterOptions(5));
gifImage.Save(dir + "sample.MedianFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a bilateral smoothing filter with a kernel size of 5 to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.BilateralSmoothingFilterOptions(5));
gifImage.Save(dir + "sample.BilateralSmoothingFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
gifImage.Save(dir + "sample.GaussianBlurFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
gifImage.Save(dir + "sample.GaussWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a motion wiener filter with a length of 5, a smooth value of 4.0 and an angle of 90.0 degrees to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MotionWienerFilterOptions(10, 1.0, 90.0));
gifImage.Save(dir + "sample.MotionWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image.
gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
gifImage.Save(dir + "sample.SharpenFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
GetOriginalOptions()
การกู้คืนตัวเลือกการตั้งค่าไฟล์เดิมซึ่งเป็นสิ่งสําคัญในการรักษาความซื่อสัตย์และความสม่ําเสมอในการประมวลผลภาพและการจัดการ วิธีนี้ช่วยให้ไม่มีรอยต่อการบูรณาการพารามิเตอร์เฉพาะไฟล์ในกิจกรรมต่อไปนี้เพื่อให้แน่ใจว่าการส่งมอบที่แม่นยําและการสอดคล้องกับลักษณะของภาพที่รุนแรงนี่อาจเป็นประโยชน์ในการรักษาความลึกและพารามิเตอร์อื่น ๆ ของภาพเดิมไม่เปลี่ยนแปลงตัวอย่างเช่นถ้าเราโหลดภาพ PNG สีดําและสีขาวด้วย 1 บิตต่อพิกเซลแล้วบันทึกมันโดยใช้Aspose.Imaging.DataStreamSupporter.Save(System.String) วิธีการภาพ PNG output กับ 8 บิตต่อพิกเซลจะผลิตเพื่อหลีกเลี่ยงและบันทึกภาพ PNG ด้วย 1 บิตต่อพิกเซลใช้วิธีการนี้เพื่อรับตัวเลือกการบันทึกที่เหมาะสมและผ่านพวกเขาวิธีการ Aspose.Imaging.Image.Save(System.String,Aspose.Imaging.ImageOptionsBase) เป็นพารามิเตอร์ที่สอง
public override ImageOptionsBase GetOriginalOptions()
Returns
ตัวเลือกตามการตั้งค่าไฟล์เดิม
Grayscale()
การแปลงของภาพเพื่อการแสดงผลสีเทาของมันแปลงสีภาพลงในรุ่นสีเทาโดยการลบข้อมูลสีในขณะที่รักษาโคมไฟ กระบวนการนี้ทําให้ภาพเรียบง่ายขึ้นไปสู่สีเทาทําให้มันเหมาะสําหรับการใช้งานต่างๆเช่นการพิมพ์การประมวลผลเอกสารและ grayscaleการวิเคราะห์
public override void Grayscale()
Examples
ตัวอย่างต่อไปนี้จะแปลงภาพ GIF สีเป็นภาพสีเทา รูปภาพ Grayscale ประกอบด้วยภาพสีเทาและมีข้อมูลความเข้มเท่านั้น
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
gifImage.Grayscale();
gifImage.Save(dir + "sample.Grayscale.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
InsertBlock(int, IGifBlock)
การใส่บล็อก GIF ใหม่ช่วยให้คุณสามารถเพิ่มข้อมูลที่กําหนดเองในตําแหน่งที่เฉพาะเจาะจงในภาพ วิธีนี้ช่วยให้คุณสามารถวางบล็อกที่กําหนดเองที่ต้องการตําแหน่งในภาพ GIF ให้ความยืดหยุ่นในการจัดระเบียบและโครงสร้างข้อมูลภาพ
public void InsertBlock(int index, IGifBlock block)
Parameters
index
int
องค์ประกอบที่ขึ้นอยู่กับศูนย์ซึ่งบล็อกจะถูกแทรก
block
IGifBlock
บล็อก GIF ที่จะเพิ่ม
OnPaletteChanged(IColorPalette, IColorPalette)
โทรเมื่อแพลตฟอร์มมีการเปลี่ยนแปลง
protected override void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
แพลิเคชันเก่า
newPalette
IColorPalette
แพลิเคชันใหม่
OnPaletteChanging(IColorPalette, IColorPalette)
การเรียกเมื่อแพลตฟอร์มจะเปลี่ยนแปลง
protected override void OnPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
แพลิเคชันเก่า
newPalette
IColorPalette
แพลิเคชันใหม่
OrderBlocks()
การสั่งซื้อบล็อก GIF ตามข้อกําหนด GIF ให้แน่ใจว่า GIF ที่เหมาะสมการจัดระเบียบและการปฏิบัติตามมาตรฐาน กระบวนการนี้เกี่ยวข้องกับการจัดระเบียบบล็อกในลําดับที่ถูกต้องตามที่กําหนดโดยข้อกําหนด นอกจากนี้อาจเกี่ยวข้องกับการลบ Aspose.Imaging.FileFormats.Gif.Blocks.GifGraphicsControlBlock ตัวอย่างที่ไม่จําเป็นสําหรับการจัดระเบียบสุดท้าย โดยการปฏิบัติตามข้อกําหนด GIFภาพที่เกิดขึ้นจะถูกโครงสร้างอย่างถูกต้องและเข้ากันได้กับการดู GIFการสมัคร
public void OrderBlocks()
RemoveBlock(บล็อก)
การลบบล็อก GIF จะลบข้อมูลที่เฉพาะเจาะจงจากภาพให้ความสามารถในการทําความสะอาดหรือแก้ไขโครงสร้างภาพ วิธีนี้ช่วยให้คุณสามารถลบไม่ต้องการหรือบล็อกที่ไม่จําเป็นเพื่อเพิ่มประสิทธิภาพภาพ GIF สําหรับการจัดเก็บข้อมูลที่มีประสิทธิภาพ ใช้สิ่งนี้ฟังก์ชั่นเพื่อกําจัดข้อมูลเก่าแก่จากภาพในขณะที่รักษาความสมบูรณ์และคุณภาพ
public void RemoveBlock(IGifBlock block)
Parameters
block
IGifBlock
บล็อกที่จะลบ
Remarks
หมายเหตุ: อย่าลืมวางบล็อกถ้าคุณจะไม่เพิ่มมันไปยัง GifImage อื่น ๆ
Resize(int, int, resizeType)
แก้ไขตัวอย่างนี้ Aspose.Imaging.Image
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
ความกว้างใหม่
newHeight
int
ความสูงใหม่
resizeType
ResizeType
ประเภทการรีไซเคิล
Examples
ตัวอย่างนี้โหลดภาพ GIF และรีไซเคิลมันโดยใช้วิธีการรีไซเคิลต่างๆ
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
// Scale up by 2 times using Nearest Neighbour resampling.
image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "upsample.nearestneighbour.gif");
}
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
// Scale down by 2 times using Nearest Neighbour resampling.
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
image.Save(dir + "downsample.nearestneighbour.gif");
}
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
// Scale up by 2 times using Bilinear resampling.
image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "upsample.bilinear.gif");
}
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
// Scale down by 2 times using Bilinear resampling.
image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
image.Save(dir + "downsample.bilinear.gif");
}
Resize(int, int, ImageResizeSettings)
แก้ไขตัวอย่างนี้ Aspose.Imaging.Image
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
ความกว้างใหม่
newHeight
int
ความสูงใหม่
settings
ImageResizeSettings
การตั้งค่า
Examples
ตัวอย่างนี้โหลดภาพ GIF และรีไซเคิลมันโดยใช้การตั้งค่ารีไซเคิลต่างๆ
string dir = "c:\\temp\\";
Aspose.Imaging.ImageResizeSettings resizeSettings = new Aspose.Imaging.ImageResizeSettings();
// The adaptive algorithm based on weighted and blended rational function and lanczos3 interpolation.
resizeSettings.Mode = Aspose.Imaging.ResizeType.AdaptiveResample;
// The small rectangular filter
resizeSettings.FilterType = Aspose.Imaging.ImageFilterType.SmallRectangular;
// The number of colors in the palette.
resizeSettings.EntriesCount = 256;
// The color quantization is not used
resizeSettings.ColorQuantizationMethod = ColorQuantizationMethod.None;
// The euclidian method
resizeSettings.ColorCompareMethod = ColorCompareMethod.Euclidian;
using (Aspose.Imaging.Image image = (Aspose.Imaging.Image)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;
// Scale down by 2 times using adaptive resampling.
gifImage.Resize(image.Width / 2, image.Height / 2, resizeSettings);
// Save to PNG
gifImage.Save(dir + "downsample.adaptive.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ResizeFullFrame(int, int, resizeType)
การรีไซเคิลของภาพในขณะที่พิจารณากรอบเต็มสําหรับแต่ละหน้าในGIF เพื่อป้องกันการปรากฏตัวของวัตถุที่เป็นไปได้ วิธีการนี้เป็นสิ่งสําคัญเพื่อรักษาความสมบูรณ์และคุณภาพของภาพโดยเฉพาะอย่างยิ่งเมื่อจัดการกับGIF animated หรือ sequences ของกรอบ
public void ResizeFullFrame(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
ความกว้างใหม่
newHeight
int
ความสูงใหม่
resizeType
ResizeType
ประเภทการรีไซเคิล
ResizeProportional(int, int, resizeType)
การรีไซเคิล proportional รักษาความสัมพันธ์ด้านของภาพในขณะที่ปรับขนาดของภาพเพื่อให้แน่ใจว่าภาพไม่ปรากฏขยายหรือผิดปกติ วิธีการนี้รีไซเคิลภาพอย่าง proportional โดยการสแกนทั้งความกว้างและความสูงโดยปัจจัยเดียวกัน การรีไซเคิล proportional จะรีไซเคิลแต่ละกรอบตามความสัมพันธ์ของ newWidth’/width และ
newHeight’/height
public void ResizeProportional(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
ความกว้างใหม่
newHeight
int
ความสูงใหม่
resizeType
ResizeType
ประเภทการรีไซเคิล
Rotate(บอล, บอล, สี)
วิธีการนี้หมุนภาพรอบจุดกลางของมัน โดยระบุการหมุนมุม, คุณสามารถหมุนภาพชั่วโมงหรือ counterชั่วโมงเพื่อให้ได้การนําทางที่ต้องการ การหมุนนี้ช่วยปรับการแสดงผลของภาพหรือการสอดคล้องโดยไม่ทําให้เนื้อหาของมันเสียหาย
public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
float
มุมหมุนในเกรด หมายเลขเชิงบวกจะหมุนตามชั่วโมง
resizeProportionally
bool
ถ้าตั้งค่าเป็น “จริง” คุณจะมีการเปลี่ยนแปลงขนาดภาพของคุณตามแนวตั้งหมุน (จุดมุม) projections ในกรณีอื่น ๆ ที่ปล่อยให้มิติไม่สัมผัสและเพียงภายใน เนื้อหาภาพจะหมุน
backgroundColor
Color
สีของพื้นหลัง
RotateFlip(RotateFlipType)
ทําการหมุนฟิล์มหรือทั้งสองบนกรอบที่ใช้งานโดยเฉพาะ การดําเนินงานนี้การประยุกต์ใช้การเปลี่ยนแปลงเฉพาะสําหรับกรอบที่ใช้งานอยู่ในขณะนี้ของภาพการรักษาความสมบูรณ์ของเฟรมอื่น ๆ ใน sequence
public override void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipType
ประเภทหมุน flip
Examples
ตัวอย่างนี้โหลดภาพ GIF จะหมุนได้ 90 องศาตามนาฬิกาและฟลีตัวเลือกภาพแนวนอนและ/หรือแนวตั้ง
string dir = "c:\\temp\\";
Aspose.Imaging.RotateFlipType[] rotateFlipTypes = new Aspose.Imaging.RotateFlipType[]
{
Aspose.Imaging.RotateFlipType.Rotate90FlipNone,
Aspose.Imaging.RotateFlipType.Rotate90FlipX,
Aspose.Imaging.RotateFlipType.Rotate90FlipXY,
Aspose.Imaging.RotateFlipType.Rotate90FlipY,
};
foreach (Aspose.Imaging.RotateFlipType rotateFlipType in rotateFlipTypes)
{
// Rotate, flip and save to the output file.
using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
image.RotateFlip(rotateFlipType);
image.Save(dir + "sample." + rotateFlipType + ".png", new Aspose.Imaging.ImageOptions.PngOptions());
}
}
SaveData(Stream)
เก็บข้อมูล
protected override void SaveData(Stream stream)
Parameters
stream
Stream
กระแสเพื่อบันทึกข้อมูล
SetFrameTime(คู่มือ)
ปรับระยะเวลาของแต่ละกรอบใน milliseconds เพื่อให้แน่ใจว่าเวลาที่สม่ําเสมอทั้งหมดใน sequence ของภาพ วิธีนี้ตั้งค่าเวลาการแสดงอย่างสม่ําเสมอสําหรับทุกกรอบช่วยให้มีการควบคุมความเร็วของภาพเคลื่อนไหวอย่างแม่นยําเปลี่ยนค่านี้จะทําให้การล่าช้าสําหรับกรอบทั้งหมด
public void SetFrameTime(ushort time)
Parameters
time
ushort
ระยะเวลาของกรอบใน milliseconds
UpdateDimensions(int, int)
ปรับปรุงขนาดภาพ
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
ความกว้างของภาพใหม่
newHeight
int
ความสูงของภาพใหม่