Class PngImage

Class PngImage

نام ها : Aspose.Imaging.FileFormats.Png جمع آوری: Aspose.Imaging.dll (25.4.0)

Manipulate Portable Network Graphics (PNG) راستر تصاویر با API متنوع ما،پشتیبانی از سطح فشرده سازی و عمق رنگ های مختلف از جملهGrayscale، Indexed Color، TrueColor، و کانال های آلفا.اجازه می دهد تا مدیریت متادیت تصویر جامع، در حالی که به راحتی بارگذاری تصاویر PNG،انجام دستکاری های مختلف، استفاده از فیلترها و تبدیل تصاویر به فایل های دیگرفرمت ها برای انعطاف پذیری و سفارشی سازی مطلوب

[JsonObject(MemberSerialization.OptIn)]
public class PngImage : RasterCachedImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata

Inheritance

object DisposableObject DataStreamSupporter Image RasterImage RasterCachedImage PngImage

Implements

IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasXmpData , IHasMetadata

اعضای ارثی

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.OnCached() , RasterCachedImage.OnPaletteChanged(IColorPalette, IColorPalette) , RasterCachedImage.IsCached , RasterImage.xmpData , 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.ReleaseManagedResources() , RasterImage.UpdateMetadata() , RasterImage.UpdateDimensions(int, int) , 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 , RasterImage.DataLoader , 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.UpdateContainer(Image) , Image.GetCanNotSaveMessage(ImageOptionsBase) , Image.GetFitRectangle(Rectangle) , Image.GetImage2Export(ImageOptionsBase, Rectangle, IImageExporter) , Image.GetFitRectangle(Rectangle, int[]) , Image.OnPaletteChanged(IColorPalette, IColorPalette) , Image.OnPaletteChanging(IColorPalette, IColorPalette) , Image.ReleaseManagedResources() , 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.timeout , DataStreamSupporter.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.SaveData(Stream) , DataStreamSupporter.ReleaseManagedResources() , DataStreamSupporter.OnDataStreamContainerChanging(StreamContainer) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , 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

این مثال نشان می دهد که چگونه یک تصویر PNG را از یک فایل بارگذاری کنید.

string dir = "c:\\temp\\";

                                                                  // Load a PNG image from a file.
                                                                  using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(dir + "sample.png"))
                                                                  {
                                                                      // Transform the image to grayscale representation
                                                                      pngImage.Grayscale();

                                                                      // Save to a file.
                                                                      pngImage.Save(dir + "sample.grayscale.png");
                                                                  }

Constructors

PngImage(int، int)

شروع یک شی جدید از کلاس Aspose.Imaging.FileFormats.Png.PngImage با ارائهپارامترهای عرض و ارتفاع.این سازنده ایجاد PNG را آسان تر می کندتصاویر با اجازه دادن به توسعه دهندگان برای مشخص کردن ابعاد به طور مستقیم، تسهیلمدیریت موثر داده های تصویر PNG در برنامه های کاربردی آنها.

public PngImage(int width, int height)

Parameters

width int

در عرض

height int

ارتفاع است.

Examples

این مثال نشان می دهد که چگونه یک تصویر PNG از اندازه مشخص شده ایجاد کنید، آن را با یک رنگ جامد پر کنید و آن را به یک فایل ذخیره کنید.

string dir = "c:\\temp\\";

                                                                                                                                // Create a PNG image of 100x100 px.
                                                                                                                                using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100))
                                                                                                                                {
                                                                                                                                    // Do some image processing, e.g. fill the entire image in red.
                                                                                                                                    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);
                                                                                                                                    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                                                    graphics.FillRectangle(brush, pngImage.Bounds);

                                                                                                                                    // Save to a file.
                                                                                                                                    pngImage.Save(dir + "output.png");
                                                                                                                                }

PngImage(String)

ایجاد یک مثال جدید از کلاس Aspose.Imaging.FileFormats.Png.PngImage با استفاده از مسیرپارامتر برای مشخص کردن محل فایل تصویر برای بارگذاری.این سازندهاجازه می دهد تا توسعه دهندگان به راحتی ایجاد تصاویر PNG با بارگذاری آنها از یک فایل،ساده سازی فرآیند کار با تصاویر PNG در برنامه های خود.

public PngImage(string path)

