Class PngImage

Class PngImage

Именује се: Aspose.Imaging.FileFormats.Png Асамблеја: Aspose.Imaging.dll (25.4.0)

Манипулишете преносиве мрежне графике (ПНГ) растер слике са нашим свеобухватним АПИ-ом,са подршком за ниво компресије и различите боје дубине укључујућиGrayscale, Indexed Color, TrueColor, i alfa kanali. bezbedno obrađuje XMP metapodatke,омогућавање свеобухватног управљања метаданима слике, а истовремено лако пуњење ПНГ слика,спровођење различитих манипулација, примјена филтера и конверзија слика у друге датотекеформати за оптималну универзалност и прилагођавање.

[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

Овај пример показује како да преузмете ПНГ слику из датотеке.

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 пружајућиширине и висине параметара. Овај конструктор олакшава стварање ПНГслике омогућавајући програмерима да директно одређују димензије, олакшавајућиЕфикасно управљање ПНГ сличним подацима у њиховим апликацијама.

public PngImage(int width, int height)

Parameters

width int

То је ширина.

height int

То је висина.

Examples

Овај пример показује како да креирате ПНГ слику одређене величине, попуните је чврстом бојом и сачувате га у датотеку.

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(Стринг)

Изграђује нову инстанцију класе ВЛ17.ФилеФорматис.Пнг. ПнгИмаге користећи путпараметар за одређивање локације датотеке слике за преузимање. овај конструкторомогућава програмерима да удобно креирају ПНГ слике преузимањем из датотеке,Поједностављање процеса рада са ПНГ сликама у њиховим апликацијама.

public PngImage(string path)

Parameters

path string

Пут за преузимање слике.

Examples

Овај пример показује како да преузмете ПНГ слику из датотеке.

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)

Креира нову инстанцију класе ВЛ17.ФилеФорматис.Пнг.PngИмаге пружајући растерслика као параметар. овај конструктор омогућава програмерима да директно иницијализујуПНГ слике објекат користећи постојећу растер слику, усклађивање процесаради са ПНГ сликама у њиховим апликацијама.

public PngImage(RasterImage rasterImage)

Parameters

rasterImage RasterImage

На слици растер.

Examples

Овај пример показује како да преузмете ПНГ слику из БМП слике.

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)

Иницијалише нову инстанцију класе ВЛ17.ФилеФорматис.Пнг.PngИмаге одређујућипут до слике датотеке и типа боје. Овај конструктор омогућавакреирање ПНГ слике из датотека различитих типова боја, пружајућиФлексибилност у управљању различитим форматима слике.

public PngImage(string path, PngColorType colorType)

Parameters

path string

Пут за преузимање слике.

colorType PngColorType

Тип боје .

Examples

Овај пример показује како да преузмете ПНГ слику из датотеке са одређеним типом боје.

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(РастерИмаге, ПнгЦолорТип)

Креира нову инстанцију класе ВЛ17.ФилеФорматис.Пнг.PngИмаге одређујућирастер слика и тип боје. Овај конструктор омогућава програмерима да директноконвертује слике растер у ПНГ формат док одређује жељен тип боје,пружају флексибилност у боји представљања.

public PngImage(RasterImage rasterImage, PngColorType colorType)

Parameters

rasterImage RasterImage

На слици растер.

colorType PngColorType

Тип боје .

Examples

Овај пример показује како да преузмете ПНГ слику из БМП слике са одређеним типом боје.

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)

Креира нову инстанцију класе ВЛ17.ФилеФорматис.Пнг. ПнгИмаге иницијалишући гаОвај конструктор омогућава програмерима да директно преузимају ПНГ сликеод једног тока, пружајући флексибилност у прикупљању слике из различитих извора.

public PngImage(Stream stream)

Parameters

stream Stream

Поток за преузимање слике.

Examples

Овај пример показује како да преузмете ПНГ слику из датотеке или протока.

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

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

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

PngImage(int, int и PngColorType)

Инсталирајте свежу инстанцију класе Aspose.Imaging.FileFormats.Png.pngImage, одређујућижељене ширине, висине и параметара типа боје.Овај конструктор омогућавабрзо стварање ПНГ слика са прилагођеним димензијама и конфигурацијама боја,олакшање усклађене генерације слике за различите апликације и радне токове.

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

Parameters

width int

То је ширина.

height int

То је висина.

colorType PngColorType

Тип боје .

Examples

