Class RasterImage

Class RasterImage

Pôvodný názov: Aspose.Imaging Zhromaždenie: Aspose.Imaging.dll (25.4.0)

Predstavuje rasterový obraz, ktorý podporuje rasterové grafické operácie.

public abstract class RasterImage : Image, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata

Inheritance

object DisposableObject DataStreamSupporter Image RasterImage

Derived

RasterCachedImage

Implements

IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasXmpData , IHasMetadata

Z dedičných členov

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

Tento príklad ukazuje, ako nahrať informácie o pixeloch v režime typu farby, manipulovať s režimom a nastaviť ho späť na obrázok. Ak chcete vykonať tieto operácie, tento vzor vytvára nový súbor obrazu (v formáte GIF) uisng MemoryStream objekt.

//Create an instance of MemoryStream
                                                                                                                                                                                                                                                         using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                             //Create an instance of GifOptions and set its various properties including the Source property
                                                                                                                                                                                                                                                             Aspose.Imaging.ImageOptions.GifOptions gifOptions = new Aspose.Imaging.ImageOptions.GifOptions();
                                                                                                                                                                                                                                                             gifOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                                                                                                                                                                                                                                                             //Create an instance of Image
                                                                                                                                                                                                                                                             using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(gifOptions, 500, 500))
                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                 //Get the pixels of image by specifying the area as image boundary
                                                                                                                                                                                                                                                                 Aspose.Imaging.Color[] pixels = image.LoadPixels(image.Bounds);

                                                                                                                                                                                                                                                                 //Loop over the Array and sets color of alrenative indexed pixel
                                                                                                                                                                                                                                                                 for (int index = 0; index < pixels.Length; index++)
                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                     if (index % 2 == 0)
                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                         //Set the indexed pixel color to yellow
                                                                                                                                                                                                                                                                         pixels[index] = Aspose.Imaging.Color.Yellow;
                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                     else
                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                         //Set the indexed pixel color to blue
                                                                                                                                                                                                                                                                         pixels[index] = Aspose.Imaging.Color.Blue;
                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                 }

                                                                                                                                                                                                                                                                 //Apply the pixel changes to the image
                                                                                                                                                                                                                                                                 image.SavePixels(image.Bounds, pixels);

                                                                                                                                                                                                                                                                 // save all changes.
                                                                                                                                                                                                                                                                 image.Save();
                                                                                                                                                                                                                                                             }

                                                                                                                                                                                                                                                             // Write MemoryStream to File
                                                                                                                                                                                                                                                             using (System.IO.FileStream fileStream = new System.IO.FileStream(@"C:\temp\output.gif", System.IO.FileMode.Create))
                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                 stream.WriteTo(fileStream);
                                                                                                                                                                                                                                                             }   
                                                                                                                                                                                                                                                         }

Constructors

RasterImage()

Initalizuje novú inštanciu triedy Aspose.Imaging.RasterImage.

[JsonConstructor]
protected RasterImage()

RasterImage(farebná paleta)

Initalizuje novú inštanciu triedy Aspose.Imaging.RasterImage.

protected RasterImage(IColorPalette colorPalette)

Parameters

colorPalette IColorPalette

Farebná paleta .

Fields

xmpData

Metodické údaje XMP

[JsonProperty]
protected XmpPacketWrapper xmpData

Fieldová hodnota

XmpPacketWrapper

Properties

DataLoader

Získať alebo nastaviť dátový nabíjač.

[JsonProperty]
protected IRasterImageArgb32PixelLoader DataLoader { get; set; }

Hodnota nehnuteľnosti

IRasterImageArgb32PixelLoader

HasAlpha

Získava hodnotu, ktorá ukazuje, či táto inštancia má alfa.

public virtual bool HasAlpha { get; }

Hodnota nehnuteľnosti

bool

Examples

Nasledujúci príklad nahrá raster obrázky a tlačí informácie o formáte surových údajov a alfa kanál.

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

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

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

Nasledujúci príklad ukazuje, ako extrahovať informácie o formáte surových údajov a alfa kanál z obrazu BMP.

// Create a 32-bpp BMP image of 100 x 100 px.
                                                                                                                           using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 32, null))
                                                                                                                           {
                                                                                                                               System.Console.WriteLine("FileFormat={0}, RawDataFormat={1}, HasAlpha={2}", bmpImage.FileFormat, bmpImage.RawDataFormat, bmpImage.HasAlpha);
                                                                                                                           };

                                                                                                                           // Create a 24-bpp BMP image of 100 x 100 px.
                                                                                                                           using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 24, null))
                                                                                                                           {
                                                                                                                               System.Console.WriteLine("FileFormat={0}, RawDataFormat={1}, HasAlpha={2}", bmpImage.FileFormat, bmpImage.RawDataFormat, bmpImage.HasAlpha);
                                                                                                                           };

                                                                                                                           // Generally, BMP doesn't support alpha channel so the output will look like this:
                                                                                                                           // FileFormat = Bmp, RawDataFormat = Rgb32Bpp, used channels: 8,8,8,8, HasAlpha = False
                                                                                                                           // FileFormat = Bmp, RawDataFormat = Rgb24Bpp, used channels: 8,8,8, HasAlpha = False

HasTransparentColor

Získava hodnotu, ktorá ukazuje, či má obraz transparentnú farbu.

public virtual bool HasTransparentColor { get; set; }

Hodnota nehnuteľnosti

bool

HorizontalResolution

Získať alebo nastaviť horizontálnu rozlíšenie, v pixeloch na palec, tohto Aspose.Imaging.RasterImage.

public virtual double HorizontalResolution { get; set; }

Hodnota nehnuteľnosti

double

Examples

Nasledujúci príklad ukazuje, ako nastaviť horizontálne/vertikálne rozlíšenie rasterového obrazu.

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

                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
                                                                                                   {
                                                                                                       Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                       // Get horizontal and vertical resolution of the image
                                                                                                       double horizontalResolution = rasterImage.HorizontalResolution;
                                                                                                       double verticalResolution = rasterImage.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");
                                                                                                           rasterImage.SetResolution(96.0, 96.0);

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

                                                                                                       // The output may look like this:
                                                                                                       // The horizontal resolution, in pixels per inch: 300
                                                                                                       // The vertical resolution, in pixels per inch: 300
                                                                                                       // Set resolution values to 96 dpi
                                                                                                       // The horizontal resolution, in pixels per inch: 96
                                                                                                       // The vertical resolution, in pixels per inch: 96
                                                                                                   }

Remarks

V predvolenom nastavení je táto hodnota vždy 96 pretože rôzne platformy nemôžu vrátiť rozlíšenie obrazovky.Môžete zvážiť použitie metódy SetResolution na aktualizáciu oboch hodnôt rozlíšenia v jednom volaní.

ImageOpacity

Získajte opacitu tohto obrazu.

public virtual float ImageOpacity { get; }

Hodnota nehnuteľnosti

float

IsRawDataAvailable

Získava hodnotu, ktorá ukazuje, či je k dispozícii surové dátové zaťaženie.

public bool IsRawDataAvailable { get; }

Hodnota nehnuteľnosti

bool

PremultiplyComponents

Získa alebo nastaví hodnotu, ktorá naznačuje, či musia byť prvky obrazu predĺžené.

public virtual bool PremultiplyComponents { get; set; }

Hodnota nehnuteľnosti

bool

Examples

Nasledujúci príklad vytvára nový rasterový obrázok, ušetrí špecifikované poloprávne pixely, potom nahráva tieto pixely a dostane konečné farby v predmnoženej podobe.

int imageWidth = 3;
                                                                                                                                                                                  int imageHeight = 2;

                                                                                                                                                                                  Aspose.Imaging.Color[] colors = new Aspose.Imaging.Color[]
                                                                                                                                                                                  {
                                                                                                                                                                                      Aspose.Imaging.Color.FromArgb(127, 255, 0, 0),
                                                                                                                                                                                      Aspose.Imaging.Color.FromArgb(127, 0, 255, 0),
                                                                                                                                                                                      Aspose.Imaging.Color.FromArgb(127, 0, 0, 255),
                                                                                                                                                                                      Aspose.Imaging.Color.FromArgb(127, 255, 255, 0),
                                                                                                                                                                                      Aspose.Imaging.Color.FromArgb(127, 255, 0, 255),
                                                                                                                                                                                      Aspose.Imaging.Color.FromArgb(127, 0, 255, 255),
                                                                                                                                                                                  };

                                                                                                                                                                                  Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                                                                  createOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
                                                                                                                                                                                  createOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;

                                                                                                                                                                                  using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(createOptions, imageWidth, imageHeight))
                                                                                                                                                                                  {
                                                                                                                                                                                      Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                                                      // Save pixels for the whole image.
                                                                                                                                                                                      rasterImage.SavePixels(rasterImage.Bounds, colors);

                                                                                                                                                                                      // The pixels are stored in the original image in the non-premultiplied form.
                                                                                                                                                                                      // Need to specify the corresponding option explicitly to obtain premultiplied color components.
                                                                                                                                                                                      // The premultiplied color components are calculated by the formulas:
                                                                                                                                                                                      // red = original_red * alpha / 255;
                                                                                                                                                                                      // green = original_green * alpha / 255;
                                                                                                                                                                                      // blue = original_blue * alpha / 255;
                                                                                                                                                                                      rasterImage.PremultiplyComponents = true;
                                                                                                                                                                                      Aspose.Imaging.Color[] premultipliedColors = rasterImage.LoadPixels(rasterImage.Bounds);

                                                                                                                                                                                      for (int i = 0; i < colors.Length; i++)
                                                                                                                                                                                      {
                                                                                                                                                                                          System.Console.WriteLine("Original color: {0}", colors[i].ToString());
                                                                                                                                                                                          System.Console.WriteLine("Premultiplied color: {0}", premultipliedColors[i].ToString());
                                                                                                                                                                                      }
                                                                                                                                                                                  }

RawCustomColorConverter