Parameters

path string

راهی برای بارگذاری یک تصویر

Examples

این مثال نشان می دهد که چگونه یک تصویر PNG را از یک فایل بارگذاری کنید.

string dir = "c:\\temp\\";

                                                                  // Load a PNG image from a file.
                                                                  using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(dir + "sample.png"))
                                                                  {
                                                                      // Transform the image to grayscale representation
                                                                      pngImage.Grayscale();

                                                                      // Save to a file.
                                                                      pngImage.Save(dir + "sample.grayscale.png");
                                                                  }

PngImage(RasterImage)

ایجاد یک مثال جدید از کلاس Aspose.Imaging.FileFormats.Png.PngImage با ارائه یک راسترتصویر به عنوان یک پارامتر.این سازنده به توسعه دهندگان اجازه می دهد تا به طور مستقیم شروع یکPNG تصویر اشیاء با استفاده از یک تصویر Raster موجود، روندکار با تصاویر PNG در برنامه های خود را.

public PngImage(RasterImage rasterImage)

Parameters

rasterImage RasterImage

تصاویری از راستر

Examples

این مثال نشان می دهد که چگونه برای بارگذاری تصویر PNG از یک تصویر BMP.

string dir = "c:\\temp\\";

                                                                     // Load a TrueColor PNG image from a BMP image.
                                                                     // First, create a temporal BMP image that will be a foundation for building a PNG image.
                                                                     // You can also load BMP image from a file or use an image of any other raster format.
                                                                     using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100))
                                                                     {
                                                                         // Fill the entire BMP image in red.
                                                                         Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);
                                                                         Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                         gr.FillRectangle(brush, bmpImage.Bounds);

                                                                         using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(bmpImage))
                                                                         {
                                                                             System.Console.WriteLine("The PNG color type: {0}", pngImage.GetOriginalOptions());
                                                                             pngImage.Save(dir + "output.png");
                                                                         }
                                                                     }

PngImage(برچسب ها: PngColorType)

شروع یک مثال جدید از کلاس Aspose.Imaging.FileFormats.Png.PngImage با مشخص کردنمسیر به فایل تصویر و نوع رنگ.این سازنده اجازه می دهد برایایجاد تصاویر PNG از فایل ها با انواع مختلف رنگ، ارائه می دهدانعطاف پذیری در مدیریت فرمت های مختلف تصویر

public PngImage(string path, PngColorType colorType)

Parameters

path string

راهی برای بارگذاری یک تصویر

colorType PngColorType

نوع رنگ است.

Examples

این مثال نشان می دهد که چگونه یک تصویر PNG را از یک فایل با نوع رنگ مشخص شده بارگذاری کنید.

string dir = "c:\\temp\\";

                                                                                                // Load a PNG image from a file.
                                                                                                // Note that the colorful image will be converted to grayscale automatically.
                                                                                                using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(dir + "sample.png", Aspose.Imaging.FileFormats.Png.PngColorType.Grayscale))
                                                                                                {
                                                                                                    // Save to a file.
                                                                                                    pngImage.Save(dir + "sample.grayscale.png");
                                                                                                }

Exceptions

ArgumentNullException

PngImage(برچسب ها: PngColorType)

ایجاد یک مثال جدید از کلاس Aspose.Imaging.FileFormats.Png.PngImage با مشخص کردن یکتصویر راستر و نوع رنگ.این سازنده به توسعه دهندگان اجازه می دهد تا به طور مستقیمتبدیل تصاویر راستر به فرمت PNG در حالی که مشخص کردن نوع رنگ مورد نظر،انعطاف پذیری در نمایندگی رنگی

public PngImage(RasterImage rasterImage, PngColorType colorType)

Parameters

rasterImage RasterImage

تصاویری از راستر

colorType PngColorType

نوع رنگ است.

Examples

این مثال نشان می دهد که چگونه برای بارگذاری تصویر PNG از یک تصویر BMP با نوع رنگ مشخص شده است.

