Class PngImage

Class PngImage

Der Name: Aspose.Imaging.FileFormats.Png Versammlung: Aspose.Imaging.dll (25.4.0)

Manipulieren Sie Portable Network Graphics (PNG) Raster Bilder mit unserer vielseitigen API,Unterstützung für Kompressionsniveaus und verschiedene Farbtiefen, einschließlichGrayscale, Indexed Color, TrueColor und Alpha-Kanäle verarbeiten XMP-Metadaten,umfassende Bildmetadatenmanagement zu ermöglichen, während PNG-Bilder leicht geladen werden,verschiedene Manipulationen durchführen, Filter anwenden und Bilder in andere Dateien umwandelnFormate für optimale Vielfalt und Anpassung.

[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

Vererbte Mitglieder

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

Dieses Beispiel zeigt, wie man ein PNG-Bild aus einem Datei laden kann.

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(und int, int)

Initialisieren Sie ein neues Objekt der Aspose.Imaging.FileFormats.Png.PngImage Klasse, indem Sie dieBreite und Höhe Parameter. Dieser Konstruktor vereinfacht die Erstellung von PNGBilder, die Entwickler ermöglichen, die Dimensionen direkt zu spezifizieren, erleichternEffiziente Verwaltung von PNG-Bilddaten innerhalb ihrer Anwendungen.

public PngImage(int width, int height)

Parameters

width int

Die Breite.

height int

Die Höhe.

Examples

Dieses Beispiel zeigt, wie Sie ein PNG-Bild der angegebenen Größe erstellen, es mit einer soliden Farbe füllen und in eine Datei speichern.

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)

Erstellen Sie eine neue Instanz der Aspose.Imaging.FileFormats.Png.PngImage Klasse mit dem WegParameter zur Angabe der Lage der Bilddatei zu laden. Dieser Konstruktorermöglicht es Entwicklern, PNG-Bilder bequem zu erstellen, indem sie aus einem Datei hochgeladen werden,Vereinfachung des Prozesses der Arbeit mit PNG-Bilder in ihren Anwendungen.

public PngImage(string path)

Parameters

path string

Der Weg, um ein Bild zu laden.

Examples

Dieses Beispiel zeigt, wie man ein PNG-Bild aus einem Datei laden kann.

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)

Erstellt eine neue Instanz der Aspose.Imaging.FileFormats.Png.PngImage Klasse, indem ein Raster bereitgestellt wirdBild als Parameter. Dieser Konstruktor ermöglicht den Entwicklern, direkt einePNG-Bildobjekt mit einem vorhandenen Raster-Bild, der den Prozess derArbeiten mit PNG-Bilder in ihren Anwendungen.

public PngImage(RasterImage rasterImage)

Parameters

rasterImage RasterImage

Das Raster Bild.

Examples

Dieses Beispiel zeigt, wie man PNG-Bild aus einem BMP-Bild laden kann.

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(String, PngColorType)

Initialisiert eine neue Instanz der Aspose.Imaging.FileFormats.Png.PngImage Klasse, indem dieWeg zum Bilddatei und zum Farbtyp. Dieser Konstruktor ermöglicht dieErstellung von PNG-Bilder aus Dateien mit verschiedenen Farbtypen, dieFlexibilität bei der Verarbeitung verschiedener Bildformate.

public PngImage(string path, PngColorType colorType)

Parameters

path string

Der Weg, um ein Bild zu laden.

colorType PngColorType

Der Farbtyp.

Examples

Dieses Beispiel zeigt, wie man ein PNG-Bild aus einem Datei mit dem angegebenen Farbtyp laden kann.

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(RasterImage, PngColorType)

Erstellt eine neue Instanz der Aspose.Imaging.FileFormats.Png.PngImage Klasse, indem eineRasterbild und eine Farbtyp. Dieser Konstruktor ermöglicht den Entwicklern, direktKonvertieren Sie Raster-Bilder in PNG-Format, während Sie den gewünschten Farbtyp angeben,Flexibilität in der Farbreprezentation.