Získajte alebo nastavíte prispôsobený farebný konvertor

public IColorConverter RawCustomColorConverter { get; set; }

Hodnota nehnuteľnosti

IColorConverter

RawDataFormat

Získava formát surových údajov.

public virtual PixelDataFormat RawDataFormat { get; }

Hodnota nehnuteľnosti

PixelDataFormat

Examples

Nasledujúci príklad nahrá raster obrázky a tlačí informácie o formáte surových údajov a alfa kanál.

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

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

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

Tento príklad ukazuje, ako nahrať obrázok DJVU z toku súborov a vytlačiť informácie o stránkach.

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

                                                                                                                // Load a DJVU image from a file stream.
                                                                                                                using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.djvu"))
                                                                                                                {
                                                                                                                    using (Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = new Aspose.Imaging.FileFormats.Djvu.DjvuImage(stream))
                                                                                                                    {
                                                                                                                        System.Console.WriteLine("The total number of pages: {0}", djvuImage.Pages.Length);
                                                                                                                        System.Console.WriteLine("The active page number:    {0}", djvuImage.ActivePage.PageNumber);
                                                                                                                        System.Console.WriteLine("The first page number:     {0}", djvuImage.FirstPage.PageNumber);
                                                                                                                        System.Console.WriteLine("The last page number:      {0}", djvuImage.LastPage.PageNumber);

                                                                                                                        foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage djvuPage in djvuImage.Pages)
                                                                                                                        {
                                                                                                                            System.Console.WriteLine("--------------------------------------------------");
                                                                                                                            System.Console.WriteLine("Page number:     {0}", djvuPage.PageNumber);
                                                                                                                            System.Console.WriteLine("Page size:       {0}", djvuPage.Size);
                                                                                                                            System.Console.WriteLine("Page raw format: {0}", djvuPage.RawDataFormat);
                                                                                                                        }
                                                                                                                    }
                                                                                                                }

                                                                                                                //The output may look like this:
                                                                                                                //The total number of pages: 2
                                                                                                                //The active page number:    1
                                                                                                                //The first page number:     1
                                                                                                                //The last page number:      2
                                                                                                                //--------------------------------------------------
                                                                                                                //Page number:     1
                                                                                                                //Page size:       { Width = 2481, Height = 3508}
                                                                                                                //Page raw format: RgbIndexed1Bpp, used channels: 1
                                                                                                                //--------------------------------------------------
                                                                                                                //Page number:     2
                                                                                                                //Page size:       { Width = 2481, Height = 3508}
                                                                                                                //Page raw format: RgbIndexed1Bpp, used channels: 1

RawDataSettings

Získajte aktuálne nastavenia surových údajov.Všimnite si, keď používate tieto nastavenia, údaje sa zaťažujú bez konverzie.

[JsonIgnore]
public RawDataSettings RawDataSettings { get; }

Hodnota nehnuteľnosti

RawDataSettings

RawFallbackIndex

Získajte alebo nastavíte index padnutia na použitie, keď je index palety mimo hraníc

public int RawFallbackIndex { get; set; }

Hodnota nehnuteľnosti

int

RawIndexedColorConverter

Získať alebo nastaviť indexovaný farebný konvertor

public IIndexedColorConverter RawIndexedColorConverter { get; set; }

Hodnota nehnuteľnosti

IIndexedColorConverter

RawLineSize

Získava veľkosť surovej línie v bytoch.

public virtual int RawLineSize { get; }

Hodnota nehnuteľnosti

int

TransparentColor

Získava obraz transparentnú farbu.

public virtual Color TransparentColor { get; set; }

Hodnota nehnuteľnosti

Color

UpdateXmpData

Získava alebo nastaví hodnotu, ktorá naznačuje, či aktualizovať metadata XMP.

public virtual bool UpdateXmpData { get; set; }

Hodnota nehnuteľnosti

bool

UsePalette

Získava hodnotu, ktorá ukazuje, či je použitá obrazová paleta.

public override bool UsePalette { get; }

Hodnota nehnuteľnosti

bool

UseRawData

Získa alebo nastaví hodnotu, ktorá naznačuje, či používať surové dátové zaťaženie, keď je surové dátové zaťaženie k dispozícii.

public virtual bool UseRawData { get; set; }

Hodnota nehnuteľnosti

bool

VerticalResolution

Získať alebo nastaviť vertikálne rozlíšenie, v pixeloch na palec, tohto Aspose.Imaging.RasterImage.

public virtual double VerticalResolution { get; set; }

Hodnota nehnuteľnosti

double

Examples

Nasledujúci príklad ukazuje, ako nastaviť horizontálne/vertikálne rozlíšenie rasterového obrazu.

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

                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
                                                                                                   {
                                                                                                       Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                       // Get horizontal and vertical resolution of the image
                                                                                                       double horizontalResolution = rasterImage.HorizontalResolution;
                                                                                                       double verticalResolution = rasterImage.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");
                                                                                                           rasterImage.SetResolution(96.0, 96.0);

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

                                                                                                       // The output may look like this:
                                                                                                       // The horizontal resolution, in pixels per inch: 300
                                                                                                       // The vertical resolution, in pixels per inch: 300
                                                                                                       // Set resolution values to 96 dpi
                                                                                                       // The horizontal resolution, in pixels per inch: 96
                                                                                                       // The vertical resolution, in pixels per inch: 96
                                                                                                   }

Remarks

V predvolenom nastavení je táto hodnota vždy 96 pretože rôzne platformy nemôžu vrátiť rozlíšenie obrazovky.Môžete zvážiť použitie metódy SetResolution na aktualizáciu oboch hodnôt rozlíšenia v jednom volaní.

XmpData

Získajte alebo nastavíte metadata XMP.

public virtual XmpPacketWrapper XmpData { get; set; }

Hodnota nehnuteľnosti

XmpPacketWrapper

Methods

AdjustBrightness(int)

Nastavenie jasu pre obrázok.

public virtual void AdjustBrightness(int brightness)

Parameters

brightness int

Hodnoty jasnosti .

Examples

Nasledujúci príklad vykonáva jasnú korekciu obrazu.

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

                                                                            using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                            {
                                                                                Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                // Set the brightness value. The accepted values of brightness are in the range [-255, 255].
                                                                                rasterImage.AdjustBrightness(50);
                                                                                rasterImage.Save(dir + "sample.AdjustBrightness.png");
                                                                            }

AdjustContrast(flotila)

Obrázok kontrast

public virtual void AdjustContrast(float contrast)

Parameters

contrast float

kontrastná hodnota (v rozmedzí [-100; 100])

Examples

Nasledujúci príklad vykonáva kontrastnú korekciu obrazu.

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

                                                                          using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                          {
                                                                              Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                              // Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
                                                                              rasterImage.AdjustContrast(50);
                                                                              rasterImage.Save(dir + "sample.AdjustContrast.png");
                                                                          }

AdjustGamma(plavba, plavba, plavba)

Gamma korekcia obrazu.

public virtual void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)

Parameters

gammaRed float

Gamma pre červený kanál koeficient

gammaGreen float

Gamma pre zelený kanál koeficient

gammaBlue float

Gamma pre modrý kanál koeficient

Examples

Nasledujúci príklad vykonáva gamma korekciu obrazu, ktorý aplikuje rôzne koeficienty na farebné komponenty.

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

                                                                                                                            using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                            {
                                                                                                                                Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                // Set individual gamma coefficients for red, green and blue channels.
                                                                                                                                rasterImage.AdjustGamma(1.5f, 2.5f, 3.5f);
                                                                                                                                rasterImage.Save(dir + "sample.AdjustGamma.png");
                                                                                                                            }

AdjustGamma(flotila)

Gamma korekcia obrazu.

public virtual void AdjustGamma(float gamma)

Parameters

gamma float

Gamma pre červené, zelené a modré kanály koeficient

Examples

Nasledujúci príklad vykonáva gamma korekciu obrazu.

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

                                                                       using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                       {
                                                                           Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                           // Set gamma coefficient for red, green and blue channels.
                                                                           rasterImage.AdjustGamma(2.5f);
                                                                           rasterImage.Save(dir + "sample.AdjustGamma.png");
                                                                       }

BinarizeBradley(Dvojitý)

Binarizácia obrazu pomocou adaptívneho prahového algoritmu Bradleyho pomocou integrovaného prahového obrazu

public virtual void BinarizeBradley(double brightnessDifference)

Parameters

brightnessDifference double

Rozdiel jasu medzi pixelom a priemerným oknom s x s pixelov sústredených okolo tohto pixelov.

BinarizeBradley(dvojnásobný, int)

Binarizácia obrazu pomocou adaptívneho prahového algoritmu Bradleyho pomocou integrovaného prahového obrazu

public virtual void BinarizeBradley(double brightnessDifference, int windowSize)

Parameters

brightnessDifference double

Rozdiel jasu medzi pixelom a priemerným oknom s x s pixelov sústredených okolo tohto pixelov.

windowSize int

Veľkosť okna s x s pixelov sústredených okolo tohto pixelov

Examples

Nasledujúci príklad binárne zobrazuje obrázok rastu s adaptívnym algoritmom Bradleyho s uvedenou veľkosťou okna.

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

                                                                                                                                                                                                  using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                                                                                  {
                                                                                                                                                                                                      Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                                                                      // Binarize the image with a brightness difference of 5. The brightness is a difference between a pixel and the average of an 10 x 10 window of pixels centered around this pixel.
                                                                                                                                                                                                      rasterImage.BinarizeBradley(5, 10);
                                                                                                                                                                                                      rasterImage.Save(dir + "sample.BinarizeBradley5_10x10.png");
                                                                                                                                                                                                  }

BinarizeFixed(byte)

Binarizácia obrazu s preddefinovaným prahom

public virtual void BinarizeFixed(byte threshold)

Parameters

threshold byte

Ak je príslušná šedá hodnota pixelov väčšia ako hraničná hodnota, hodnota 255 sa jej priradí, 0 inak.