string dir = "c:\\temp\\";

                                                                                                   // Load a grayscale PNG image from a colored BMP image.
                                                                                                   // First, create a temporal BMP image that will be a foundation for building a PNG image.
                                                                                                   // You can also load BMP image from a file or use an image of any other raster format.
                                                                                                   using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100))
                                                                                                   {
                                                                                                       // Fill the entire BMP image in red.
                                                                                                       Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);
                                                                                                       Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                       gr.FillRectangle(brush, bmpImage.Bounds);

                                                                                                       // The colors of the image pixels will be converted to their grayscale counterparts.
                                                                                                       using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(bmpImage, Aspose.Imaging.FileFormats.Png.PngColorType.Grayscale))
                                                                                                       {
                                                                                                           pngImage.Save(dir + "output.grayscale.png");
                                                                                                       }
                                                                                                   }

PngImage(Stream)

ایجاد یک مثال جدید از کلاس Aspose.Imaging.FileFormats.Png.PngImage با شروع آناین سازنده به توسعه دهندگان اجازه می دهد تا تصاویر PNG را به طور مستقیم بارگذاری کنند.از یک جریان، ارائه انعطاف پذیری در تصویر برداشت از منابع مختلف.

public PngImage(Stream stream)

Parameters

stream Stream

جریان برای بارگذاری یک تصویر.

Examples

این مثال نشان می دهد که چگونه یک تصویر PNG را از یک فایل یا جریان فایل بارگذاری کنید.

string dir = "c:\\temp\\";

                                                                                   // Load a PNG image from a file stream.
                                                                                   using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.png"))
                                                                                   {
                                                                                       using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(stream))
                                                                                       {
                                                                                           // Transform the image to grayscale representation
                                                                                           pngImage.Grayscale();

                                                                                           // Save to a file.
                                                                                           pngImage.Save(dir + "sample.grayscale.png");
                                                                                       }
                                                                                   }

PngImage(int، int، PngColorType)

یک مثال جدید از کلاس Aspose.Imaging.FileFormats.Png.PngImage را تکرار کنید.پهنای باند، ارتفاع و پارامترهای نوع رنگ مورد نظر.این سازنده اجازه می دهدایجاد سریع تصاویر PNG با ابعاد سفارشی و تنظیمات رنگی،تسهیل بهینه سازی تصویر برای برنامه های مختلف و جریان های کار.

public PngImage(int width, int height, PngColorType colorType)

Parameters

width int

در عرض

height int

ارتفاع است.

colorType PngColorType

نوع رنگ است.

Examples

این مثال نشان می دهد که چگونه یک تصویر PNG از اندازه مشخص شده با نوع رنگ مشخص شده ایجاد کنید، آن را با یک رنگ جامد پر کنید و آن را در یک فایل ذخیره کنید.

string dir = "c:\\temp\\";

                                                                                                                                                              // Create a grayscale PNG image of 100x100 px.
                                                                                                                                                              // All colors will be automatically converted to the grayscale format.
                                                                                                                                                              using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100, Aspose.Imaging.FileFormats.Png.PngColorType.Grayscale))
                                                                                                                                                              {
                                                                                                                                                                  // Do some image processing, e.g. fill the entire image in red.
                                                                                                                                                                  Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);
                                                                                                                                                                  Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                                                                                  graphics.FillRectangle(brush, pngImage.Bounds);

                                                                                                                                                                  // Save to a file.
                                                                                                                                                                  pngImage.Save(dir + "output.grayscale.png");
                                                                                                                                                              }

PngImage(PngOptions، int، int)

شروع یک مثال جدید از کلاس Aspose.Imaging.FileFormats.Png.PngImage، شاملگزینه های PNG در کنار پارامترهای عرض و ارتفاع.این سازنده قدرتتوسعه دهندگان برای ایجاد تصاویر PNG با تنظیمات و ابعاد سفارشی،ارائه انعطاف پذیری در تولید تصویر برای موارد مختلف استفاده.

public PngImage(PngOptions pngOptions, int width, int height)

Parameters

pngOptions PngOptions

گزینه های PNG

width int

در عرض

height int

ارتفاع است.

Examples

این مثال نشان می دهد که چگونه یک تصویر PNG را با گزینه های مشخص شده ایجاد کنید، آن را با یک رنگ گرادینت خطی پر کنید و آن را به یک فایل ذخیره کنید.