Овај пример показује како да креирате ПНГ слику одређене величине уз одређени тип боје, попуните је чврстом бојом и сачувате га у датотеку.

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(Пнгопције, инт, Инт)

Иницијалишете нову инстанцију класе ВЛ17.ФилеФорматис.Пнг. ПнгИмаге, укључујућиОпције ПНГ заједно са параметрима ширине и висине. Овај конструктор омогућавапрограмери да креирају ПНГ слике са прилагодљивим подешавањама и димензијама,пружају флексибилност у генерацији слике за различите употребе случајева.

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

Parameters

pngOptions PngOptions

Опције ПНГ опције.

width int

То је ширина.

height int

То је висина.

Examples

Овај пример показује како да креирате ПНГ слику са одређеним опцијама, попуните је линеарним градијентним бојама и сачувате га у датотеку.

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

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

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

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

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

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

                                                                                                                                                // Use progressive loading
                                                                                                                                                createOptions.Progressive = true;

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

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

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

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

Properties

BackgroundColor

Враћа боју позадине слике, ако је један одређен.корисно за апликације које морају идентификовати и потенцијално манипулисатибоја позадине слике.

public override Color BackgroundColor { get; set; }

Вредност имовине

Color

Examples

Следећи пример показује како поставити потпуно транспарентне боје за део слике TrueColor PNG који не подржава алфа канал.

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

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

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

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

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

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

                                                                                                                                                       pngImage.Save();
                                                                                                                                                   }

BitsPerPixel

Повратак бита по пикселу вредност за слику. Ова својства пружа кључнеинформације о боји дубине слике, омогућавајући програмерима даразумевање нивоа детаља и тачности боје присутни у подацима слике.

public override int BitsPerPixel { get; }

Вредност имовине

int

FileFormat

Враћа формат датотеке повезан са сликом. овоимовина пружа важне информације у вези са типом датотеке, омогућавајућиЕфикасно управљање и обрада на основу специфичних захтева за формат.

public override FileFormat FileFormat { get; }

Вредност имовине

FileFormat

HasAlpha

Враћа булеанску вредност која указује на то да ли слика има алфа канал,који одређује његову транспарентност. Ова имовина је корисна за апликацијето треба да се бави транспаренцијом, омогућавајући програмерима да утврде да лиДодатна обрада је потребна за управљање транспарентним подручјима у слици.

public override bool HasAlpha { get; }

Вредност имовине

bool

Examples

Следећи пример показује како проверити да ли ПНГ слика подржава алфа канал.

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

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

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

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

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

HasBackgroundColor

Ретретира булеанску вредност која указује на то да ли слика има боју позадине.Ова имовина је корисна за апликације које морају да утврде да ли је сликаукључује боју позадине, која може бити важна за различите обрадеЗадаци као што су композиција, рендеринг или извоз.

public override bool HasBackgroundColor { get; set; }

Вредност имовине

bool

Examples

Следећи пример показује како поставити потпуно транспарентне боје за део слике TrueColor PNG који не подржава алфа канал.

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

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

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

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

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

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

                                                                                                                                                       pngImage.Save();
                                                                                                                                                   }

HasTransparentColor

Обезбеђује булеанску вредност која указује на то да ли слика садржи транспарентнубоја. Ова имовина је од суштинског значаја за апликације које морају да се баветранспарентност, омогућавајући програмерима да утврде да ли је додатна обрадаПотребно је да се баве транспарентним регионима у слици.

public override bool HasTransparentColor { get; set; }

Вредност имовине

bool

Examples

Следећи пример показује како поставити потпуно транспарентне боје за део слике TrueColor PNG који не подржава алфа канал.

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

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

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

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

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

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

                                                                                                                                                       pngImage.Save();
                                                                                                                                                   }

Height

Добијте висину слике. Ова имовина враћа вертикалну димензијуслика, омогућавајући програмерима да утврде његову величину у пикселима дужВертикална оса

public override int Height { get; }

Вредност имовине

int

HorizontalResolution

Повратак или модификовање хоризонталне резолуције слике.представља број пиксела по инчу дуж хоризонталне осиПрилагођавање ове резолуције може утицати на физичку величину слике кадаПринтирани или приказивани.

public override double HorizontalResolution { get; set; }

Вредност имовине

double

Examples

Следећи пример показује како подесити хоризонталну/вертикалну резолуцију ПНГ слике.

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

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

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

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

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

Interlaced

