Class PngImage
İsim alanı : Aspose.Imaging.FileFormats.Png Toplantı: Aspose.Imaging.dll (25.4.0)
Portable Network Graphics (PNG) raster görüntüleri çeşitli API’lerimizle manipüle edin,kompresyon seviyeleri ve çeşitli renk derinlikleri için destek sağlar,Grayscale, Indexed Color, TrueColor ve alfa kanalları.kapsamlı görüntü metadata yönetimi sağlarken, PNG görüntüleri kolayca yüklenirken,Çeşitli manipülasyonları gerçekleştirmek, filtreleri uygulamak ve resimleri diğer dosyalara dönüştürmekOptimal çeşitlilik ve özelleştirme için formatlar.
[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
mirasçı üyeleri
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
Bu örnek, bir dosyadan bir PNG görüntüsünü nasıl yükleyeceğinizi gösterir.
string dir = "c:\\temp\\";
// Load a PNG image from a file.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(dir + "sample.png"))
{
// Transform the image to grayscale representation
pngImage.Grayscale();
// Save to a file.
pngImage.Save(dir + "sample.grayscale.png");
}
Constructors
PngImage(int , int , int)
Aspose.Imaging.FileFormats.Png.PngImage sınıfının yeni bir nesnesini başlatıngenişlik ve yükseklik parametreleri. bu yapımcı PNG oluşturmayı kolaylaştırırGörüntüleri geliştiricilerin boyutları doğrudan belirlemelerine izin vererek, kolaylaştırarakUygulamalarında PNG görüntü verilerinin verimli bir şekilde yönetilmesi.
public PngImage(int width, int height)
Parameters
width
int
Genişlik için.
height
int
Yükseklik için.
Examples
Bu örnek, belirtilen boyutlu bir PNG görüntüsü nasıl oluşturulur, sağlam bir renkle doldurulur ve bir dosyaya kaydedilir.
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(Sırt)
Aspose.Imaging.FileFormats.Png.PngImage sınıfını kullanarak yeni bir örnek oluştururparametre yüklemek için görüntü dosyasının konumunu belirlemek için. bu yapılandırıcıGeliştiricilerin PNG görüntüleri bir dosyadan yükleyerek kolayca oluşturmalarını sağlar,Uygulamalarında PNG görüntüleri ile çalışma sürecini basitleştirmek.
public PngImage(string path)
Parameters
path
string
Bir resim yüklemek için yol.
Examples
Bu örnek, bir dosyadan bir PNG görüntüsünü nasıl yükleyeceğinizi gösterir.
string dir = "c:\\temp\\";
// Load a PNG image from a file.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(dir + "sample.png"))
{
// Transform the image to grayscale representation
pngImage.Grayscale();
// Save to a file.
pngImage.Save(dir + "sample.grayscale.png");
}
PngImage(RasterImage)
Aspose.Imaging.FileFormats.Png.PngImage sınıfının yeni bir örneği oluştururBu yapılandırıcı, geliştiricilerin doğrudan bir parametre başlatmalarını sağlar.PNG görüntü nesnesi, mevcut bir raster görüntüsünü kullanarak,Uygulamalarında PNG görüntüleri ile çalışın.
public PngImage(RasterImage rasterImage)
Parameters
rasterImage
RasterImage
Raster Görüntüleri
Examples
Bu örnek, bir BMP görüntüsünden PNG görüntüsünü nasıl yüklediğini gösterir.
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(Çerçeve, PngColorType)
Aspose.Imaging.FileFormats.Png.PngImage sınıfını belirleyerek yeni bir örnek başlatır.resim dosyasına ve renk tipi yol. bu yapımcı uygunFarklı renk türleri olan dosyadan PNG görüntüleri oluşturmak,Çeşitli görüntü biçimlerini yönetmek için esneklik.
public PngImage(string path, PngColorType colorType)
Parameters
path
string
Bir resim yüklemek için yol.
colorType
PngColorType
Renk türü vardır.
Examples
Bu örnek, belirlenen renk türü ile bir dosyadan bir PNG görüntüsünü nasıl yükleneceğini gösterir.
string dir = "c:\\temp\\";
// Load a PNG image from a file.
// Note that the colorful image will be converted to grayscale automatically.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(dir + "sample.png", Aspose.Imaging.FileFormats.Png.PngColorType.Grayscale))
{
// Save to a file.
pngImage.Save(dir + "sample.grayscale.png");
}
Exceptions
PngImage(RasterImage ve PngColorType)
Aspose.Imaging.FileFormats.Png.PngImage sınıfının yeni bir örneği oluşturur.raster görüntü ve bir renk tipi. bu yapımcı geliştiricilerin doğrudanRaster görüntüleri PNG formatına dönüştürürken istenen renk türünü belirlerken,Renk temsilciliğinde esneklik sağlar.
public PngImage(RasterImage rasterImage, PngColorType colorType)
Parameters
rasterImage
RasterImage
Raster Görüntüleri
colorType
PngColorType
Renk türü vardır.
Examples
Bu örnek, belirlenen renk tipi ile bir BMP görüntüsünden PNG görüntüsünü nasıl yüklediğinizi gösterir.
string dir = "c:\\temp\\";
// Load a grayscale PNG image from a colored BMP image.
// First, create a temporal BMP image that will be a foundation for building a PNG image.
// You can also load BMP image from a file or use an image of any other raster format.
using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100))
{
// Fill the entire BMP image in red.
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(bmpImage);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
gr.FillRectangle(brush, bmpImage.Bounds);
// The colors of the image pixels will be converted to their grayscale counterparts.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(bmpImage, Aspose.Imaging.FileFormats.Png.PngColorType.Grayscale))
{
pngImage.Save(dir + "output.grayscale.png");
}
}
PngImage(Stream)
Aspose.Imaging.FileFormats.Png.PngImage sınıfını başlatarak yeni bir örnek oluştururBu yapımcı geliştiricilerin doğrudan PNG görüntüleri yüklemelerini sağlarBir akımdan, farklı kaynaklardan görüntü alımında esneklik sağlar.
public PngImage(Stream stream)
Parameters
stream
Stream
Bir görüntü yüklemek için akış.
Examples
Bu örnek, bir dosyadan veya bir dosya akışından bir PNG görüntüsünü nasıl yüklediğinizi gösterir.
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 sınıfının yeni bir örneğini başlatın.arzu edilen genişlik, yükseklik ve renk tipi parametreleri. bu yapımcıHızlı PNG görüntüleri, özelleştirilmiş boyutlar ve renk konfigürasyonları ile oluşturmak,Çeşitli uygulamalar ve çalışma akışları için akıllı görüntü üretimi kolaylaştırmak.
public PngImage(int width, int height, PngColorType colorType)
Parameters
width
int
Genişlik için.
height
int
Yükseklik için.
colorType
PngColorType
Renk türü vardır.
Examples
Bu örnek, belirli renk tipi ile belirli boyutlu bir PNG görüntüsü nasıl oluşturulur, sağlam bir renkle doldurulur ve bir dosyaya kaydedilir.
string dir = "c:\\temp\\";
// Create a grayscale PNG image of 100x100 px.
// All colors will be automatically converted to the grayscale format.
using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100, Aspose.Imaging.FileFormats.Png.PngColorType.Grayscale))
{
// Do some image processing, e.g. fill the entire image in red.
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
graphics.FillRectangle(brush, pngImage.Bounds);
// Save to a file.
pngImage.Save(dir + "output.grayscale.png");
}
PngImage(PngOptions , int , int)
Aspose.Imaging.FileFormats.Png.PngImage sınıfının yeni bir örneğini başlatın.PNG seçenekleri genişlik ve yükseklik parametreleri ile birlikte. bu yapımcı güçlendirirGeliştiriciler özelleştirilebilir ayarları ve boyutları ile PNG görüntüleri oluşturmak,Çeşitli kullanım durumları için görüntü üretiminde esneklik sağlar.
public PngImage(PngOptions pngOptions, int width, int height)
Parameters
pngOptions
PngOptions
PNG seçenekleri
width
int
Genişlik için.
height
int
Yükseklik için.
Examples
Bu örnek, belirtilen seçeneklerle bir PNG görüntüsü nasıl oluşturulacağını, lineer bir gradient rengi ile doldurulacağını ve bir dosyaya kaydedileceğini gösterir.
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
Görüntünün arka plan rengini geri getirir, eğer belirlenmişse.potansiyel olarak tanımlanması ve manipüle edilmesi gereken uygulamalar için yararlıdır.Bir resmin arka plan rengi.
public override Color BackgroundColor { get; set; }
Mülkiyet Değer
Examples
Aşağıdaki örnek, alfa kanalını desteklemeyen TrueColor PNG görüntüsünün bir kısmı için tamamen şeffaf renkler nasıl ayarlandığını gösterir.
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
Görüntü için piksel değerine göre bitleri geri getirin.Bu özellik önemliGörüntünün renk derinliği ile ilgili bilgi, geliştiricilerinGörüntü verilerinde bulunan ayrıntı ve renk doğruluğu seviyesini anlamak.
public override int BitsPerPixel { get; }
Mülkiyet Değer
FileFormat
Görüntü örneği ile ilişkili dosya biçimini geri dönüştürür.Mülkiyet dosya türü ile ilgili önemli bilgileri sağlar,Özel format gereksinimlerine dayalı verimli işleme ve işleme.
public override FileFormat FileFormat { get; }
Mülkiyet Değer
HasAlpha
Boolean değeri, resmin bir alfa kanalı olup olmadığını gösterir.Şeffaflığı belirleyen.Bu mülk uygulamalar için yararlıdırGeliştiricilerin şeffaflık yapmalarını sağlamak, geliştiricilerin şeffaflık yapmalarını sağlamak,Görüntüde şeffaf alanlarla uğraşmak için ek işleme ihtiyaç vardır.
public override bool HasAlpha { get; }
Mülkiyet Değer
Examples
Aşağıdaki örnek, bir PNG görüntüsünün alfa kanalı desteklediğini nasıl kontrol edeceğini gösterir.
// 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
Boolean değeri, resmin bir arka plan rengi olup olmadığını gösterir.Bu özellik, bir görüntü olup olmadığını belirlemesi gereken uygulamalar için yararlıdır.Bir arka plan rengi içerir, bu da çeşitli işlemler için önemli olabilir.Kompozisyon, render veya ihracat gibi görevler.
public override bool HasBackgroundColor { get; set; }
Mülkiyet Değer
Examples
Aşağıdaki örnek, alfa kanalını desteklemeyen TrueColor PNG görüntüsünün bir kısmı için tamamen şeffaf renkler nasıl ayarlandığını gösterir.
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
Boolean değeri, resmin şeffaf bir içeriği olup olmadığını gösterir.renk. bu mülk, işleme ihtiyacı olan uygulamalar için çok önemlidirGeliştiricilerin daha fazla işleme sahip olup olmadıklarını belirlemeleri için şeffaflık sağlar.Görüntüde şeffaf bölgelerle uğraşmak gerekir.
public override bool HasTransparentColor { get; set; }
Mülkiyet Değer
Examples
Aşağıdaki örnek, alfa kanalını desteklemeyen TrueColor PNG görüntüsünün bir kısmı için tamamen şeffaf renkler nasıl ayarlandığını gösterir.
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
Görüntünün yüksekliğini elde edin.Bu özellik, vertikal boyutunu geri getirirGörüntü, geliştiricilerin boyutunu piksel olarak belirlemesine olanak tanır.Vertikal eksenler
public override int Height { get; }
Mülkiyet Değer
HorizontalResolution
Görüntünün yatay çözünürlüğünü geri getirmek veya değiştirmek.Bu özellikpiksel sayısını inç başına yatay eksen boyunca temsil eder.Bu çözünürlüğün ayarlanması görüntünün fiziksel boyutunu etkileyebilir.Yazdırılmış veya gösterilmiştir.
public override double HorizontalResolution { get; set; }
Mülkiyet Değer
Examples
Aşağıdaki örnek, bir PNG görüntüsünün yatay/vertikal çözünürlüğünü nasıl ayarlayacağınızı gösterir.
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 olup olmadığını gösteren bir boolean değeri geri getiririnterlaced, görüntü verilerinin ileri düzeyde kaydedildiğini belirler.Daha hızlı yükleme veya aktarma yöntemleri.
public bool Interlaced { get; }
Mülkiyet Değer
IsInterlaced
Boolean değeri, görüntü örneğinin birbirine bağlandığını gösterir.Mülkiyet, yük stratejilerini optimize etmek ve verimliliği sağlamak için çok önemlidir.Görüntü işleme veya görüntüleme görevleri sırasında performans.
public bool IsInterlaced { get; }
Mülkiyet Değer
RawDataFormat
Görüntünün temel veri biçimine erişimi sağlar.Bu özellikGörüntü verilerinin nasıl içsel olarak yapılandırıldığını, bu gelişmiş için yararlı olabilirGörüntü işleme veya format dönüştürme görevleri.
public override PixelDataFormat RawDataFormat { get; }
Mülkiyet Değer
Examples
Aşağıdaki örnek PNG görüntüleri yükler ve hammadde veri biçimi ve alfa kanalı hakkında bilgi yazdırır.
// 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
Görüntünün şeffaf rengi geri çekilir, eğer var ise.Şeffaf alanların doğru bir şekilde işlenmesini gerektiren uygulamalar için değerliGörüntüler içinde, geliştiricilerin erişmesine ve belirli özellikleri manipüle etmesine olanak tanır.Kullanılan renkler şeffaf.
public override Color TransparentColor { get; set; }
Mülkiyet Değer
Examples
Aşağıdaki örnek, alfa kanalını desteklemeyen TrueColor PNG görüntüsünün bir kısmı için tamamen şeffaf renkler nasıl ayarlandığını gösterir.
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
Görüntü vertikal çözünürlüğüne erişim sağlar. geliştiriciler kullanabilirbu mülkiyeti geri almak veya çözünürlüğün ayarını değiştirmek için,Görüntünün dikey ekseni boyunca inç başına piksel sayısı (PPI).
public override double VerticalResolution { get; set; }
Mülkiyet Değer
Examples
Aşağıdaki örnek, bir PNG görüntüsünün yatay/vertikal çözünürlüğünü nasıl ayarlayacağınızı gösterir.
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
Görüntü genişliğinin geri çekilmesini sağlar, gerekli bilgileri sağlarÇoğu zaman, bu özellikler geliştiriciler tarafından kullanılır.Görüntü genişliğini belirlemek, çeşitli işlemleri gerçekleştirmelerini sağlar.büyüklüğünde
public override int Width { get; }
Mülkiyet Değer
XmpData
Genişletilebilir Metadata Platformu (XMP) ile ilişkili metadata erişimi veya değiştirmeBu mülk, çıkarılmasını, değiştirilmesini veyaMetadata ekleme, görüntü ile ilgili bilgi kapsamlı yönetimi sağlar.
public override XmpPacketWrapper XmpData { get; set; }
Mülkiyet Değer
Methods
GetDefaultOptions(nesne[])
Default seçenekleri alınır.
public override ImageOptionsBase GetDefaultOptions(object[] args)
Parameters
args
object
[…]
ve argümanları.
Returns
Default seçenekleri
GetModifyDate(bool)
Kaynakların en son değiştirilmesini gösteren zaman çizgisini geri getirirBu yöntem, önemli metadata erişimi sağlar ve uygulamalarıngörüntü son değiştirildiğinden emin olun, sürüm izlemeyi kolaylaştırın veİçerik Yönetimi .
public override DateTime GetModifyDate(bool useDefault)
Parameters
useDefault
bool
Eğer ‘gerçek’ olarak ayarlanırsa, FileInfo’dan gelen bilgileri varsayılan değer olarak kullanır.
Returns
Tarih ve zaman kaynak görüntüsü son değiştirildi.
GetOriginalOptions()
Orijinal dosya ayarlarına göre seçenekleri alır.Bu, bit derinliği ve orijinal görüntünün diğer parametrelerini değişmez tutmak için yararlı olabilir.Örneğin, bir piksel başına 1 bit ile siyah beyaz bir PNG görüntüsünü yüklerseniz ve sonra kaydedin.Aspose.Imaging.DataStreamSupporter.Save(System.String) yöntemi, piksel başına 8 bit çıkış PNG görüntüsü üretilecektir.Bunu önlemek ve piksel başına 1 bit PNG görüntüsünü kaydetmek için, bu yöntemi uygun tasarruf seçenekleri elde etmek ve bunları geçmek için kullanınAspose.Imaging.Image.Save (System.String,Aspose.Imaging.ImageOptionsBase) yöntemi ikinci parametredir.
public override ImageOptionsBase GetOriginalOptions()
Returns
Orijinal dosya ayarlarına dayalı seçenekler.
OnPaletteChanged(İKOLOR, İKOLOR İKOLOR)
Palet değiştirildiğinde arama yapılır.
protected override void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
O eski palet.
newPalette
IColorPalette
Yeni palet için.
SaveData(Stream)
Tasarruf verileri.
protected override void SaveData(Stream stream)
Parameters
stream
Stream
akış için.
UpdateDimensions(int , int , int)
Güncelleştirme boyutları
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
Yeni bir genişlik.
newHeight
int
Yeni bir yükseklik.
UpdateMetadata()
Son değişiklik tarihi ve saatini görüntü güncelleştirir.
protected override void UpdateMetadata()