string dir = "c:\\temp\\";

                                                                                                                                                Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();

                                                                                                                                                // The number of bits per color channel
                                                                                                                                                createOptions.BitDepth = 8;

                                                                                                                                                // Each pixel is a (red, green, blue) triple followed by the alpha component.
                                                                                                                                                createOptions.ColorType = Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;

                                                                                                                                                // The maximum level of compression.
                                                                                                                                                createOptions.CompressionLevel = 9;

                                                                                                                                                // Usage of filters allows to compress continuous tonal images more effectively.
                                                                                                                                                createOptions.FilterType = Aspose.Imaging.FileFormats.Png.PngFilterType.Sub;

                                                                                                                                                // Use progressive loading
                                                                                                                                                createOptions.Progressive = true;

                                                                                                                                                // Create a PNG image with custom parameters.
                                                                                                                                                using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(createOptions, 100, 100))
                                                                                                                                                {
                                                                                                                                                    Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
                                                                                                                                                            new Aspose.Imaging.Point(0, 0),
                                                                                                                                                            new Aspose.Imaging.Point(pngImage.Width, pngImage.Height),
                                                                                                                                                            Aspose.Imaging.Color.Blue,
                                                                                                                                                            Aspose.Imaging.Color.Transparent);

                                                                                                                                                    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);

                                                                                                                                                    // Fill the image with a semi-transparent gradient.
                                                                                                                                                    graphics.FillRectangle(gradientBrush, pngImage.Bounds);

                                                                                                                                                    // Save to a file.
                                                                                                                                                    pngImage.Save(dir + "output.explicitoptions.png");
                                                                                                                                                }

Properties

BackgroundColor

بازگرداندن رنگ پس زمینه از تصویر، اگر یکی مشخص شده است.مفید برای برنامه هایی است که نیاز به شناسایی و دستکاری بالقوه دارند.رنگ پس زمینه یک تصویر

public override Color BackgroundColor { get; set; }

ارزش املاک

Color

Examples

مثال زیر نشان می دهد که چگونه برای تنظیم رنگ های کاملا شفاف برای بخشی از یک تصویر TrueColor PNG که از کانال آلفا پشتیبانی نمی کند.

Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                                   createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource("c:\\temp\\transparent.png", false);
                                                                                                                                                   createOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.Truecolor;

                                                                                                                                                   // Create a TrueColor PNG image of 100x100 px.
                                                                                                                                                   using (Aspose.Imaging.Image image = Image.Create(createOptions, 100, 100))
                                                                                                                                                   {
                                                                                                                                                       Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)image;
                                                                                                                                                       Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(pngImage);

                                                                                                                                                       // All red pixels will be considered as fully transparent.
                                                                                                                                                       pngImage.TransparentColor = Aspose.Imaging.Color.Red;
                                                                                                                                                       pngImage.HasTransparentColor = true;

                                                                                                                                                       // All transparent pixels will have a background color.
                                                                                                                                                       pngImage.BackgroundColor = Aspose.Imaging.Color.Green;
                                                                                                                                                       pngImage.HasBackgroundColor = true;

                                                                                                                                                       // Fill the entire image with white color.
                                                                                                                                                       gr.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White), pngImage.Bounds);

                                                                                                                                                       // Fill the top-left quarter of the image with the transparent color.
                                                                                                                                                       // This makes the top-left quarter colored in the background color.
                                                                                                                                                       Rectangle rect = new Rectangle(0, 0, pngImage.Width / 2, pngImage.Height / 2);
                                                                                                                                                       gr.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red), rect);

                                                                                                                                                       pngImage.Save();
                                                                                                                                                   }

BitsPerPixel

بازگرداندن بیت ها در هر پیکسل برای تصویر.این ویژگی ارائه می دهد حیاتیاطلاعات مربوط به عمق رنگ تصویر، به توسعه دهندگان اجازه می دهد تادرک سطح جزئیات و دقت رنگ موجود در داده های تصویر.

public override int BitsPerPixel { get; }

ارزش املاک

int

FileFormat

بازگرداندن فرمت فایل مرتبط با مثال تصویر.اینمالکیت ارائه اطلاعات ضروری در مورد نوع فایل، امکان پذیر استمدیریت و پردازش موثر بر اساس نیازهای فرمت خاص.

public override FileFormat FileFormat { get; }

ارزش املاک

FileFormat

HasAlpha