Examples

Nasledujúci príklad binarizuje rasterový obrázok s preddefinovaným prahom. binárne obrázky obsahujú iba 2 farby - čierne a biele.

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

                                                                                                                                                  using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                                  {
                                                                                                                                                      Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                      // Binarize the image with a threshold value of 127.
                                                                                                                                                      // If a corresponding gray value of a pixel is greater than 127, a value of 255 will be assigned to it, 0 otherwise.
                                                                                                                                                      rasterImage.BinarizeFixed(127);
                                                                                                                                                      rasterImage.Save(dir + "sample.BinarizeFixed.png");
                                                                                                                                                  }

BinarizeOtsu()

Binarizácia obrazu s rozsahom Otsu

public virtual void BinarizeOtsu()

Examples

Nasledujúci príklad binarizuje raster obrázok s Otsu hranice. binárne obrázky obsahujú iba 2 farby - čierna a biela.

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

                                                                                                                                           using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                           {
                                                                                                                                               Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                               // Binarize the image with Otsu thresholding.
                                                                                                                                               rasterImage.BinarizeOtsu();
                                                                                                                                               rasterImage.Save(dir + "sample.BinarizeOtsu.png");
                                                                                                                                           }

Blend(Point, RasterImage, Rectangle, byte)

Zmiešajte tento obrázok s obrázkom overlay".

public virtual void Blend(Point origin, RasterImage overlay, Rectangle overlayArea, byte overlayAlpha = 255)

Parameters

origin Point

Obrázok pozadia zmiešaného pôvodu.

overlay RasterImage

Nadmerný obrázok .

overlayArea Rectangle

Oblasť preplnenia.

overlayAlpha byte

Prechádzka s alfa.

Blend(bod, RasterImage, byte)

Zmiešajte tento obrázok s obrázkom overlay".

public void Blend(Point origin, RasterImage overlay, byte overlayAlpha = 255)

Parameters

origin Point

Obrázok pozadia zmiešaného pôvodu.

overlay RasterImage

Nadmerný obrázok .

overlayAlpha byte

Prechádzka s alfa.

Dither(Metóda vývoja, int)

Vykonáva sa na aktuálnom obraze.

public void Dither(DitheringMethod ditheringMethod, int bitsCount)

Parameters

ditheringMethod DitheringMethod

Metóda rozptýlenia .

bitsCount int

Posledné bity počítajú na dithering.

Examples

Nasledujúci príklad nahrádza rasterový obrázok a vykonáva hraničné a plynulé dithering pomocou rôznych hĺbok palety.

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

                                                                                                                               using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                               {
                                                                                                                                   Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                   // Perform threshold dithering using 4-bit color palette which contains 16 colors.
                                                                                                                                   // The more bits specified the higher quality and the bigger size of the output image.
                                                                                                                                   // Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
                                                                                                                                   rasterImage.Dither(Aspose.Imaging.DitheringMethod.ThresholdDithering, 4);

                                                                                                                                   rasterImage.Save(dir + "sample.ThresholdDithering4.png");
                                                                                                                               }

                                                                                                                               using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                               {
                                                                                                                                   Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                   // Perform floyd dithering using 1-bit color palette which contains only 2 colors - black and white.
                                                                                                                                   // The more bits specified the higher quality and the bigger size of the output image.
                                                                                                                                   // Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
                                                                                                                                   rasterImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1);

                                                                                                                                   rasterImage.Save(dir + "sample.FloydSteinbergDithering1.png");
                                                                                                                               }

Dither(DitheringMetóda, int, IColorPalette)

Vykonáva sa na aktuálnom obraze.

public abstract void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)

Parameters

ditheringMethod DitheringMethod

Metóda rozptýlenia .

bitsCount int

Posledné bity počítajú na dithering.

customPalette IColorPalette

Zvyčajná paleta pre dithering.

Filter(Rectangle, FilterOptionsBase)

Filtruje špecifikovaný rektangul.

public virtual void Filter(Rectangle rectangle, FilterOptionsBase options)

Parameters

rectangle Rectangle

v pravom rohu.

options FilterOptionsBase

a možnosťami .

Examples

Nasledujúci príklad sa vzťahuje na rôzne typy filtrov na obraz rastu.

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

                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                    {
                                                                                        Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                        // Apply a median filter with a rectangle size of 5 to the entire image.
                                                                                        rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MedianFilterOptions(5));
                                                                                        rasterImage.Save(dir + "sample.MedianFilter.png");
                                                                                    }

                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                    {
                                                                                        Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                        // Apply a bilateral smoothing filter with a kernel size of 5 to the entire image.
                                                                                        rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.BilateralSmoothingFilterOptions(5));
                                                                                        rasterImage.Save(dir + "sample.BilateralSmoothingFilter.png");
                                                                                    }

                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                    {
                                                                                        Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                        // Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image.
                                                                                        rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
                                                                                        rasterImage.Save(dir + "sample.GaussianBlurFilter.png");
                                                                                    }

                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                    {
                                                                                        Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                        // Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image.
                                                                                        rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
                                                                                        rasterImage.Save(dir + "sample.GaussWienerFilter.png");
                                                                                    }

                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                    {
                                                                                        Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                        // Apply a motion wiener filter with a length of 5, a smooth value of 4.0 and an angle of 90.0 degrees to the entire image.
                                                                                        rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MotionWienerFilterOptions(10, 1.0, 90.0));
                                                                                        rasterImage.Save(dir + "sample.MotionWienerFilter.png");
                                                                                    }

                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                    {
                                                                                        Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                        // Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image.
                                                                                        rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
                                                                                        rasterImage.Save(dir + "sample.SharpenFilter.png");
                                                                                    }

GetArgb32Pixel(a int, int)

Získava obraz 32-bitový ARGB pixel.

public int GetArgb32Pixel(int x, int y)

Parameters

x int

Poloha pixelov x.

y int

Pixel a umiestnenie.

Returns

int

32-bitový pixel ARGB pre špecifikované umiestnenie.

Examples

Nasledujúci príklad nahrádza rasterový obrázok a získa farbu dobrovoľného pixelu, ktorý je reprezentovaný ako 32-bitová celková hodnota.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.png"))
                                                                                                                                        {
                                                                                                                                            Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                            // Get an integer representation of the color of the top-left pixel of the image.
                                                                                                                                            int color = rasterImage.GetArgb32Pixel(0, 0);

                                                                                                                                            // To obtain the values of the individual color components, shift the color value by a corresponding number of bits
                                                                                                                                            int alpha = (color >> 24) & 0xff;
                                                                                                                                            int red = (color >> 16) & 0xff;
                                                                                                                                            int green = (color >> 8) & 0xff;
                                                                                                                                            int blue = (color >> 0) & 0xff;

                                                                                                                                            System.Console.WriteLine("The color of the pixel(0,0) is A={0},R={1},G={2},B={3}", alpha, red, green, blue);
                                                                                                                                        }

Nasledujúci príklad ukazuje, ako caching obrazu ovplyvňuje výkonnosť.V všeobecnosti sa čítanie cache údajov vykonáva rýchlejšie ako čítať non-cache údaje.

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

                                                                                                                                                                    // Load an image from a PNG file.
                                                                                                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                                                    {
                                                                                                                                                                        // Cache all pixel data so that no additional data loading will be performed from the underlying data stream
                                                                                                                                                                        image.CacheData();

                                                                                                                                                                        System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
                                                                                                                                                                        stopwatch.Start();

                                                                                                                                                                        // Reading all pixels is pretty fast.
                                                                                                                                                                        Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
                                                                                                                                                                        for (int y = 0; y < image.Height; y++)
                                                                                                                                                                        {
                                                                                                                                                                            for (int x = 0; x < image.Width; x++)
                                                                                                                                                                            {
                                                                                                                                                                                int color = rasterImage.GetArgb32Pixel(x, y);
                                                                                                                                                                            }
                                                                                                                                                                        }

                                                                                                                                                                        stopwatch.Stop();
                                                                                                                                                                        System.Console.WriteLine("Reading all cached pixels took {0} ms.", stopwatch.ElapsedMilliseconds);
                                                                                                                                                                    }

                                                                                                                                                                    // Load an image from a PNG file
                                                                                                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                                                    {
                                                                                                                                                                        System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
                                                                                                                                                                        stopwatch.Start();

                                                                                                                                                                        // Reading all pixels is not as fast as when caching
                                                                                                                                                                        Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
                                                                                                                                                                        for (int y = 0; y < image.Height; y++)
                                                                                                                                                                        {
                                                                                                                                                                            for (int x = 0; x < image.Width; x++)
                                                                                                                                                                            {
                                                                                                                                                                                int color = rasterImage.GetArgb32Pixel(x, y);
                                                                                                                                                                            }
                                                                                                                                                                        }

                                                                                                                                                                        stopwatch.Stop();
                                                                                                                                                                        System.Console.WriteLine("Reading all pixels without preliminary caching took {0} ms.", stopwatch.ElapsedMilliseconds);
                                                                                                                                                                    }

                                                                                                                                                                    // The output may look like this:
                                                                                                                                                                    // Reading all cached pixels took 1500 ms.
                                                                                                                                                                    // Reading all pixels without preliminary caching took 150000 ms.

GetDefaultArgb32Pixels(Rectangle)

Získava predvolený 32-bitový ARGB pixelový rozsah.

public int[] GetDefaultArgb32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

V rektáloch sa dostanú pixely.

Returns

int []

Predvolené pixelové rozloženie.

GetDefaultPixels(Príslušenstvo pre IPartialArgb32PixelLoader)

Získava predvolené pixelové rozloženie pomocou čiastočného pixelového nabíjača.

public void GetDefaultPixels(Rectangle rectangle, IPartialArgb32PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

V rektáloch sa dostanú pixely.

partialPixelLoader IPartialArgb32PixelLoader

čiastočný pixelový nabíjač.

GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings)

Získava predvolenú surovú databázu pomocou čiastočného pixelového nabíjača.