Враћа булеанску вредност која указује на то да ли је Aspose.Imaging.FileFormats.Png.pngImageинтерлакирани, који одређује да ли се подаци слике чувају у прогресивномначин за брже пуњење или пренос.

public bool Interlaced { get; }

Вредност имовине

bool

IsInterlaced

Враћа булеанску вредност која указује на то да ли је инстанција слике повезана.имовина је од суштинског значаја за оптимизацију стратегија оптерећења и обезбеђивање ефикасногперформансе током обраде слике или приказивања задатака.

public bool IsInterlaced { get; }

Вредност имовине

bool

RawDataFormat

Доступно је формат сирових података слике.Ова имовина пружа увид уКако се подаци слике структурирају унутра, што може бити корисно за напреднеЗадаци обраде слике или конверзије формата.

public override PixelDataFormat RawDataFormat { get; }

Вредност имовине

PixelDataFormat

Examples

Следећи пример преузима ПНГ слике и штампа информације о формату сирових података и алфа каналу.

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

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

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

TransparentColor

Повлачи транспарентну боју слике, ако постоји.вредно за апликације које захтевају прецизно управљање транспарентним подручјимаунутар слика, омогућавајући програмерима да приступе и манипулишу специфичнимКоришћена транспарентна боја.

public override Color TransparentColor { get; set; }

Вредност имовине

Color

Examples

Следећи пример показује како поставити потпуно транспарентне боје за део слике TrueColor PNG који не подржава алфа канал.

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

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

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

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

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

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

                                                                                                                                                       pngImage.Save();
                                                                                                                                                   }

VerticalResolution

Обезбеђује приступ вертикалној резолуцији слике. програмери могу користитиовај имовина да преузме или промени подешавање резолуције, што указује наБрој пиксела по инчу (ППИ) дуж вертикалне оси слике.

public override double VerticalResolution { get; set; }

Вредност имовине

double

Examples

Следећи пример показује како подесити хоризонталну/вертикалну резолуцију ПНГ слике.

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

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

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

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

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

Width

Омогућава повраћање ширине слике, пружајући неопходне информацијео његовим димензијама. ова имовина се често користи од стране програмера заодређивање ширине слике, омогућавајући им да обављају различите операције засноване наНа својој величини

public override int Width { get; }

Вредност имовине

int

XmpData

Приступа или модификује проширене метадане платформе (XMP)Ова имовина олакшава извлачење, модификацију, илидодавање метадата, омогућавајући свеобухватно управљање информацијама везаним за слику.

public override XmpPacketWrapper XmpData { get; set; }

Вредност имовине

XmpPacketWrapper

Methods

GetDefaultOptions(Објекат[])

Покушајте да добијете дефолт опције.

public override ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object []

i argumentima .

Returns

ImageOptionsBase

Default opcije

GetModifyDate(Боол)

Повратак временског знака који указује на најновију модификацију ресурсаОвај метод пружа приступ виталним метаданима, омогућавајући апликацијама даутврдити када је слика последње промењена, олакшавајући праћење верзије иУправљање садржајем.

public override DateTime GetModifyDate(bool useDefault)

Parameters

useDefault bool

ако је постављен на “истину”, користите информације из FileInfo као подразумевану вредност.

Returns

DateTime

Датум и време слике ресурса је последњи пут модификован.

GetOriginalOptions()

Добија опције засноване на оригиналним подешавањама датотеке.Ово може бити корисно за одржавање детаљне дубине и других параметара оригиналне слике непромењене.На пример, ако наплаћујемо црно-белу ПНГ слику са 1 битом по пикселу, а затим га сачувате користећиAspose.Imaging.DataStreamSupporter.Save(System.String) метода, излазна ПНГ слика са 8 бита по пикселу ће бити произведена.Да бисте то избегли и сачували ПНГ слику са 1 битом по пикселу, користите ову методу да бисте добили одговарајуће опције за штедњу и прошли их.до метода Aspose.Imaging.Image.Save(System.String,_Wl17.ImageOptionsBase) као други параметар.

public override ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

Опције засноване на оригиналним поставкама датотеке.

OnPaletteChanged(ИЦОЛОРПАЛЕТ, ИЦОЛОРПАЛЕТ)

Позива се када се палет мења.

protected override void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette

Стари палети.

newPalette IColorPalette

Нова палета је.

SaveData(Stream)

Sačuvajte podatke .

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()
 Српски