بازگرداندن یک مقدار بولی نشان می دهد که آیا تصویر دارای یک کانال آلفا است یا خیر.که شفافیت آن را تعیین می کند.این دارایی برای درخواست ها مفید استاین امر نیاز به شفافیت دارد و به توسعه دهندگان اجازه می دهد تا تعیین کنند که آیاپردازش اضافی برای رسیدگی به مناطق شفاف در تصویر مورد نیاز است.

public override bool HasAlpha { get; }

ارزش املاک

bool

Examples

مثال زیر نشان می دهد که چگونه می توان بررسی کرد که آیا یک تصویر PNG از کانال آلفا پشتیبانی می کند.

// Get all supported PNG color types.
                                                                                          System.Array colorTypes = System.Enum.GetValues(typeof(Aspose.Imaging.FileFormats.Png.PngColorType));

                                                                                          foreach (Aspose.Imaging.FileFormats.Png.PngColorType colorType in colorTypes)
                                                                                          {
                                                                                              Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                              createOptions.Source = new Sources.StreamSource(new System.IO.MemoryStream());
                                                                                              createOptions.ColorType = colorType;

                                                                                              using (Aspose.Imaging.Image image = Image.Create(createOptions, 100, 100))
                                                                                              {
                                                                                                  Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)image;

                                                                                                  if (pngImage.HasAlpha)
                                                                                                  {
                                                                                                      System.Console.WriteLine("A {0} PNG image supports alpha channel", createOptions.ColorType);
                                                                                                  }
                                                                                                  else
                                                                                                  {
                                                                                                      System.Console.WriteLine("A {0} PNG image doesn't support alpha channel", createOptions.ColorType);
                                                                                                  }
                                                                                              }
                                                                                          }

                                                                                          // The output looks like this:
                                                                                          // A Grayscale PNG image doesn't support alpha channel
                                                                                          // A Truecolor PNG image doesn't support alpha channel
                                                                                          // A IndexedColor PNG image doesn't support alpha channel
                                                                                          // A GrayscaleWithAlpha PNG image supports alpha channel
                                                                                          // A TruecolorWithAlpha PNG image supports alpha channel

HasBackgroundColor

یک مقدار بولی نشان می دهد که آیا تصویر دارای رنگ پس زمینه است یا خیر.این ویژگی برای برنامه هایی مفید است که نیاز به تعیین اینکه آیا یک تصویرشامل یک رنگ پس زمینه است که می تواند برای پردازش های مختلف مهم باشد.وظایف مانند ترکیب، ارائه یا صادرات.

public override bool HasBackgroundColor { get; set; }

ارزش املاک

bool

Examples

مثال زیر نشان می دهد که چگونه برای تنظیم رنگ های کاملا شفاف برای بخشی از یک تصویر TrueColor PNG که از کانال آلفا پشتیبانی نمی کند.

Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                                   createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource("c:\\temp\\transparent.png", false);
                                                                                                                                                   createOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.Truecolor;

                                                                                                                                                   // Create a TrueColor PNG image of 100x100 px.
                                                                                                                                                   using (Aspose.Imaging.Image image = Image.Create(createOptions, 100, 100))
                                                                                                                                                   {
                                                                                                                                                       Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)image;
                                                                                                                                                       Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(pngImage);

                                                                                                                                                       // All red pixels will be considered as fully transparent.
                                                                                                                                                       pngImage.TransparentColor = Aspose.Imaging.Color.Red;
                                                                                                                                                       pngImage.HasTransparentColor = true;

                                                                                                                                                       // All transparent pixels will have a background color.
                                                                                                                                                       pngImage.BackgroundColor = Aspose.Imaging.Color.Green;
                                                                                                                                                       pngImage.HasBackgroundColor = true;

                                                                                                                                                       // Fill the entire image with white color.
                                                                                                                                                       gr.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White), pngImage.Bounds);

                                                                                                                                                       // Fill the top-left quarter of the image with the transparent color.
                                                                                                                                                       // This makes the top-left quarter colored in the background color.
                                                                                                                                                       Rectangle rect = new Rectangle(0, 0, pngImage.Width / 2, pngImage.Height / 2);
                                                                                                                                                       gr.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red), rect);

                                                                                                                                                       pngImage.Save();
                                                                                                                                                   }

HasTransparentColor