public void GetDefaultRawData(Rectangle rectangle, IPartialRawDataLoader partialRawDataLoader, RawDataSettings rawDataSettings)

Parameters

rectangle Rectangle

V rektáloch sa dostanú pixely.

partialRawDataLoader IPartialRawDataLoader

Čiastočný surový dátový nabíjač.

rawDataSettings RawDataSettings

Nastavenie surových údajov.

GetDefaultRawData(Príslušenstvo pre RawDataSettings)

Získava predvolené surové údaje.

public byte[] GetDefaultRawData(Rectangle rectangle, RawDataSettings rawDataSettings)

Parameters

rectangle Rectangle

Rektangul pre získanie surových údajov.

rawDataSettings RawDataSettings

Nastavenie surových údajov.

Returns

byte []

Predvolené surové dátové array.

GetModifyDate(bool)

Dostane dátum a čas, kedy bola obrázok zdroja naposledy upravený.

public virtual DateTime GetModifyDate(bool useDefault)

Parameters

useDefault bool

Ak je nastavený na “skutočný”, použite informácie z programu FileInfo ako predvolenú hodnotu.

Returns

DateTime

Dátum a čas, kedy bol obrázok zdroja naposledy upravený.

GetPixel(a int, int)

Získajte obrázok pixel.

public Color GetPixel(int x, int y)

Parameters

x int

Poloha pixelov x.

y int

Pixel a umiestnenie.

Returns

Color

Farba pixelov pre určené umiestnenie.

Examples

Nasledujúci príklad nahrá rasterový obrázok a získa farbu dobrovoľného pixelov.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.png"))
                                                                                                  {
                                                                                                      Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                      // Get the color of the top-left pixel of the image.
                                                                                                      Color color = rasterImage.GetPixel(0, 0);

                                                                                                      // Obtain the values of the individual color components
                                                                                                      byte alpha = color.A;
                                                                                                      byte red = color.R;
                                                                                                      int green = color.G;
                                                                                                      int blue = color.B;

                                                                                                      System.Console.WriteLine("The color of the pixel(0,0) is A={0},R={1},G={2},B={3}", alpha, red, green, blue);
                                                                                                  }

GetSkewAngle()

Získavame úhlový kút.Táto metóda sa vzťahuje na skenované textové dokumenty, aby sa pri skenovaní určil úhel škrupiny.

public float GetSkewAngle()

Returns

float

V úzkom rohu, v stupňoch.

Grayscale()

Premeny obrazu na jeho grayscale reprezentáciu

public virtual void Grayscale()

Examples

Nasledujúci príklad transformuje farebný rasterový obrázok do jeho šedivého obrazu. Grayscale obrazy sú zložené výlučne zo odtieňov sivého a nesú iba informácie o intenzite.

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

                                                                                                                                                                                                     using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                                                                                     {
                                                                                                                                                                                                         Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                                                                         rasterImage.Grayscale();
                                                                                                                                                                                                         rasterImage.Save(dir + "sample.Grayscale.png");
                                                                                                                                                                                                     }

LoadArgb32Pixels(Rectangle)

32-bitový ARGB pixel.

public int[] LoadArgb32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

V rektáloch na stiahnutie pixelov.

Returns

int []

32-bitové ARGB pixelové rozhranie.

Examples

Nasledujúci príklad ukazuje, ako nahrať a spracovať pixely rasterového obrazu.Pixely sú reprezentované ako 32-bitové celkové hodnoty.Napríklad, zvážte problém počítania plne transparentných pixelov obrázku.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\alpha.png"))
                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                      Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                                                                                                      // Load pixels for the whole image. Any rectangular part of the image can be specified as a parameter of the Aspose.Imaging.RasterImage.LoadArgb32Pixels method.
                                                                                                                                                                                                                                      int[] pixels = rasterImage.LoadArgb32Pixels(rasterImage.Bounds);

                                                                                                                                                                                                                                      int count = 0;
                                                                                                                                                                                                                                      foreach (int pixel in pixels)
                                                                                                                                                                                                                                      {
                                                                                                                                                                                                                                          int alpha = (pixel >> 24) & 0xff;
                                                                                                                                                                                                                                          if (alpha == 0)
                                                                                                                                                                                                                                          {
                                                                                                                                                                                                                                              count++;
                                                                                                                                                                                                                                          }
                                                                                                                                                                                                                                      }

                                                                                                                                                                                                                                      System.Console.WriteLine("The number of fully transparent pixels is {0}", count);
                                                                                                                                                                                                                                      System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
                                                                                                                                                                                                                                  }

LoadArgb64Pixels(Rectangle)

Nabíja 64-bitové pixely ARGB.

public long[] LoadArgb64Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

V rektáloch na stiahnutie pixelov.

Returns

long []

Príslušenstvo pre 64-bitové ARGB pixely.

Examples

Nasledujúci príklad ukazuje, ako nahrať a spracovať pixely rasterového obrazu.Pixely sú reprezentované ako 64-bitové celkové hodnoty.Napríklad, zvážte problém počítania plne transparentných pixelov obrázku.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\16rgba.png"))
                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                      Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                                                                                                      // Load pixels for the whole image. Any rectangular part of the image can be specified as a parameter of the Aspose.Imaging.RasterImage.LoadArgb64Pixels method.
                                                                                                                                                                                                                                      // Note that the image itself must have 16 bits per sample, because Aspose.Imaging.RasterImage.LoadArgb64Pixels doesn't work with 8 bit per sample.
                                                                                                                                                                                                                                      // In order to work with 8 bits per sample please use the good old Aspose.Imaging.RasterImage.LoadArgb32Pixels method.
                                                                                                                                                                                                                                      long[] pixels = rasterImage.LoadArgb64Pixels(rasterImage.Bounds);

                                                                                                                                                                                                                                      int count = 0;
                                                                                                                                                                                                                                      foreach (int pixel in pixels)
                                                                                                                                                                                                                                      {
                                                                                                                                                                                                                                          // Note that all color components including alpha are represented by 16-bit values, so their allowed values are in the range [0, 63535].
                                                                                                                                                                                                                                          int alpha = (pixel >> 48) & 0xffff;
                                                                                                                                                                                                                                          if (alpha == 0)
                                                                                                                                                                                                                                          {
                                                                                                                                                                                                                                              count++;
                                                                                                                                                                                                                                          }
                                                                                                                                                                                                                                      }

                                                                                                                                                                                                                                      System.Console.WriteLine("The number of fully transparent pixels is {0}", count);
                                                                                                                                                                                                                                      System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
                                                                                                                                                                                                                                  }

LoadCmyk32Pixels(Rectangle)

Nahráva pixely vo formáte CMYK.

public int[] LoadCmyk32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

V rektáloch na stiahnutie pixelov.

Returns

int []

Naložené CMYK pixely sú prítomné ako 32-bitové hodnoty inateger.

LoadCmykPixels(Rectangle)

Nahráva pixely vo formáte CMYK.Prosím, použite efektívnejšiu metódu Aspose.Imaging.RasterImage.LoadCmyk32Pixels(__W L17_Rectangle).

[Obsolete("Method is obsolete")]
public CmykColor[] LoadCmykPixels(Rectangle rectangle)

Parameters

rectangle Rectangle

V rektáloch na stiahnutie pixelov.

Returns

CmykColor []

Zariadenie CMYK pixelov.

LoadPartialArgb32Pixels(Príslušenstvo pre IPartialArgb32PixelLoader)

32-bitové ARGB pixely sa čiastočne nahrávajú baleniami.