public PngImage(RasterImage rasterImage, PngColorType colorType)

Parameters

rasterImage RasterImage

Das Raster Bild.

colorType PngColorType

Der Farbtyp.

Examples

Dieses Beispiel zeigt, wie man PNG-Bild aus einem BMP-Bild mit dem angegebenen Farbtyp laden kann.

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)

Erstellt eine neue Instanz der Aspose.Imaging.FileFormats.Png.PngImage Klasse, indem Sie sie initialisierenmit einem Strom. Dieser Konstruktor ermöglicht Entwicklern, PNG Bilder direkt zu ladenvon einem Strom, die Flexibilität bei der Erfassung von Bildern aus verschiedenen Quellen bietet.

public PngImage(Stream stream)

Parameters

stream Stream

Der Strom, um ein Bild zu laden.

Examples

Dieses Beispiel zeigt, wie man ein PNG-Bild aus einem Datei oder einem Dateistrom laden kann.

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)

Instantieren Sie eine neue Instanz der Aspose.Imaging.FileFormats.Png.PngImage Klasse, diedie gewünschte Breite, Höhe und Farbtypparameter. Dieser Konstruktor ermöglichtschnelle Erstellung von PNG-Bilder mit angepassten Dimensionen und Farbkonfigurationen,Erleichterung der effizienten Bildgeneration für verschiedene Anwendungen und Workflows.

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

Parameters

width int

Die Breite.

height int

Die Höhe.

colorType PngColorType

Der Farbtyp.

Examples

Dieses Beispiel zeigt, wie Sie ein PNG-Bild der angegebenen Größe mit dem angegebenen Farbtyp erstellen, es mit einer soliden Farbe füllen und in eine Datei speichern.

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)

Initialisieren Sie eine neue Instanz der Aspose.Imaging.FileFormats.Png.PngImage Klasse, diePNG-Optionen neben Breite und Höhenparameter. Dieser Konstruktor ermöglichtEntwickler, um PNG-Bilder mit anpassbaren Einstellungen und Dimensionen zu erstellen,Flexibilität in der Bildgeneration für verschiedene Anwendungsfälle.

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

Parameters

pngOptions PngOptions

Die PNG Optionen.

width int

Die Breite.

height int

Die Höhe.

Examples

Dieses Beispiel zeigt, wie Sie ein PNG-Bild mit den angegebenen Optionen erstellen, es mit einer linearen Gradientfarbe füllen und in eine Datei speichern.

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

Wiederherstellt die Hintergrundfarbe des Bildes, wenn eine angegeben ist.hilfreich für Anwendungen, die identifizieren und potenziell manipulieren müssenDie Hintergrundfarbe eines Bildes.

public override Color BackgroundColor { get; set; }

Eigentumswert

Color

Examples

Das folgende Beispiel zeigt, wie man voll transparente Farben für einen Teil eines TrueColor PNG-Bildes festlegt, das kein Alpha-Kanal unterstützt.

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

Wiederherstellen Sie die Bits pro Pixelwert für das Bild. Diese Eigenschaft bietet entscheidendeInformationen über die Farbtiefe des Bildes, die Entwicklern ermöglichen,das Niveau der Details und der Farbenauigkeit, die in den Bilddaten vorhanden ist.

public override int BitsPerPixel { get; }

Eigentumswert

int

FileFormat

Wiederherstellt das Format der Datei, die mit der Bildinstanz verbunden ist.Eigentum bietet wesentliche Informationen über den Dateityp, dieEffiziente Handhabung und Verarbeitung basierend auf den spezifischen Formatanforderungen.

public override FileFormat FileFormat { get; }

Eigentumswert

FileFormat

HasAlpha

Wiederherstellt einen Booleanwert, der darauf hindeutet, ob das Bild einen Alpha-Kanal hat,die ihre Transparenz bestimmen. Diese Eigenschaft ist nützlich für Anwendungendie Transparenz zu bewältigen, damit Entwickler bestimmen können, obEine zusätzliche Verarbeitung ist erforderlich, um transparente Bereiche im Bild zu behandeln.