ارزش بولی را نشان می دهد که آیا تصویر حاوی شفافیت است یا خیر.این ویژگی برای برنامه هایی که نیاز به مدیریت دارند بسیار مهم است.شفافیت، به توسعه دهندگان اجازه می دهد تا تعیین کنند که آیا پردازش اضافینیاز به مدیریت مناطق شفاف در تصویر.

public override bool HasTransparentColor { get; set; }

ارزش املاک

bool

Examples

مثال زیر نشان می دهد که چگونه برای تنظیم رنگ های کاملا شفاف برای بخشی از یک تصویر TrueColor PNG که از کانال آلفا پشتیبانی نمی کند.

Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                                   createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource("c:\\temp\\transparent.png", false);
                                                                                                                                                   createOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.Truecolor;

                                                                                                                                                   // Create a TrueColor PNG image of 100x100 px.
                                                                                                                                                   using (Aspose.Imaging.Image image = Image.Create(createOptions, 100, 100))
                                                                                                                                                   {
                                                                                                                                                       Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)image;
                                                                                                                                                       Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(pngImage);

                                                                                                                                                       // All red pixels will be considered as fully transparent.
                                                                                                                                                       pngImage.TransparentColor = Aspose.Imaging.Color.Red;
                                                                                                                                                       pngImage.HasTransparentColor = true;

                                                                                                                                                       // All transparent pixels will have a background color.
                                                                                                                                                       pngImage.BackgroundColor = Aspose.Imaging.Color.Green;
                                                                                                                                                       pngImage.HasBackgroundColor = true;

                                                                                                                                                       // Fill the entire image with white color.
                                                                                                                                                       gr.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White), pngImage.Bounds);

                                                                                                                                                       // Fill the top-left quarter of the image with the transparent color.
                                                                                                                                                       // This makes the top-left quarter colored in the background color.
                                                                                                                                                       Rectangle rect = new Rectangle(0, 0, pngImage.Width / 2, pngImage.Height / 2);
                                                                                                                                                       gr.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red), rect);

                                                                                                                                                       pngImage.Save();
                                                                                                                                                   }

Height

این ویژگی ابعاد عمودی تصویر را باز می گرداند.تصویر، به توسعه دهندگان اجازه می دهد تا اندازه آن را در پیکسل ها در طولمحور عمودی

public override int Height { get; }

ارزش املاک

int

HorizontalResolution

بازگرداندن یا تغییر رزولوشن افقی تصویر.این ویژگینشان دهنده تعداد پیکسل ها در هر اینچ در امتداد محور افقیتنظیم این رزولوشن می تواند بر اندازه فیزیکی تصویر تاثیر بگذارد.چاپ شده یا نمایش داده شده

public override double HorizontalResolution { get; set; }

ارزش املاک

double

Examples

مثال زیر نشان می دهد که چگونه برای تنظیم رزولوشن افقی / عمودی یک تصویر PNG.

string dir = "c:\\temp\\";

                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                {
                                                                                                    Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)image;

                                                                                                    // Get horizontal and vertical resolution of the PngImage.
                                                                                                    double horizontalResolution = pngImage.HorizontalResolution;
                                                                                                    double verticalResolution = pngImage.VerticalResolution;
                                                                                                    System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
                                                                                                    System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);

                                                                                                    if (horizontalResolution != 96.0 || verticalResolution != 96.0)
                                                                                                    {
                                                                                                        // Use the SetResolution method for updating both resolution values in a single call.
                                                                                                        System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                        pngImage.SetResolution(96.0, 96.0);

                                                                                                        System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", pngImage.HorizontalResolution);
                                                                                                        System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", pngImage.VerticalResolution);
                                                                                                    }
                                                                                                }

Interlaced

بازگرداندن یک مقدار بولی نشان می دهد که آیا Aspose.Imaging.FileFormats.Png.PngImageمتصل، که تعیین می کند که آیا داده های تصویر در یکبرای حمل و نقل سریع تر و یا حمل و نقل سریع تر

public bool Interlaced { get; }

ارزش املاک

bool

IsInterlaced

بازگرداندن یک مقدار بولی نشان می دهد که آیا مثال تصویر متصل است.املاک برای بهینه سازی استراتژی های بارگذاری و اطمینان از بهره وری بسیار مهم است.عملکرد در هنگام پردازش تصویر یا نمایش وظایف.