public void LoadPartialArgb32Pixels(Rectangle rectangle, IPartialArgb32PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

požadovaný rektangul.

partialPixelLoader IPartialArgb32PixelLoader

32-bitový pixelový nabíjač ARGB.

Examples

Nasledujúci príklad ukazuje, ako nahrať a spracovať pixely rasterového obrazu pomocou vlastného čiastočného procesora. Napríklad, zvážte problém počítania plne transparentných pixelov obrázku. Aby sa vypočítavali transparentné pixely pomocou mechanizmu častého nahrávania, je zavedená samostatná trieda TransparentArgb32PixelCounter implementing Aspose.Imaging.IPartialArGB32PixelLoader.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\alpha.png"))
                                                                                                                                                                                                                                                                                                                                                                                                        {
                                                                                                                                                                                                                                                                                                                                                                                                            Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                                                                                                                                                                                                                                                                            // Create an instance of the Aspose.Imaging.IPartialArgb32PixelLoader and pass it to the Aspose.Imaging.RasterImage.LoadPartialArgb32Pixels
                                                                                                                                                                                                                                                                                                                                                                                                            TransparentArgb32PixelCounter counter = new TransparentArgb32PixelCounter();

                                                                                                                                                                                                                                                                                                                                                                                                            // Load pixels for the whole image. Any rectangular part of the image can be specified as the first parameter of the Aspose.Imaging.RasterImage.LoadPartialArgb32Pixels method.
                                                                                                                                                                                                                                                                                                                                                                                                            rasterImage.LoadPartialArgb32Pixels(rasterImage.Bounds, counter);

                                                                                                                                                                                                                                                                                                                                                                                                            System.Console.WriteLine("The number of fully transparent pixels is {0}", counter.Count);
                                                                                                                                                                                                                                                                                                                                                                                                            System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
                                                                                                                                                                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                                                                                                                                                                        // The counter may look like this:        
                                                                                                                                                                                                                                                                                                                                                                                                        /// <summary>
                                                                                                                                                                                                                                                                                                                                                                                                        /// Counts the number of fully transparent pixels with alpha channel value of 0.
                                                                                                                                                                                                                                                                                                                                                                                                        /// </summary>
                                                                                                                                                                                                                                                                                                                                                                                                        private class TransparentArgb32PixelCounter : IPartialArgb32PixelLoader
                                                                                                                                                                                                                                                                                                                                                                                                        {
                                                                                                                                                                                                                                                                                                                                                                                                            /// <summary>
                                                                                                                                                                                                                                                                                                                                                                                                            /// The number of fully transparent pixels.
                                                                                                                                                                                                                                                                                                                                                                                                            /// </summary>
                                                                                                                                                                                                                                                                                                                                                                                                            private int count;

                                                                                                                                                                                                                                                                                                                                                                                                            /// <summary>
                                                                                                                                                                                                                                                                                                                                                                                                            /// Gets the number of fully transparent pixels.
                                                                                                                                                                                                                                                                                                                                                                                                            /// </summary>
                                                                                                                                                                                                                                                                                                                                                                                                            public int Count
                                                                                                                                                                                                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                                                                                                                                                                                                get { return this.count; }
                                                                                                                                                                                                                                                                                                                                                                                                            }

                                                                                                                                                                                                                                                                                                                                                                                                            /// <summary>
                                                                                                                                                                                                                                                                                                                                                                                                            /// Processes the loaded pixels. This method is called back every time when a new portion of pixels is loaded.
                                                                                                                                                                                                                                                                                                                                                                                                            /// </summary>
                                                                                                                                                                                                                                                                                                                                                                                                            /// <param name="pixelsRectangle"/>The pixels rectangle.
                                                                                                                                                                                                                                                                                                                                                                                                            /// <param name="pixels"/>The 32-bit ARGB pixels.
                                                                                                                                                                                                                                                                                                                                                                                                            /// <param name="start"/>The start pixels point.
                                                                                                                                                                                                                                                                                                                                                                                                            /// <param name="end"/>The end pixels point.
                                                                                                                                                                                                                                                                                                                                                                                                            public void Process(Aspose.Imaging.Rectangle pixelsRectangle, int[] pixels, Aspose.Imaging.Point start, Aspose.Imaging.Point end)
                                                                                                                                                                                                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                                                                                                                                                                                                foreach (int pixel in pixels)
                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                    int alpha = (pixel &gt;&gt; 24) &amp; 0xff;
                                                                                                                                                                                                                                                                                                                                                                                                                    if (alpha == 0)
                                                                                                                                                                                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                                                                                                                                                                                        this.count++;
                                                                                                                                                                                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                                                                                                                                                        }

LoadPartialArgb64Pixels(Príslušenstvo pre IPartialArgb64PixelLoader)

64-bitové ARGB pixely sa čiastočne nahrávajú balíkmi.

public void LoadPartialArgb64Pixels(Rectangle rectangle, IPartialArgb64PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

požadovaný rektangul.

partialPixelLoader IPartialArgb64PixelLoader

64-bitový pixelový nabíjač ARGB.

LoadPartialPixels(Príslušenstvo pre IPartialPixelLoader)

Naloží pixely čiastočne baleniami.

public void LoadPartialPixels(Rectangle desiredRectangle, IPartialPixelLoader pixelLoader)

Parameters

desiredRectangle Rectangle

požadovaný rektangul.

pixelLoader IPartialPixelLoader

Pixelový nabíjač.

Examples

Nasledujúci príklad ukazuje, ako nahrať a spracovať pixely rasterového obrazu pomocou vlastného čiastočného procesora. Napríklad, zvážte problém počítania plne transparentných pixelov snímky. Aby bolo možné počítať transparentne pomocou mechanizmu čiastkového zaťaženia, je zavedená samostatná trieda TransparentPixelCounter implementing Aspose.Imaging.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\alpha.png"))
                                                                                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                                                                                         Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                                                                                                                                                                                                                                                         // Create an instance of the Aspose.Imaging.IPartialPixelLoader and pass it to the Aspose.Imaging.RasterImage.LoadPartialPixels
                                                                                                                                                                                                                                                                                                                                                                                         TransparentPixelCounter counter = new TransparentPixelCounter();

                                                                                                                                                                                                                                                                                                                                                                                         // Load pixels for the whole image. Any rectangular part of the image can be specified as the first parameter of the Aspose.Imaging.RasterImage.LoadPartialPixels method.
                                                                                                                                                                                                                                                                                                                                                                                         rasterImage.LoadPartialPixels(rasterImage.Bounds, counter);

                                                                                                                                                                                                                                                                                                                                                                                         System.Console.WriteLine("The number of fully transparent pixels is {0}", counter.Count);
                                                                                                                                                                                                                                                                                                                                                                                         System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
                                                                                                                                                                                                                                                                                                                                                                                     }

                                                                                                                                                                                                                                                                                                                                                                                     // The counter may look like this:
                                                                                                                                                                                                                                                                                                                                                                                     /// <summary>
                                                                                                                                                                                                                                                                                                                                                                                     /// Counts the number of fully transparent pixels with alpha channel value of 0.
                                                                                                                                                                                                                                                                                                                                                                                     /// </summary>
                                                                                                                                                                                                                                                                                                                                                                                     private class TransparentPixelCounter : IPartialPixelLoader
                                                                                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                                                                                         /// <summary>
                                                                                                                                                                                                                                                                                                                                                                                         /// The number of fully transparent pixels.
                                                                                                                                                                                                                                                                                                                                                                                         /// </summary>
                                                                                                                                                                                                                                                                                                                                                                                         private int count;

                                                                                                                                                                                                                                                                                                                                                                                         /// <summary>
                                                                                                                                                                                                                                                                                                                                                                                         /// Gets the number of fully transparent pixels.
                                                                                                                                                                                                                                                                                                                                                                                         /// </summary>
                                                                                                                                                                                                                                                                                                                                                                                         public int Count
                                                                                                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                                                                                                             get { return this.count; }
                                                                                                                                                                                                                                                                                                                                                                                         }

                                                                                                                                                                                                                                                                                                                                                                                         /// <summary>
                                                                                                                                                                                                                                                                                                                                                                                         /// Processes the loaded pixels. This method is called back every time when a new portion of pixels is loaded.
                                                                                                                                                                                                                                                                                                                                                                                         /// </summary>
                                                                                                                                                                                                                                                                                                                                                                                         /// <param name="pixelsRectangle"/>The pixels rectangle.
                                                                                                                                                                                                                                                                                                                                                                                         /// <param name="pixels"/>The 32-bit ARGB pixels.
                                                                                                                                                                                                                                                                                                                                                                                         /// <param name="start"/>The start pixels point.
                                                                                                                                                                                                                                                                                                                                                                                         /// <param name="end"/>The end pixels point.
                                                                                                                                                                                                                                                                                                                                                                                         public void Process(Aspose.Imaging.Rectangle pixelsRectangle, Aspose.Imaging.Color[] pixels, Aspose.Imaging.Point start, Aspose.Imaging.Point end)
                                                                                                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                                                                                                             foreach (Color pixel in pixels)
                                                                                                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                                                                                                 if (pixel.A == 0)
                                                                                                                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                                                                                                                     this.count++;
                                                                                                                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                                                                                     }

LoadPixels(Rectangle)

Sťahovanie pixelov.

public Color[] LoadPixels(Rectangle rectangle)

Parameters

rectangle Rectangle

V rektáloch na stiahnutie pixelov.

Returns

Color []

Zariadené pixely sú v poriadku.

Examples

Nasledujúci príklad ukazuje, ako nahrať a spracovať pixely rasterového obrazu. Napríklad, zvážte problém počítania plne transparentných pixelov obrázku.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\alpha.png"))
                                                                                                                                                                             {
                                                                                                                                                                                 Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                                                 // Load pixels for the whole image. Any rectangular part of the image can be specified as a parameter of the Aspose.Imaging.RasterImage.LoadPixels method.
                                                                                                                                                                                 Color[] pixels = rasterImage.LoadPixels(rasterImage.Bounds);

                                                                                                                                                                                 int count = 0;
                                                                                                                                                                                 foreach (Color pixel in pixels)
                                                                                                                                                                                 {
                                                                                                                                                                                     if (pixel.A == 0)
                                                                                                                                                                                     {
                                                                                                                                                                                         count++;
                                                                                                                                                                                     }
                                                                                                                                                                                 }

                                                                                                                                                                                 System.Console.WriteLine("The number of fully transparent pixels is {0}", count);
                                                                                                                                                                                 System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
                                                                                                                                                                             }

Tento príklad ukazuje, ako nahrať informácie o pixeloch v režime typu farby, manipulovať s režimom a nastaviť ho späť na obrázok. Ak chcete vykonať tieto operácie, tento vzor vytvára nový súbor obrazu (v formáte GIF) uisng MemoryStream objekt.

//Create an instance of MemoryStream
                                                                                                                                                                                                                                                         using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                             //Create an instance of GifOptions and set its various properties including the Source property
                                                                                                                                                                                                                                                             Aspose.Imaging.ImageOptions.GifOptions gifOptions = new Aspose.Imaging.ImageOptions.GifOptions();
                                                                                                                                                                                                                                                             gifOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                                                                                                                                                                                                                                                             //Create an instance of Image
                                                                                                                                                                                                                                                             using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(gifOptions, 500, 500))
                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                 //Get the pixels of image by specifying the area as image boundary
                                                                                                                                                                                                                                                                 Aspose.Imaging.Color[] pixels = image.LoadPixels(image.Bounds);

                                                                                                                                                                                                                                                                 //Loop over the Array and sets color of alrenative indexed pixel
                                                                                                                                                                                                                                                                 for (int index = 0; index &lt; pixels.Length; index++)
                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                     if (index % 2 == 0)
                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                         //Set the indexed pixel color to yellow
                                                                                                                                                                                                                                                                         pixels[index] = Aspose.Imaging.Color.Yellow;
                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                     else
                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                         //Set the indexed pixel color to blue
                                                                                                                                                                                                                                                                         pixels[index] = Aspose.Imaging.Color.Blue;
                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                 }

                                                                                                                                                                                                                                                                 //Apply the pixel changes to the image
                                                                                                                                                                                                                                                                 image.SavePixels(image.Bounds, pixels);

                                                                                                                                                                                                                                                                 // save all changes.
                                                                                                                                                                                                                                                                 image.Save();
                                                                                                                                                                                                                                                             }

                                                                                                                                                                                                                                                             // Write MemoryStream to File
                                                                                                                                                                                                                                                             using (System.IO.FileStream fileStream = new System.IO.FileStream(@"C:\temp\output.gif", System.IO.FileMode.Create))
                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                 stream.WriteTo(fileStream);
                                                                                                                                                                                                                                                             }   
                                                                                                                                                                                                                                                         }

LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader)

Naloží surové údaje.

public void LoadRawData(Rectangle rectangle, RawDataSettings rawDataSettings, IPartialRawDataLoader rawDataLoader)

Parameters

rectangle Rectangle

Rektangul pre nahrávanie surových údajov z.

rawDataSettings RawDataSettings

Nastavenia surových údajov na použitie pre nahrané údaje.Upozorňujeme, že ak údaje nie sú v špecifikovanom formáte, potom sa uskutoční konverzia údajov.

rawDataLoader IPartialRawDataLoader

Príslušenstvo pre surový dátový nabíjač.

Examples

Nasledujúci príklad ukazuje, ako extrahovať pixely z surových údajov s použitím RawDataSettings. Napríklad, zvážte problém počítania plne transparentných pixelov obrazu.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\GrayscaleWithAlpha.png"))
                                                                                                                                                                                                {
                                                                                                                                                                                                    Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
                                                                                                                                                                                                    Aspose.Imaging.RawDataSettings settings = rasterImage.RawDataSettings;

                                                                                                                                                                                                    TransparentPixelRawDataCounter rawDataLoader = new TransparentPixelRawDataCounter(settings);

                                                                                                                                                                                                    // Load pixels for the whole image. Any rectangular part of the image can be specified as a parameter of the Aspose.Imaging.RasterImage.LoadRawData method.
                                                                                                                                                                                                    rasterImage.LoadRawData(rasterImage.Bounds, settings, rawDataLoader);

                                                                                                                                                                                                    System.Console.WriteLine("The number of fully transparent pixels is {0}", rawDataLoader.Count);
                                                                                                                                                                                                    System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
                                                                                                                                                                                                }

                                                                                                                                                                                                // In case of raw data, the counter may look like this:
                                                                                                                                                                                                /// <summary>
                                                                                                                                                                                                /// Counts the number of fully transparent pixels with alpha channel value of 0.
                                                                                                                                                                                                /// </summary>
                                                                                                                                                                                                private class TransparentPixelRawDataCounter : IPartialRawDataLoader
                                                                                                                                                                                                {
                                                                                                                                                                                                    /// <summary>
                                                                                                                                                                                                    /// The number of fully transparent pixels.
                                                                                                                                                                                                    /// </summary>
                                                                                                                                                                                                    private int count;

                                                                                                                                                                                                    /// <summary>
                                                                                                                                                                                                    /// The raw data settings of the loaded image.
                                                                                                                                                                                                    /// </summary>
                                                                                                                                                                                                    private Aspose.Imaging.RawDataSettings rawDataSettings;

                                                                                                                                                                                                    /// <summary>
                                                                                                                                                                                                    /// Gets the number of fully transparent pixels.
                                                                                                                                                                                                    /// </summary>
                                                                                                                                                                                                    public int Count
                                                                                                                                                                                                    {
                                                                                                                                                                                                        get { return this.count; }
                                                                                                                                                                                                    }

                                                                                                                                                                                                    /// <summary>
                                                                                                                                                                                                    /// Initializes a new instance of the <see transparentpixelrawdatacounter=""></see> class.
                                                                                                                                                                                                    /// </summary>
                                                                                                                                                                                                    /// <param name="settings"/>The raw data settings allow to extract color components from raw data.
                                                                                                                                                                                                    public TransparentPixelRawDataCounter(Aspose.Imaging.RawDataSettings settings)
                                                                                                                                                                                                    {
                                                                                                                                                                                                        this.rawDataSettings = settings;
                                                                                                                                                                                                        this.count = 0;
                                                                                                                                                                                                    }

                                                                                                                                                                                                    /// <summary>
                                                                                                                                                                                                    /// Processes the loaded raw data. This method is called back every time when a new portion of raw data is loaded.
                                                                                                                                                                                                    /// </summary>
                                                                                                                                                                                                    /// <param name="dataRectangle"/>The raw data rectangle.
                                                                                                                                                                                                    /// <param name="data"/>The raw data.
                                                                                                                                                                                                    /// <param name="start"/>The start data point.
                                                                                                                                                                                                    /// <param name="end"/>The end data point.
                                                                                                                                                                                                    public void Process(Aspose.Imaging.Rectangle dataRectangle, byte[] data, Aspose.Imaging.Point start, Aspose.Imaging.Point end)
                                                                                                                                                                                                    {
                                                                                                                                                                                                        int[] channelBits = this.rawDataSettings.PixelDataFormat.ChannelBits;

                                                                                                                                                                                                        // Only simple formats are consdired here to simplify the code.
                                                                                                                                                                                                        // Let's consider only images with 8 bits per sample.
                                                                                                                                                                                                        for (int i = 0; i &lt; channelBits.Length; i++)
                                                                                                                                                                                                        {
                                                                                                                                                                                                            if (channelBits[i] != 8)
                                                                                                                                                                                                            {
                                                                                                                                                                                                                throw new System.NotSupportedException();
                                                                                                                                                                                                            }
                                                                                                                                                                                                        }

                                                                                                                                                                                                        switch (this.rawDataSettings.PixelDataFormat.PixelFormat)
                                                                                                                                                                                                        {
                                                                                                                                                                                                            case PixelFormat.Rgb:
                                                                                                                                                                                                            case PixelFormat.Bgr:
                                                                                                                                                                                                                {
                                                                                                                                                                                                                    if (channelBits.Length == 4)
                                                                                                                                                                                                                    {
                                                                                                                                                                                                                        // ARGB
                                                                                                                                                                                                                        for (int i = 0; i &lt; data.Length; i += 4)
                                                                                                                                                                                                                        {
                                                                                                                                                                                                                            // The alpha channel is stored last, after the color components.
                                                                                                                                                                                                                            if (data[i + 3] == 0)
                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                this.count++;
                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        }
                                                                                                                                                                                                                    }
                                                                                                                                                                                                                }
                                                                                                                                                                                                                break;

                                                                                                                                                                                                            case PixelFormat.Grayscale:
                                                                                                                                                                                                                {
                                                                                                                                                                                                                    if (channelBits.Length == 2)
                                                                                                                                                                                                                    {
                                                                                                                                                                                                                        // Grayscale Alpha
                                                                                                                                                                                                                        for (int i = 0; i &lt; data.Length; i += 2)
                                                                                                                                                                                                                        {
                                                                                                                                                                                                                            // The alpha channel is stored last, after the color components.
                                                                                                                                                                                                                            if (data[i + 1] == 0)
                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                this.count++;
                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        }
                                                                                                                                                                                                                    }
                                                                                                                                                                                                                }
                                                                                                                                                                                                                break;

                                                                                                                                                                                                            default:
                                                                                                                                                                                                                throw new System.ArgumentOutOfRangeException("PixelFormat");
                                                                                                                                                                                                        }
                                                                                                                                                                                                    }

                                                                                                                                                                                                    /// <summary>
                                                                                                                                                                                                    /// Processes the loaded raw data. This method is called back every time when a new portion of raw data is loaded.
                                                                                                                                                                                                    /// </summary>
                                                                                                                                                                                                    /// <param name="dataRectangle"/>The raw data rectangle.
                                                                                                                                                                                                    /// <param name="data"/>The raw data.
                                                                                                                                                                                                    /// <param name="start"/>The start data point.
                                                                                                                                                                                                    /// <param name="end"/>The end data point.
                                                                                                                                                                                                    /// <param name="loadOptions"/>The load options.
                                                                                                                                                                                                    public void Process(Aspose.Imaging.Rectangle dataRectangle, byte[] data, Aspose.Imaging.Point start, Aspose.Imaging.Point end, Aspose.Imaging.LoadOptions loadOptions)
                                                                                                                                                                                                    {
                                                                                                                                                                                                        this.Process(dataRectangle, data, start, end);
                                                                                                                                                                                                    }
                                                                                                                                                                                                }

LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader)

Naloží surové údaje.

public void LoadRawData(Rectangle rectangle, Rectangle destImageBounds, RawDataSettings rawDataSettings, IPartialRawDataLoader rawDataLoader)

Parameters

rectangle Rectangle

Rektangul pre nahrávanie surových údajov z.

destImageBounds Rectangle

Obrázok je obmedzený.

rawDataSettings RawDataSettings

Nastavenia surových údajov na použitie pre nahrané údaje.Upozorňujeme, že ak údaje nie sú v špecifikovanom formáte, potom sa uskutoční konverzia údajov.

rawDataLoader IPartialRawDataLoader

Príslušenstvo pre surový dátový nabíjač.

NormalizeAngle()

Normalizuje úhel.Táto metóda sa vzťahuje na skenované textové dokumenty, aby sa zbavili šikovaného skenovania.Tento spôsob používa metódy Aspose.Imaging.RasterImage.GetSkewAngle a W L17. RasterImage.Rote(System.Single).

public void NormalizeAngle()

NormalizeAngle(bool, farba)

Normalizuje úhel.Táto metóda sa vzťahuje na skenované textové dokumenty, aby sa zbavili šikovaného skenovania.Táto metóda používa metód Aspose.Imaging.RasterImage.GetSkewAngle a W L 17_ .Rast Image (System.Single, System.Boolean,__ WL 17_.Color).

public virtual void NormalizeAngle(bool resizeProportionally, Color backgroundColor)

Parameters

resizeProportionally bool

ak je nastavený na “skutočný”, zmení sa veľkosť obrazu podľa rotujúcich rektangulárnych (kornových bodov) projekcií v inom prípade, ktoré zanechávajú rozmery bez dotyku a rotujú sa iba vnútorné obsahy obrazu.

backgroundColor Color