public override bool HasAlpha { get; }

Eigentumswert

bool

Examples

Das folgende Beispiel zeigt, wie man prüft, ob ein PNG-Bild Alpha-Kanal unterstützt.

// 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

Retriebe einen Booleanwert, der angibt, ob das Bild eine Hintergrundfarbe hat.Diese Eigenschaft ist nützlich für Anwendungen, die feststellen müssen, ob ein Bildenthält eine Hintergrundfarbe, die für verschiedene Verarbeitung wichtig sein kannAufgaben wie Komposition, Rendering oder Export.

public override bool HasBackgroundColor { get; set; }

Eigentumswert

bool

Examples

Das folgende Beispiel zeigt, wie man voll transparente Farben für einen Teil eines TrueColor PNG-Bildes festlegt, das kein Alpha-Kanal unterstützt.

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

Bereitzt ein Booleanwert, mit dem angezeigt wird, ob das Bild einen transparentenFarbe. Diese Eigenschaft ist entscheidend für Anwendungen, die zu handhabenTransparenz, die Entwicklern erlaubt, festzustellen, ob zusätzliche Verarbeitungerforderlich, um transparente Regionen im Bild zu behandeln.

public override bool HasTransparentColor { get; set; }

Eigentumswert

bool

Examples

Das folgende Beispiel zeigt, wie man voll transparente Farben für einen Teil eines TrueColor PNG-Bildes festlegt, das kein Alpha-Kanal unterstützt.

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

Erhalten Sie die Höhe des Bildes. Diese Eigenschaft kehrt die vertikale Dimension derDas Bild ermöglicht es den Entwicklern, seine Größe in Pixeln entlang derDer vertikale Axe.

public override int Height { get; }

Eigentumswert

int

HorizontalResolution

Wiederherstellen oder ändern Sie die horizontale Auflösung des Bildes.repräsentiert die Anzahl von Pixeln pro Zoll entlang der horizontalen Achse desAnpassung dieser Auflösung kann die physische Größe des Bildes beeinflussen, wenngedruckt oder angezeigt.

public override double HorizontalResolution { get; set; }

Eigentumswert

double

Examples

Das folgende Beispiel zeigt, wie man eine horizontale/vertikale Auflösung eines PNG-Bildes festlegt.

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

Retriebe einen Booleanwert, der angibt, ob die Aspose.Imaging.FileFormats.Png.PngImage istinterlaced, die bestimmt, ob die Bilddaten in einer progressivenSchnellere Ladung oder Übertragung.

public bool Interlaced { get; }

Eigentumswert

bool

IsInterlaced

Ersetzt einen Booleanwert, der angibt, ob die Bildinstanz vernetzt ist.Eigentum ist entscheidend für die Optimierung von Ladestrategien und die Gewährleistung von EffizienzLeistung während Bildverarbeitung oder Anzeigen Aufgaben.

public bool IsInterlaced { get; }

Eigentumswert

bool

RawDataFormat

Zugriff auf das Rohdatenformat des Bildes. Diese Eigenschaft bietet Einblicke inwie die Bilddaten intern strukturiert werden, was nützlich für fortgeschritteneBildverarbeitung Aufgaben oder Formatkonvertierung.

public override PixelDataFormat RawDataFormat { get; }

Eigentumswert

PixelDataFormat

Examples

Das folgende Beispiel laden PNG-Bilder auf und drucken Informationen über Rohdatenformat und Alpha-Kanal.

// 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

Retriebe die transparente Farbe des Bildes, wenn es vorhanden ist.wertvoll für Anwendungen, die eine genaue Verwaltung transparenter Gebiete erforderninnerhalb von Bildern, die Entwicklern erlaubt, die spezifischenTransparente Farben verwendet.

public override Color TransparentColor { get; set; }

Eigentumswert

Color

Examples