public bool IsInterlaced { get; }

ارزش املاک

bool

RawDataFormat

دسترسی به فرمت داده های خام تصویر.این ویژگی ارائه می دهد بینش درچگونگی ساختار داده های تصویر به صورت داخلی، که می تواند برای پیشرفته مفید باشدکارهای پردازش تصویر یا تبدیل فرمت

public override PixelDataFormat RawDataFormat { get; }

ارزش املاک

PixelDataFormat

Examples

مثال زیر تصاویر PNG را بارگذاری می کند و اطلاعات مربوط به فرمت داده های خام و کانال آلفا را چاپ می کند.

// The PNG images to load.
                                                                                                                 string[] fileNames = new string[]
                                                                                                                 {
                                                                                                                     @"c:\temp\sample.png",
                                                                                                                     @"c:\temp\alpha.png",
                                                                                                                 };

                                                                                                                 foreach (string fileName in fileNames)
                                                                                                                 {
                                                                                                                     using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName))
                                                                                                                     {
                                                                                                                         Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)image;
                                                                                                                         System.Console.WriteLine("ImageFile={0}, FileFormat={1}, HasAlpha={2}", fileName, pngImage.RawDataFormat, pngImage.HasAlpha);
                                                                                                                     }
                                                                                                                 }

                                                                                                                 // The output may look like this:
                                                                                                                 // ImageFile=c:\temp\sample.png, FileFormat=Rgb24Bpp, used channels: 8,8,8, HasAlpha=False
                                                                                                                 // ImageFile=c:\temp\alpha.png, FileFormat=RGBA32Bpp, used channels: 8,8,8,8, HasAlpha=True

TransparentColor

بازگرداندن رنگ شفاف تصویر، اگر وجود داشته باشد.قابل توجه برای درخواست هایی که نیاز به مدیریت دقیق مناطق شفاف دارنددر داخل تصاویر، اجازه می دهد تا توسعه دهندگان برای دسترسی و دستکاری خاصرنگ های شفاف استفاده می شود.

public override Color TransparentColor { get; set; }

ارزش املاک

Color

Examples

مثال زیر نشان می دهد که چگونه برای تنظیم رنگ های کاملا شفاف برای بخشی از یک تصویر TrueColor PNG که از کانال آلفا پشتیبانی نمی کند.

Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                                   createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource("c:\\temp\\transparent.png", false);
                                                                                                                                                   createOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.Truecolor;

                                                                                                                                                   // Create a TrueColor PNG image of 100x100 px.
                                                                                                                                                   using (Aspose.Imaging.Image image = Image.Create(createOptions, 100, 100))
                                                                                                                                                   {
                                                                                                                                                       Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)image;
                                                                                                                                                       Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(pngImage);

                                                                                                                                                       // All red pixels will be considered as fully transparent.
                                                                                                                                                       pngImage.TransparentColor = Aspose.Imaging.Color.Red;
                                                                                                                                                       pngImage.HasTransparentColor = true;

                                                                                                                                                       // All transparent pixels will have a background color.
                                                                                                                                                       pngImage.BackgroundColor = Aspose.Imaging.Color.Green;
                                                                                                                                                       pngImage.HasBackgroundColor = true;

                                                                                                                                                       // Fill the entire image with white color.
                                                                                                                                                       gr.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White), pngImage.Bounds);

                                                                                                                                                       // Fill the top-left quarter of the image with the transparent color.
                                                                                                                                                       // This makes the top-left quarter colored in the background color.
                                                                                                                                                       Rectangle rect = new Rectangle(0, 0, pngImage.Width / 2, pngImage.Height / 2);
                                                                                                                                                       gr.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red), rect);

                                                                                                                                                       pngImage.Save();
                                                                                                                                                   }

VerticalResolution

دسترسی به رزولوشن عمودی تصویر را فراهم می کند توسعه دهندگان می توانند ازاین دارایی برای بازگرداندن یا اصلاح تنظیمات رزولوشن، که نشان دهندهتعداد پیکسل ها در هر اینچ (PPI) در امتداد محور عمودی تصویر

public override double VerticalResolution { get; set; }

ارزش املاک

double

Examples

مثال زیر نشان می دهد که چگونه برای تنظیم رزولوشن افقی / عمودی یک تصویر PNG.