Farba z pozadia.

Examples

Skew je artefakt, ktorý sa môže objaviť počas procesu skenovania dokumentov, keď sa text/obrázok dokumentu otáča v miernom rohu. Môže to mať rôzne príčiny, ale najčastejšie je, že papier sa počas skenovanie nesprávne umiestni. Preto je odkazu procesom detekcie a opravy tohto problému na skenovaných súboroch (t. j. bitmap) takže odkreslené dokumenty budú mať text / obrázky správne a horizontálne upravené.

string dir = "c:\\aspose.imaging\\issues\\net\\3567\\";

                                                                                                                                                                                                                                                                                                                                                                                                                                          string inputFilePath = dir + "skewed.png";
                                                                                                                                                                                                                                                                                                                                                                                                                                          string outputFilePath = dir + "skewed.out.png";

                                                                                                                                                                                                                                                                                                                                                                                                                                          // Get rid of the skewed scan with default parameters
                                                                                                                                                                                                                                                                                                                                                                                                                                          using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(inputFilePath))
                                                                                                                                                                                                                                                                                                                                                                                                                                          {
                                                                                                                                                                                                                                                                                                                                                                                                                                              // Deskew
                                                                                                                                                                                                                                                                                                                                                                                                                                              image.NormalizeAngle(false /*do not resize*/, Aspose.Imaging.Color.LightGray /*background color*/);
                                                                                                                                                                                                                                                                                                                                                                                                                                              image.Save(outputFilePath);
                                                                                                                                                                                                                                                                                                                                                                                                                                          }

NormalizeHistogram()

Normalizuje histogram obrazu – prispôsobí hodnoty pixelov na použitie všetkých dostupných rozsahov.

public virtual void NormalizeHistogram()

ReadArgb32ScanLine(int)

Prečítajte si celú skenovacie linku podľa špecifikovaného indexu skenovacieho linka.

public int[] ReadArgb32ScanLine(int scanLineIndex)

Parameters

scanLineIndex int

Zero-základný index skenovacieho riadku.

Returns

int []

Zariadenie 32-bitové farebné hodnoty ARGB.

ReadScanLine(int)

Prečítajte si celú skenovacie linku podľa špecifikovaného indexu skenovacieho linka.

public Color[] ReadScanLine(int scanLineIndex)

Parameters

scanLineIndex int

Zero-základný index skenovacieho riadku.

Returns

Color []

Zariadenie pixelových farebných hodnôt.

ReleaseManagedResources()

Uvoľní spravované zdroje. uistite sa, že tu nie sú spravované zdroje uvoľnené, pretože možno už boli uvoľnené.

protected override void ReleaseManagedResources()

RemoveMetadata()

Odstrániť tento obrázok príklad metadata tým, že nastaviť túto hodnotu Aspose.Imaging.Xmp.IHasXMPData. nula.

public override void RemoveMetadata()

ReplaceColor(farba, byte, farba)

Zmení jednu farbu na druhú s povoleným rozdielom a zachováva pôvodnú hodnotu alfa, aby sa zachránili hladké okraje.

public void ReplaceColor(Color oldColor, byte oldColorDiff, Color newColor)

Parameters

oldColor Color

Staré farby by mali byť nahradené.

oldColorDiff byte

Povolený rozdiel v starej farbe, aby bolo možné rozšíriť nahradený tón farby.

newColor Color

Nová farba nahradí starú farbu

ReplaceColor(int, byte, int)

Zmení jednu farbu na druhú s povoleným rozdielom a zachováva pôvodnú hodnotu alfa, aby sa zachránili hladké okraje.

public virtual void ReplaceColor(int oldColorArgb, byte oldColorDiff, int newColorArgb)

Parameters

oldColorArgb int

Staré farebné hodnoty ARGB by mali byť nahradené.

oldColorDiff byte

Povolený rozdiel v starej farbe, aby bolo možné rozšíriť nahradený tón farby.

newColorArgb int

Nová farba ARGB hodnoty nahradiť starú farbu.

ReplaceNonTransparentColors(Color)

Nahradí všetky nešetrné farby novou farbou a zachováva pôvodnú hodnotu alfa, aby sa zachránili hladké okraje.Poznámka: Ak ho použijete na snímkach bez transparentnosti, všetky farby budú nahradené jedným.

public void ReplaceNonTransparentColors(Color newColor)

Parameters

newColor Color

Nová farba nahrádza nepresné farby.

ReplaceNonTransparentColors(int)

Nahradí všetky nešetrné farby novou farbou a zachováva pôvodnú hodnotu alfa, aby sa zachránili hladké okraje.Poznámka: Ak ho použijete na snímkach bez transparentnosti, všetky farby budú nahradené jedným.

public virtual void ReplaceNonTransparentColors(int newColorArgb)

Parameters

newColorArgb int

Nová farebná hodnota ARGB nahradí neprehľadné farby.

Resize(int, int, ImageResizeSettings)

Obnoviť obrázok s rozšírenými možnosťami.

public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)

Parameters

newWidth int

a novú šírku.

newHeight int

a novú výšku.

settings ImageResizeSettings

Odstránené nastavenia .

Examples

Tento príklad nahráva rasterový obrázok a resizuje ho pomocou rôznych rezingových nastavení.

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

                                                                                            Aspose.Imaging.ImageResizeSettings resizeSettings = new Aspose.Imaging.ImageResizeSettings();

                                                                                            // The adaptive algorithm based on weighted and blended rational function and lanczos3 interpolation.
                                                                                            resizeSettings.Mode = Aspose.Imaging.ResizeType.AdaptiveResample;

                                                                                            // The small rectangular filter
                                                                                            resizeSettings.FilterType = Aspose.Imaging.ImageFilterType.SmallRectangular;

                                                                                            // The number of colors in the palette.
                                                                                            resizeSettings.EntriesCount = 256;

                                                                                            // The color quantization is not used
                                                                                            resizeSettings.ColorQuantizationMethod = ColorQuantizationMethod.None;

                                                                                            // The euclidian method
                                                                                            resizeSettings.ColorCompareMethod = ColorCompareMethod.Euclidian;

                                                                                            using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                            {
                                                                                                // Scale down by 2 times using adaptive resampling.
                                                                                                image.Resize(image.Width / 2, image.Height / 2, resizeSettings);
                                                                                                image.Save(dir + "downsample.adaptive.gif");
                                                                                            }

Rotate(Float, bool, farba)

Obrázok sa otáča okolo centra.

public virtual void Rotate(float angle, bool resizeProportionally, Color backgroundColor)

Parameters

angle float

Zvuk sa otáča v stupňoch. pozitívne hodnoty sa otáčajú hodinovo.

resizeProportionally bool

ak je nastavený na “skutočný”, zmení sa veľkosť obrazu podľa rotujúcich rektangulárnych (kornových bodov) projekcií v inom prípade, ktoré zanechávajú rozmery bez dotyku a rotujú sa iba vnútorné obsahy obrazu.

backgroundColor Color

Farba z pozadia.

Exceptions

NotImplementedException

Neimplementované výnimky

Rotate(flotila)

Obrázok sa otáča okolo centra.

public override void Rotate(float angle)

Parameters

angle float

Zvuk sa otáča v stupňoch. pozitívne hodnoty sa otáčajú hodinovo.

Save(Stream, ImageOptionsBase, Rectangle)

Uloží údaje obrazu do špecifikovaného prúdu v špecifikovanom formáte súboru podľa možností uloženia.

public override void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)

Parameters

stream Stream

Stream na ukladanie údajov obrazu na.

optionsBase ImageOptionsBase

Možnosti na úsporu.

boundsRectangle Rectangle

Obrázok určenia obmedzuje rektangul. Nastaviť prázdny rektangul pre použitie zdrojových hraníc.

SaveArgb32Pixels(rektangul, int[])

Ušetrí 32-bitové ARGB pixely.

public void SaveArgb32Pixels(Rectangle rectangle, int[] pixels)

Parameters

rectangle Rectangle

V rektáloch zachrániť pixely na.

pixels int []

32-bitové ARGB pixelové rozhranie.

Examples

Nasledujúci príklad vyplní centrálnu oblasť rasterového obrazu čiernymi pixelmi pomocou metódy Aspose.Imaging.RasterImage.SaveArgb32Pixels.

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

                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                                         {
                                                                                                                                                             Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                             // The black square
                                                                                                                                                             int[] pixels = new int[(rasterImage.Width / 2) * (rasterImage.Height / 2)];
                                                                                                                                                             for (int i = 0; i &lt; pixels.Length; i++)
                                                                                                                                                             {
                                                                                                                                                                 pixels[i] = Color.Black.ToArgb();
                                                                                                                                                             }

                                                                                                                                                             // Draw the black square at the center of the image.
                                                                                                                                                             Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(rasterImage.Width / 4, rasterImage.Height / 4, rasterImage.Width / 2, rasterImage.Height / 2);
                                                                                                                                                             rasterImage.SaveArgb32Pixels(area, pixels);

                                                                                                                                                             rasterImage.Save(dir + "sample.SaveArgb32Pixels.png");
                                                                                                                                                         }

SaveCmyk32Pixels(rektangul, int[])

Ušetriť pixely.

public void SaveCmyk32Pixels(Rectangle rectangle, int[] pixels)

Parameters

rectangle Rectangle

V rektáloch zachrániť pixely na.

pixels int []

CMYK pixely sú prezentované ako 32-bitové integrované hodnoty.

Examples