Das folgende Beispiel zeigt, wie man voll transparente Farben für einen Teil eines TrueColor PNG-Bildes festlegt, das kein Alpha-Kanal unterstützt.

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

Erlaubt Zugriff auf die vertikale Auflösung des Bildes.Entwickler könnendieses Eigentum, um die Entschließung zu erlangen oder zu ändern, die dieAnzahl von Pixeln pro Zoll (PPI) entlang der vertikalen Achse des Bildes.

public override double VerticalResolution { get; set; }

Eigentumswert

double

Examples

Das folgende Beispiel zeigt, wie man eine horizontale/vertikale Auflösung eines PNG-Bildes festlegt.

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

Erlaubt die Wiederholung der Breite des Bildes und bietet wesentliche Informationenüber seine Dimensionen. Diese Eigenschaft wird häufig von Entwicklern verwendetdie Breite des Bildes bestimmen, wodurch sie verschiedene Operationen durchführen könnenauf seiner Größe

public override int Width { get; }

Eigentumswert

int

XmpData

Zugriff oder Änderung der erweiterbaren Metadata-Plattform (XMP)mit dem Bild. Dieses Eigentum erleichtert die Extraktion, Änderung oderZusatz von Metadaten, die eine umfassende Verwaltung von Bild-bezogenen Informationen ermöglicht.

public override XmpPacketWrapper XmpData { get; set; }

Eigentumswert

XmpPacketWrapper

Methods

GetDefaultOptions(Objekt[])

Erhalten Sie die Standardoptionen.

public override ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object [][]

Die Argumente.

Returns

ImageOptionsBase

Default Optionen

GetModifyDate(Bool)

Retriebe den Zeitraum, der die neueste Änderung der Ressource angibtDiese Methode bietet Zugang zu lebenswichtigen Metadaten, die Anwendungen ermöglichen, umzu überprüfen, wann das Bild zuletzt geändert wurde, die Versionverfolgung undInhaltsverwaltung.

public override DateTime GetModifyDate(bool useDefault)

Parameters

useDefault bool

Wenn Sie auf ’true’ eingestellt sind, verwenden Sie die Informationen aus FileInfo als Standardwert.

Returns

DateTime

Das Datum und die Uhrzeit des Ressourcenbildes wurde zuletzt geändert.

GetOriginalOptions()

Erhalten Sie die Optionen auf der Grundlage der ursprünglichen Datei-Einstellungen.Dies kann hilfreich sein, Bit-Dichte und andere Parameter des ursprünglichen Bildes unverändert zu halten.Zum Beispiel, wenn wir ein schwarz-weißes PNG-Bild mit 1 Bit pro Pixel laden und es dann mit derAspose.Imaging.DataStreamSupporter.Save(System.String) Methode, wird das Ausgang PNG Bild mit 8-Bit pro Pixel produziert.Um es zu vermeiden und PNG-Bild mit 1 Bit pro Pixel zu speichern, verwenden Sie diese Methode, um die entsprechenden Speicheroptionen zu erhalten und sie durchzuführen.auf die Aspose.Imaging.Image.Save(System.String,Aspose.Imaging.ImageOptionsBase) Methode als den zweiten Parameter.

public override ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

Die Optionen basieren auf den ursprünglichen Dateiinstellungen.

OnPaletteChanged(IColorPalette und IColorPalette)

Anrufen, wenn die Palette geändert wird.

protected override void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette

Die alte Palette.

newPalette IColorPalette

Die neue Palette.

SaveData(Stream)

Die Speicherung der Daten.

protected override void SaveData(Stream stream)

Parameters

stream Stream

Der Strom.

UpdateDimensions(und int, int)

Aktualisierung der Dimensionen.

protected override void UpdateDimensions(int newWidth, int newHeight)

Parameters

newWidth int

Die neue Breite.

newHeight int

Die neue Höhe.

UpdateMetadata()

Aktualisieren Sie das Bild zum letzten Zeitpunkt und Datum der Änderung.

protected override void UpdateMetadata()
 Deutsch