string dir = "c:\\temp\\";

                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                {
                                                                                                    Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)image;

                                                                                                    // Get horizontal and vertical resolution of the PngImage.
                                                                                                    double horizontalResolution = pngImage.HorizontalResolution;
                                                                                                    double verticalResolution = pngImage.VerticalResolution;
                                                                                                    System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
                                                                                                    System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);

                                                                                                    if (horizontalResolution != 96.0 || verticalResolution != 96.0)
                                                                                                    {
                                                                                                        // Use the SetResolution method for updating both resolution values in a single call.
                                                                                                        System.Console.WriteLine("Set resolution values to 96 dpi");
                                                                                                        pngImage.SetResolution(96.0, 96.0);

                                                                                                        System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", pngImage.HorizontalResolution);
                                                                                                        System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", pngImage.VerticalResolution);
                                                                                                    }
                                                                                                }

Width

امکان بازگرداندن عرض تصویر، ارائه اطلاعات ضروریدر مورد ابعاد آن.این ملک اغلب توسط توسعه دهندگان مورد استفاده قرار می گیردتعیین عرض تصویر، اجازه می دهد تا آنها را به انجام عملیات مختلف بر اساسدر اندازه خود

public override int Width { get; }

ارزش املاک

int

XmpData

دسترسی یا تغییر داده های متابولیک متابولیک متابولیک (XMP)این دارایی، استخراج، اصلاح و یااضافه کردن متا داده ها، امکان مدیریت جامع اطلاعات مربوط به تصویر.

public override XmpPacketWrapper XmpData { get; set; }

ارزش املاک

XmpPacketWrapper

Methods

GetDefaultOptions(موضوع[])

گزینه های پیش فرض را انتخاب کنید.

public override ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object [ ]

این استدلال ها

Returns

ImageOptionsBase

گزینه های پیش فرض

GetModifyDate(بول)

بازگرداندن فاصله زمانی نشان دهنده آخرین تغییرات در منبعاین روش دسترسی به متا داده های حیاتی را فراهم می کند و امکان استفاده ازمشخص کردن زمانی که تصویر آخرین بار تغییر کرده است، تسهیل ردیابی نسخه ومدیریت محتوا

public override DateTime GetModifyDate(bool useDefault)

Parameters

useDefault bool

اگر به “واقعی” تنظیم شده باشد، از اطلاعات FileInfo به عنوان مقدار پیش فرض استفاده کنید.

Returns

DateTime

تاریخ و زمان تصویر منبع آخرین بار اصلاح شده است.

GetOriginalOptions()

گزینه ها را بر اساس تنظیمات فایل اصلی دریافت کنید.این کار می تواند برای حفظ عمق و سایر پارامترهای تصویر اصلی مفید باشد.به عنوان مثال، اگر ما یک تصویر PNG سیاه و سفید را با 1 بیتی در هر پیکسل بارگذاری کنیم و سپس آن را با استفاده ازAspose.Imaging.DataStreamSupporter.Save(System.String) روش، تصویر خروجی PNG با 8 بیتی در هر پیکسل تولید خواهد شد.برای جلوگیری از آن و ذخیره تصویر PNG با 1 بیتی در هر پیکسل، از این روش برای به دست آوردن گزینه های ذخیره مناسب و عبور آنها استفاده کنید.به روش Aspose.Imaging.Image.Save(System.String،Aspose.Imaging.ImageOptionsBase) به عنوان پارامتر دوم.

public override ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

گزینه های مبتنی بر تنظیمات فایل اصلی.

OnPaletteChanged(بایگانی برچسب ها: IColorPalette)

هنگامی که پالت تغییر می کند.

protected override void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette

پالت قدیمی

newPalette IColorPalette

پالت جدید است.

SaveData(Stream)

ذخیره سازی داده ها

protected override void SaveData(Stream stream)

Parameters

stream Stream

جریان است.

UpdateDimensions(int، int)

ابعاد به روز رسانی

protected override void UpdateDimensions(int newWidth, int newHeight)

Parameters

newWidth int

عرض جدید است.

newHeight int

ارتفاع جدید است.

UpdateMetadata()

تاریخ و زمان آخرین تغییر تصویر را به روز می کند.

protected override void UpdateMetadata()
 فارسی