Nasledujúci príklad vyplní centrálnu oblasť rasterového obrazu čiernymi pixelmi pomocou metódy Aspose.Imaging.RasterImage.SaveCmyk32Pixels.

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

                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                                         {
                                                                                                                                                             Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                             // Get an integer representation of black in the CMYK color space.
                                                                                                                                                             int blackCmyk = Aspose.Imaging.CmykColorHelper.ToCmyk(Color.Black);

                                                                                                                                                             // The black square.
                                                                                                                                                             int[] pixels = new int[(rasterImage.Width / 2) * (rasterImage.Height / 2)];
                                                                                                                                                             for (int i = 0; i &lt; pixels.Length; i++)
                                                                                                                                                             {
                                                                                                                                                                 pixels[i] = blackCmyk;
                                                                                                                                                             }

                                                                                                                                                             // Draw the black square at the center of the image.
                                                                                                                                                             Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(rasterImage.Width / 4, rasterImage.Height / 4, rasterImage.Width / 2, rasterImage.Height / 2);
                                                                                                                                                             rasterImage.SaveCmyk32Pixels(area, pixels);

                                                                                                                                                             rasterImage.Save(dir + "sample.SaveCmyk32Pixels.png");
                                                                                                                                                         }

SaveCmykPixels(Rektangle, CmykColor[])

Ušetriť pixely.Prosím, použite efektívnejšiu metódu Aspose.Imaging.RasterImage.SaveCmyk32Pixels(W L 17 .Rectangle,System.Int32[]).

[Obsolete("Method is obsolete")]
public void SaveCmykPixels(Rectangle rectangle, CmykColor[] pixels)

Parameters

rectangle Rectangle

V rektáloch zachrániť pixely na.

pixels CmykColor []

CMYK pixely sú rozdelené.

SavePixels(rektangul, farba[])

Ušetriť pixely.

public void SavePixels(Rectangle rectangle, Color[] pixels)

Parameters

rectangle Rectangle

V rektáloch zachrániť pixely na.

pixels Color []

Pixel je v poriadku.

Examples

Nasledujúci príklad vyplní centrálnu oblasť rasterového obrazu čiernymi pixelmi pomocou metódy Aspose.Imaging.RasterImage.SavePixels.

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

                                                                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                                                   {
                                                                                                                                                       Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                                                                       // The black square
                                                                                                                                                       Color[] pixels = new Color[(rasterImage.Width / 2) * (rasterImage.Height / 2)];
                                                                                                                                                       for (int i = 0; i &lt; pixels.Length; i++)
                                                                                                                                                       {
                                                                                                                                                           pixels[i] = Color.Black;
                                                                                                                                                       }

                                                                                                                                                       // Draw the black square at the center of the image.
                                                                                                                                                       Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(rasterImage.Width / 4, rasterImage.Height / 4, rasterImage.Width / 2, rasterImage.Height / 2);
                                                                                                                                                       rasterImage.SavePixels(area, pixels);

                                                                                                                                                       rasterImage.Save(dir + "sample.SavePixels.png");
                                                                                                                                                   }

Tento príklad ukazuje, ako nahrať informácie o pixeloch v režime typu farby, manipulovať s režimom a nastaviť ho späť na obrázok. Ak chcete vykonať tieto operácie, tento vzor vytvára nový súbor obrazu (v formáte GIF) uisng MemoryStream objekt.

//Create an instance of MemoryStream
                                                                                                                                                                                                                                                         using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                             //Create an instance of GifOptions and set its various properties including the Source property
                                                                                                                                                                                                                                                             Aspose.Imaging.ImageOptions.GifOptions gifOptions = new Aspose.Imaging.ImageOptions.GifOptions();
                                                                                                                                                                                                                                                             gifOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);

                                                                                                                                                                                                                                                             //Create an instance of Image
                                                                                                                                                                                                                                                             using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(gifOptions, 500, 500))
                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                 //Get the pixels of image by specifying the area as image boundary
                                                                                                                                                                                                                                                                 Aspose.Imaging.Color[] pixels = image.LoadPixels(image.Bounds);

                                                                                                                                                                                                                                                                 //Loop over the Array and sets color of alrenative indexed pixel
                                                                                                                                                                                                                                                                 for (int index = 0; index &lt; pixels.Length; index++)
                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                     if (index % 2 == 0)
                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                         //Set the indexed pixel color to yellow
                                                                                                                                                                                                                                                                         pixels[index] = Aspose.Imaging.Color.Yellow;
                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                     else
                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                         //Set the indexed pixel color to blue
                                                                                                                                                                                                                                                                         pixels[index] = Aspose.Imaging.Color.Blue;
                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                 }

                                                                                                                                                                                                                                                                 //Apply the pixel changes to the image
                                                                                                                                                                                                                                                                 image.SavePixels(image.Bounds, pixels);

                                                                                                                                                                                                                                                                 // save all changes.
                                                                                                                                                                                                                                                                 image.Save();
                                                                                                                                                                                                                                                             }

                                                                                                                                                                                                                                                             // Write MemoryStream to File
                                                                                                                                                                                                                                                             using (System.IO.FileStream fileStream = new System.IO.FileStream(@"C:\temp\output.gif", System.IO.FileMode.Create))
                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                 stream.WriteTo(fileStream);
                                                                                                                                                                                                                                                             }   
                                                                                                                                                                                                                                                         }

SaveRawData(byte[], int, Rectangle, RawDataSettings)

Ušetriť surové údaje.

public void SaveRawData(byte[] data, int dataOffset, Rectangle rectangle, RawDataSettings rawDataSettings)

Parameters

data byte []

a surových údajov.

dataOffset int

Začiatočné surové dáta odpočítavajú.

rectangle Rectangle

Pôvodný dátový rektangul.

rawDataSettings RawDataSettings

Surové údaje nastavenia, v ktorých sú údaje.

SetArgb32Pixel(int, int, int)

Nastaviť obrázok 32-bitový ARGB pixel pre špecifikovanú polohu.

public void SetArgb32Pixel(int x, int y, int argb32Color)

Parameters

x int

Poloha pixelov x.

y int

Pixel a umiestnenie.

argb32Color int

32-bitový pixel ARGB pre špecifikovanú polohu.

Examples

Nasledujúci príklad nahrá raster obrázok a nastaví farbu dobrovoľného pixel.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.png"))
                                                                                                {
                                                                                                    Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                    // Sets the color of the top-left pixel.
                                                                                                    rasterImage.SetArgb32Pixel(0, 0, Aspose.Imaging.Color.Aqua.ToArgb());

                                                                                                    // Another way is to pass an instance of the Aspose.Imaging.Color directly
                                                                                                    rasterImage.SetPixel(0, 0, Aspose.Imaging.Color.Aqua);
                                                                                                }

SetPalette(IkolorPalette, Boolová)

Vytvorte obrazovú paletu.

public override void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

Paleta na nastavenie.

updateColors bool

Ak je nastavený na “skutočné” farby budú aktualizované podľa novej palety; inak farebné indexy zostanú nezmenené.

SetPixel(int, int, farba)

Umiestnite obrázok pixel pre špecifikovanú polohu.

public void SetPixel(int x, int y, Color color)

Parameters

x int

Poloha pixelov x.

y int

Pixel a umiestnenie.

color Color

Farba pixelov pre špecifikovanú polohu.

Examples

Nasledujúci príklad nahrá raster obrázok a nastaví farbu dobrovoľného pixel.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.png"))
                                                                                                {
                                                                                                    Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                    // Sets the color of the top-left pixel.
                                                                                                    rasterImage.SetArgb32Pixel(0, 0, Aspose.Imaging.Color.Aqua.ToArgb());

                                                                                                    // Another way is to pass an instance of the Aspose.Imaging.Color directly
                                                                                                    rasterImage.SetPixel(0, 0, Aspose.Imaging.Color.Aqua);
                                                                                                }

SetResolution(dvojnásobný, dvojnásobný)

Nastaviť rozlíšenie pre tento Aspose.Imaging.RasterImage.

public virtual void SetResolution(double dpiX, double dpiY)

Parameters

dpiX double

Horizontálna rozlíšenie, v bodoch na palec, Aspose.Imaging.RasterImage.

dpiY double

Vertikálna rozlíšenie, v bodoch na palec, Aspose.Imaging.RasterImage.

Examples

Nasledujúci príklad ukazuje, ako nastaviť horizontálne/vertikálne rozlíšenie rasterového obrazu.

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

                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
                                                                                                   {
                                                                                                       Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;

                                                                                                       // Get horizontal and vertical resolution of the image
                                                                                                       double horizontalResolution = rasterImage.HorizontalResolution;
                                                                                                       double verticalResolution = rasterImage.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");
                                                                                                           rasterImage.SetResolution(96.0, 96.0);

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

                                                                                                       // The output may look like this:
                                                                                                       // The horizontal resolution, in pixels per inch: 300
                                                                                                       // The vertical resolution, in pixels per inch: 300
                                                                                                       // Set resolution values to 96 dpi
                                                                                                       // The horizontal resolution, in pixels per inch: 96
                                                                                                       // The vertical resolution, in pixels per inch: 96
                                                                                                   }

ToBitmap()

Konvertuje rasterový obrázok na bitmap.Táto metóda nie je podporovaná v verziách z .Net7.0 a vyššie

public virtual Bitmap ToBitmap()

Returns

Bitmap

Bitmap →

UpdateDimensions(a int, int)

Aktualizujte rozmery obrazu.

protected abstract void UpdateDimensions(int newWidth, int newHeight)

Parameters

newWidth int

Nový obrázok šírka.

newHeight int

Nová výška obrazu.

UpdateMetadata()

Aktualizácia obrazu metadata.

protected virtual void UpdateMetadata()

WriteArgb32ScanLine(a int, int[])

Napíšte celú skenovacie líniu na špecifikovaný index skenovacieho línie.

public void WriteArgb32ScanLine(int scanLineIndex, int[] argb32Pixels)

Parameters

scanLineIndex int

Zero-základný index skenovacieho riadku.

argb32Pixels int []

32-bitové farby ARGB sa pripravujú na písanie.

WriteScanLine(int, farba[])

Napíšte celú skenovacie líniu na špecifikovaný index skenovacieho línie.

public void WriteScanLine(int scanLineIndex, Color[] pixels)

Parameters

scanLineIndex int

Zero-základný index skenovacieho riadku.

pixels Color []

Pixelové farby sa pripravujú na písanie.

 Slovenčina