Class PngImage
اسم الفضاء : Aspose.Imaging.FileFormats.Png تجميع: Aspose.Imaging.dll (25.4.0)
التعامل مع صور الرسومات الشبكية المحمولة (PNG) مع API المتنوع لدينا ،يقدم دعمًا لمستويات الضغط ومختلف أعماق الألوان بما في ذلكقنوات Grayscale و Indexed Color و TrueColor و Alpha.تتيح إدارة بيانات الصورة الشاملة، وفي الوقت نفسه تحميل صور 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(إنت، إنت)
إطلاق كائن جديد من فئة 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(الستار)
إنشاء مثال جديد من فئة 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 باستخدام صورة راستر موجودة، وتسريع عمليةالعمل مع صور 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
PngImage(أرشيف الوسم : PngColor)
يخلق مثالًا جديدًا من فئة 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(إنت، إنت، 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; }
قيمة الممتلكات
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; }
قيمة الممتلكات
FileFormat
يعيد تنسيق الملف المرتبط بمثال الصورة.الممتلكات توفر المعلومات الأساسية المتعلقة بنوع الملفات، مما يتيحمعالجة فعالة ومعالجة استنادا إلى متطلبات النموذج المحددة.
public override FileFormat FileFormat { get; }
قيمة الممتلكات
HasAlpha
يعيد قيمة بوليان تشير إلى ما إذا كانت الصورة لديها قناة ألفا،التي تحدد شفافيتها.هذا الممتلكات مفيدة للتطبيقاتمن الضروري التعامل مع الشفافية ، مما يسمح للمطورين بتحديد ما إذا كانيتطلب معالجة إضافية للتعامل مع المناطق الشفافة في الصورة.
public override bool HasAlpha { get; }
قيمة الممتلكات
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; }
قيمة الممتلكات
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; }
قيمة الممتلكات
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; }
قيمة الممتلكات
HorizontalResolution
استرداد أو تعديل القرار الأفقي للصورة.هذا الممتلكاتيمثل عدد البكسل لكل بوصة على طول المحور الأفقيتعديل هذا القرار يمكن أن يؤثر على الحجم المادي للصورة عندماطباعة أو عرض.
public override double HorizontalResolution { get; set; }
قيمة الممتلكات
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; }
قيمة الممتلكات
IsInterlaced
يعيد قيمة البولين التي تشير إلى ما إذا كانت عينة الصورة مترابطة.الممتلكات أمر حاسم لتحسين استراتيجيات الشحن وضمان كفاءةأداء أثناء معالجة الصور أو مهام العرض.
public bool IsInterlaced { get; }
قيمة الممتلكات
RawDataFormat
الوصول إلى تنسيق البيانات الخام للصورة.هذه الممتلكات توفر إدراككيف يتم تنظيم بيانات الصورة بشكل داخلي ، والتي يمكن أن تكون مفيدةوظائف معالجة الصور أو تحويل النماذج.
public override PixelDataFormat RawDataFormat { get; }
قيمة الممتلكات
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; }
قيمة الممتلكات
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; }
قيمة الممتلكات
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; }
قيمة الممتلكات
XmpData
الوصول أو تعديل البيانات المرتبطة منصة البيانات المتطورة (XMP)هذا الممتلكات يسهل استخراج أو تعديل أوإضافة البيانات الميتا، مما يتيح إدارة شاملة للمعلومات ذات الصلة بالصورة.
public override XmpPacketWrapper XmpData { get; set; }
قيمة الممتلكات
Methods
GetDefaultOptions(الموضوع[])
احصل على الخيارات الافتراضية.
public override ImageOptionsBase GetDefaultOptions(object[] args)
Parameters
args
object
[ ]
من الحجج .
Returns
الخيارات الافتراضية
GetModifyDate(بول)
إعادة تدوير علامة التوقيت التي تشير إلى أحدث تعديل للمواردهذه الطريقة توفر الوصول إلى البيانات الأساسية، مما يتيح التطبيقاتتأكد من أن الصورة قد تغيرت مؤخرا، مما يسهل متابعة النسخة وإدارة المحتوى .
public override DateTime GetModifyDate(bool useDefault)
Parameters
useDefault
bool
إذا قمت بتعيين “الحقيقة” تستخدم المعلومات من FileInfo كقيمة افتراضية.
Returns
تاريخ ووقت تم آخر تعديل لصورة المصدر.
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
الخيارات القائمة على إعدادات الملف الأصلي.
OnPaletteChanged(الألوان، الألوان، الألوان)
يتم استدعاءها عندما يتم تغيير اللوحة.
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(إنت، إنت)
وتحديث الأبعاد.
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
العرض الجديد .
newHeight
int
الارتفاع الجديد
UpdateMetadata()
تحديث الصورة تاريخ وأوقات آخر تعديل.
protected override void UpdateMetadata()