Class RasterImage

Class RasterImage

Nombre del espacio: Aspose.Imaging Asamblea: Aspose.Imaging.dll (25.4.0)

Representa una imagen raster que soporta las operaciones de gráficos raster.

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

Inheritance

object DisposableObject DataStreamSupporter Image RasterImage

Derived

RasterCachedImage

Implements

IDisposable ,y, IObjectWithBounds ,y, IRasterImageArgb32PixelLoader ,y, IRasterImageRawDataLoader ,y, IHasXmpData ,y, IHasMetadata

Miembros heredados

Image.CanLoad(string) ,y, Image.CanLoad(string, LoadOptions) ,y, Image.CanLoad(Stream) ,y, Image.CanLoad(Stream, LoadOptions) ,y, Image.Create(ImageOptionsBase, int, int) ,y, Image.Create(Image[]) ,y, Image.Create(MultipageCreateOptions) ,y, Image.Create(string[], bool) ,y, Image.Create(string[]) ,y, Image.Create(Image[], bool) ,y, Image.GetFileFormat(string) ,y, Image.GetFileFormat(Stream) ,y, Image.GetFittingRectangle(Rectangle, int, int) ,y, Image.GetFittingRectangle(Rectangle, int[], int, int) ,y, Image.Load(string, LoadOptions) ,y, Image.Load(string) ,y, Image.Load(Stream, LoadOptions) ,y, Image.Load(Stream) ,y, Image.GetProportionalWidth(int, int, int) ,y, Image.GetProportionalHeight(int, int, int) ,y, Image.RemoveMetadata() ,y, Image.CanSave(ImageOptionsBase) ,y, Image.Resize(int, int) ,y, Image.Resize(int, int, ResizeType) ,y, Image.Resize(int, int, ImageResizeSettings) ,y, Image.GetDefaultOptions(object[]) ,y, Image.GetOriginalOptions() ,y, Image.ResizeWidthProportionally(int) ,y, Image.ResizeHeightProportionally(int) ,y, Image.ResizeWidthProportionally(int, ResizeType) ,y, Image.ResizeHeightProportionally(int, ResizeType) ,y, Image.ResizeWidthProportionally(int, ImageResizeSettings) ,y, Image.ResizeHeightProportionally(int, ImageResizeSettings) ,y, Image.RotateFlip(RotateFlipType) ,y, Image.Rotate(float) ,y, Image.Crop(Rectangle) ,y, Image.Crop(int, int, int, int) ,y, Image.Save() ,y, Image.Save(string) ,y, Image.Save(string, ImageOptionsBase) ,y, Image.Save(string, ImageOptionsBase, Rectangle) ,y, Image.Save(Stream, ImageOptionsBase) ,y, Image.Save(Stream, ImageOptionsBase, Rectangle) ,y, Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) ,y, Image.SetPalette(IColorPalette, bool) ,y, Image.UpdateContainer(Image) ,y, Image.GetCanNotSaveMessage(ImageOptionsBase) ,y, Image.GetFitRectangle(Rectangle) ,y, Image.GetImage2Export(ImageOptionsBase, Rectangle, IImageExporter) ,y, Image.GetFitRectangle(Rectangle, int[]) ,y, Image.OnPaletteChanged(IColorPalette, IColorPalette) ,y, Image.OnPaletteChanging(IColorPalette, IColorPalette) ,y, Image.ReleaseManagedResources() ,y, Image.BitsPerPixel ,y, Image.Bounds ,y, Image.Container ,y, Image.Height ,y, Image.Palette ,y, Image.UsePalette ,y, Image.Size ,y, Image.Width ,y, Image.InterruptMonitor ,y, Image.BufferSizeHint ,y, Image.AutoAdjustPalette ,y, Image.HasBackgroundColor ,y, Image.FileFormat ,y, Image.BackgroundColor ,y, DataStreamSupporter.timeout ,y, DataStreamSupporter.CacheData() ,y, DataStreamSupporter.Save() ,y, DataStreamSupporter.Save(Stream) ,y, DataStreamSupporter.Save(string) ,y, DataStreamSupporter.Save(string, bool) ,y, DataStreamSupporter.SaveData(Stream) ,y, DataStreamSupporter.ReleaseManagedResources() ,y, DataStreamSupporter.OnDataStreamContainerChanging(StreamContainer) ,y, DataStreamSupporter.DataStreamContainer ,y, DataStreamSupporter.IsCached ,y, DisposableObject.Dispose() ,y, DisposableObject.ReleaseManagedResources() ,y, DisposableObject.ReleaseUnmanagedResources() ,y, DisposableObject.VerifyNotDisposed() ,y, DisposableObject.Disposed ,y, object.GetType() ,y, object.MemberwiseClone() ,y, object.ToString() ,y, object.Equals(object?) ,y, object.Equals(object?, object?) ,y, object.ReferenceEquals(object?, object?) ,y, object.GetHashCode()

Examples

Este ejemplo muestra cómo cargar la información de Pixel en un Array de tipo de color, manipula el array y la ponga de vuelta a la imagen. Para realizar estas operaciones, este ejemplo crea un nuevo archivo de imagen (en formato GIF) uisng Objeto MemoryStream.

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

Inicia una nueva instancia de la clase Aspose.Imaging.RasterImage.

[JsonConstructor]
protected RasterImage()

RasterImage(ICOLORPALETA)

Inicia una nueva instancia de la clase Aspose.Imaging.RasterImage.

protected RasterImage(IColorPalette colorPalette)

Parameters

colorPalette IColorPalette

La paleta de colores.

Fields

xmpData

Los metadatos de XMP

[JsonProperty]
protected XmpPacketWrapper xmpData

Valor de campo

XmpPacketWrapper

Properties

DataLoader

Obtenga o coloca el cargador de datos.

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

Valor de la propiedad

IRasterImageArgb32PixelLoader

HasAlpha

Recibe un valor que indica si esta instancia tiene alfa.

public virtual bool HasAlpha { get; }

Valor de la propiedad

bool

Examples

El siguiente ejemplo carga imágenes de raster y imprime información sobre el formato de datos crudos y el canal alfa.

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

El siguiente ejemplo muestra cómo extraer información sobre el formato de datos crudos y el canal alfa de una imagen 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

Recibe un valor que indica si la imagen tiene color transparente.

public virtual bool HasTransparentColor { get; set; }

Valor de la propiedad

bool

HorizontalResolution

Obtenga o establece la resolución horizontal, en píxeles por pulgón, de este Aspose.Imaging.RasterImage.

public virtual double HorizontalResolution { get; set; }

Valor de la propiedad

double

Examples

El siguiente ejemplo muestra cómo configurar la resolución horizontal/vertical de una imagen de raster.

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

Nota por defecto este valor es siempre 96 ya que las diferentes plataformas no pueden devolver la resolución de la pantalla. Puede considerar utilizar el método SetResolution para actualizar ambos valores de resolución en una sola llamada.

ImageOpacity

Obtenga la opacidad de esta imagen.

public virtual float ImageOpacity { get; }

Valor de la propiedad

float

IsRawDataAvailable

Recibe un valor que indica si la carga de datos crudos está disponible.

public bool IsRawDataAvailable { get; }

Valor de la propiedad

bool

PremultiplyComponents

Obtenga o establece un valor que indique si los componentes de la imagen deben ser prematuriados.

public virtual bool PremultiplyComponents { get; set; }

Valor de la propiedad

bool

Examples

El siguiente ejemplo crea una nueva imagen de raster, salva los píxeles semi-transparentes especificados, luego carga esos píxeles y obtiene los colores finales en la forma prematura.

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

Obtenga o establece el convertidor de color personalizado

public IColorConverter RawCustomColorConverter { get; set; }

Valor de la propiedad

IColorConverter

RawDataFormat

Obtenga el formato de datos crudos.

public virtual PixelDataFormat RawDataFormat { get; }

Valor de la propiedad

PixelDataFormat

Examples

El siguiente ejemplo carga imágenes de raster y imprime información sobre el formato de datos crudos y el canal alfa.

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

Este ejemplo muestra cómo cargar una imagen DJVU de un flujo de archivos y imprimir información sobre las páginas.

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

Obtenga las configuraciones de datos crudos actuales. Nota cuando se utilizan estas configuraciones los datos cargan sin conversión.

[JsonIgnore]
public RawDataSettings RawDataSettings { get; }

Valor de la propiedad

RawDataSettings

RawFallbackIndex

Obtenga o establece el índice fallback para usar cuando el índice de paleta está fuera de los límites

public int RawFallbackIndex { get; set; }

Valor de la propiedad

int

RawIndexedColorConverter

Obtenga o establece el convertidor de color indexado

public IIndexedColorConverter RawIndexedColorConverter { get; set; }

Valor de la propiedad

IIndexedColorConverter

RawLineSize

Obtenga el tamaño de la línea cruda en bytes.

public virtual int RawLineSize { get; }

Valor de la propiedad

int

TransparentColor

Obtenga el color transparente de la imagen.

public virtual Color TransparentColor { get; set; }

Valor de la propiedad

Color

UpdateXmpData

Obtenga o establece un valor que indica si actualizar los metadatos de XMP.

public virtual bool UpdateXmpData { get; set; }

Valor de la propiedad

bool

UsePalette

Recibe un valor que indica si se utiliza la paleta de imagen.

public override bool UsePalette { get; }

Valor de la propiedad

bool

UseRawData

Recibe o establece un valor que indica si utilizar la carga de datos crudos cuando la carga de datos crudos está disponible.

public virtual bool UseRawData { get; set; }

Valor de la propiedad

bool

VerticalResolution

Obtenga o establece la resolución vertical, en píxeles por pulgón, de este Aspose.Imaging.RasterImage.

public virtual double VerticalResolution { get; set; }

Valor de la propiedad

double

Examples

El siguiente ejemplo muestra cómo configurar la resolución horizontal/vertical de una imagen de raster.

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

Nota por defecto este valor es siempre 96 ya que las diferentes plataformas no pueden devolver la resolución de la pantalla. Puede considerar utilizar el método SetResolution para actualizar ambos valores de resolución en una sola llamada.

XmpData

Obtenga o establece los metadatos XMP.

public virtual XmpPacketWrapper XmpData { get; set; }

Valor de la propiedad

XmpPacketWrapper

Methods

AdjustBrightness(Int)

Ajuste de un brillo para la imagen.

public virtual void AdjustBrightness(int brightness)

Parameters

brightness int

Valor de brillo.

Examples

El siguiente ejemplo realiza la corrección de brillo de una imagen.

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(float)

Imagen Contrast

public virtual void AdjustContrast(float contrast)

Parameters

contrast float

Valor de contraste (en rango [-100; 100])

Examples

El siguiente ejemplo realiza una corrección de contraste de una imagen.

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(float, float y float)

Corrección de Gamma de una imagen.

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

Parameters

gammaRed float

Gamma para el coeficiente de canal rojo

gammaGreen float

Gamma para el coeficiente de canal verde

gammaBlue float

Gamma para el coeficiente de canal azul

Examples

El siguiente ejemplo realiza la corrección gamma de una imagen aplicando coeficientes diferentes para los componentes de color.

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(float)

Corrección de Gamma de una imagen.

public virtual void AdjustGamma(float gamma)

Parameters

gamma float

Gamma para los canales rojo, verde y azul coeficiente

Examples

El siguiente ejemplo realiza una corrección gamma de una imagen.

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(doble)

Binarización de una imagen utilizando el algoritmo de límite adaptativo de Bradley utilizando el límite de imagen integral

public virtual void BinarizeBradley(double brightnessDifference)

Parameters

brightnessDifference double

La diferencia de brillo entre el pixel y la media de una ventana s x s de píxeles centrados alrededor de este pixel.

BinarizeBradley(El doble, int)

Binarización de una imagen utilizando el algoritmo de límite adaptativo de Bradley utilizando el límite de imagen integral

public virtual void BinarizeBradley(double brightnessDifference, int windowSize)

Parameters

brightnessDifference double

La diferencia de brillo entre el pixel y la media de una ventana s x s de píxeles centrados alrededor de este pixel.

windowSize int

El tamaño de la ventana s x s de los píxeles centrados alrededor de este píxel

Examples

El siguiente ejemplo binariza una imagen de raster con el algoritmo adaptativo de Bradley con el tamaño de la ventana especificada. imágenes binarias contienen sólo 2 colores - negro y blanco.

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(El byte)

Binarización de una imagen con un límite predefinido

public virtual void BinarizeFixed(byte threshold)

Parameters

threshold byte

Si el valor gris correspondiente de un pixel es mayor que el límite, se le asignará un valor de 255, 0 de otra manera.

Examples

El siguiente ejemplo binariza una imagen de raster con el límite predefinido. imágenes binarias contienen sólo 2 colores - negro y blanco.

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()

Binarización de una imagen con el límite de Otsu

public virtual void BinarizeOtsu()

Examples

El siguiente ejemplo binariza una imagen de raster con el límite de Otsu. imágenes binarias contienen sólo 2 colores - negro y blanco.

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(Punto, RasterImage, Rectangle, byte)

Mezcla esta imagen con la imagen overlay.

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

Parameters

origin Point

La imagen de fondo mezcla de origen.

overlay RasterImage

La imagen superficial.

overlayArea Rectangle

La zona de sobrecarga.

overlayAlpha byte

El alfa superficial.

Blend(Punto, RasterImage, byte)

Mezcla esta imagen con la imagen overlay.

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

Parameters

origin Point

La imagen de fondo mezcla de origen.

overlay RasterImage

La imagen superficial.

overlayAlpha byte

El alfa superficial.

Dither(El método, int)

Los resultados se reflejan en la imagen actual.

public void Dither(DitheringMethod ditheringMethod, int bitsCount)

Parameters

ditheringMethod DitheringMethod

El método de difusión.

bitsCount int

Los últimos bits cuentan para diitar.

Examples

El siguiente ejemplo carga una imagen de raster y realiza el límite y el fluido de dithering utilizando diferentes profundidades de paleta.

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(DitheringMétodo, int, IColorPalette)

Los resultados se reflejan en la imagen actual.

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

Parameters

ditheringMethod DitheringMethod

El método de difusión.

bitsCount int

Los últimos bits cuentan para diitar.

customPalette IColorPalette

La paleta personalizada para la difusión.

Filter(Rectangle, FilterOptionsBase)

Filtra el rectángulo especificado.

public virtual void Filter(Rectangle rectangle, FilterOptionsBase options)

Parameters

rectangle Rectangle

El rectángulo.

options FilterOptionsBase

Las opciones.

Examples

El siguiente ejemplo aplica varios tipos de filtros a una imagen de raster.

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

Recibe una imagen de 32 bits de ARGB.

public int GetArgb32Pixel(int x, int y)

Parameters

x int

La ubicación del pixel x.

y int

El pixel y la ubicación.

Returns

int

El píxel ARGB de 32 bits para la ubicación especificada.

Examples

El siguiente ejemplo carga una imagen de raster y obtiene el color de un pixel arbitrario representado como un valor integral de 32 bits.

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);
                                                                                                                                        }

El siguiente ejemplo muestra cómo el caching de imágenes afecta el rendimiento.En general, la lectura de los datos cache se realiza más rápido que la lectura de los datos no cache.

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)

Recibe el array de píxeles ARGB de 32 bits.

public int[] GetDefaultArgb32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

El rectángulo para obtener píxeles.

Returns

int [][]

Los píxeles están array.

GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader)

Obtenga los píxeles por defecto array utilizando un cargador de píxeles parciales.

public void GetDefaultPixels(Rectangle rectangle, IPartialArgb32PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

El rectángulo para obtener píxeles.

partialPixelLoader IPartialArgb32PixelLoader

El cargador de píxeles parcial.

GetDefaultRawData(Rectangle, IPartialRawDataLoader y RawDataSettings)

Obtenga la arregla de datos crudos por defecto utilizando un cargador de píxeles parciales.

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

Parameters

rectangle Rectangle

El rectángulo para obtener píxeles.

partialRawDataLoader IPartialRawDataLoader

El cargador parcial de datos crudos.

rawDataSettings RawDataSettings

La configuración de los datos crudos.

GetDefaultRawData(Rectangle y RawDataSettings)

Recibe el array de datos crudos predeterminados.

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

Parameters

rectangle Rectangle

El rectángulo para obtener datos crudos.

rawDataSettings RawDataSettings

La configuración de los datos crudos.

Returns

byte [][]

El array de datos crudos defectuosos.

GetModifyDate(BOOL)

Recibe la fecha y hora en que la imagen de la fuente fue modificada por última vez.

public virtual DateTime GetModifyDate(bool useDefault)

Parameters

useDefault bool

si se establece a ‘verdad’ utiliza la información de FileInfo como valor predeterminado.

Returns

DateTime

La fecha y hora de la imagen de la fuente fue modificada por última vez.

GetPixel(El int, int)

Obtendrá un pixel de imagen.

public Color GetPixel(int x, int y)

Parameters

x int

La ubicación del pixel x.

y int

El pixel y la ubicación.

Returns

Color

El color del pixel para la ubicación especificada.

Examples

El siguiente ejemplo carga una imagen de raster y obtiene el color de un pixel arbitrario.

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()

Tiene el ángulo de escudo.Este método se aplica a los documentos de texto escaneados, para determinar el ángulo de escaneamiento al escanear.

public float GetSkewAngle()

Returns

float

El ángulo escudo, en grados.

Grayscale()

Transformación de una imagen en su representación griega

public virtual void Grayscale()

Examples

El siguiente ejemplo transforma una imagen de raster colorida en su representación de grayscale. las imágenes de grayscale se componen exclusivamente de sombras de gris y solo llevan información de intensidad.

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)

Carga de 32 bits de píxeles ARGB.

public int[] LoadArgb32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

El rectángulo para cargar píxeles de.

Returns

int [][]

El array de píxeles ARGB de 32 bits.

Examples

El siguiente ejemplo muestra cómo cargar y procesar los píxeles de una imagen raster. Los píxeles se representan como valores integrales de 32 bits. Por ejemplo, considere un problema de contar los píxeles totalmente transparentes de una imagen.

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)

Carga 64 bits de píxeles ARGB.

public long[] LoadArgb64Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

El rectángulo para cargar píxeles de.

Returns

long [][]

El array de píxeles ARGB de 64 bits.

Examples

El siguiente ejemplo muestra cómo cargar y procesar los píxeles de una imagen raster. Los píxeles se representan como valores integrales de 64 bits. Por ejemplo, considere un problema de contar los píxeles totalmente transparentes de una imagen.

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)

Carga píxeles en formato CMYK.

public int[] LoadCmyk32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

El rectángulo para cargar píxeles de.

Returns

int [][]

Los píxeles CMYK cargados se presentan como valores inateger de 32 bits.

LoadCmykPixels(Rectangle)

Carga píxeles en formato CMYK.Por favor, utilice más eficazmente el método Aspose.Imaging.RasterImage.LoadCmyk32Pixels(Aspose.Imaging.Rectangle.

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

Parameters

rectangle Rectangle

El rectángulo para cargar píxeles de.

Returns

CmykColor [][]

La carga de los píxeles CMYK.

LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader)

Carga los píxeles ARGB de 32 bits parcialmente por paquetes.

public void LoadPartialArgb32Pixels(Rectangle rectangle, IPartialArgb32PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

El rectángulo deseado.

partialPixelLoader IPartialArgb32PixelLoader

El cargador de píxeles ARGB de 32 bits.

Examples

El siguiente ejemplo muestra cómo cargar y procesar los píxeles de una imagen raster utilizando su propio procesador parcial. Por ejemplo, considerar un problema de contar los píxeles totalmente transparentes de una imagen. Para contar los píxeles transparentes utilizando el mecanismo de carga parcial, se introduce una clase separada TransparentArgb32PixelCounter implementando 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(Rectangle, IPartialArgb64PixelLoader)

Carga 64 bits de píxeles ARGB parcialmente por paquetes.

public void LoadPartialArgb64Pixels(Rectangle rectangle, IPartialArgb64PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

El rectángulo deseado.

partialPixelLoader IPartialArgb64PixelLoader

El cargador de píxeles ARGB de 64 bits.

LoadPartialPixels(Rectangle y IPartialPixelLoader)

Carga los píxeles parcialmente por paquetes.

public void LoadPartialPixels(Rectangle desiredRectangle, IPartialPixelLoader pixelLoader)

Parameters

desiredRectangle Rectangle

El rectángulo deseado.

pixelLoader IPartialPixelLoader

El cargador de pixel.

Examples

El siguiente ejemplo muestra cómo cargar y procesar los píxeles de una imagen raster utilizando su propio procesador parcial. Por ejemplo, considerar un problema de contar los píxeles totalmente transparentes de una imagen. Para contar transparentemente utilizando el mecanismo de carga parcial, se introduce una clase separada TransparentPixelCounter implementando Aspose.Imaging.IPartialPixelLoader.

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)

Carga de píxeles.

public Color[] LoadPixels(Rectangle rectangle)

Parameters

rectangle Rectangle

El rectángulo para cargar píxeles de.

Returns

Color [][]

Los píxeles cargados array.

Examples

El siguiente ejemplo muestra cómo cargar y procesar los píxeles de una imagen raster. Por ejemplo, considere un problema de contar los píxeles totalmente transparentes de una imagen.

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);
                                                                                                                                                                             }

Este ejemplo muestra cómo cargar la información de Pixel en un Array de tipo de color, manipula el array y la ponga de vuelta a la imagen. Para realizar estas operaciones, este ejemplo crea un nuevo archivo de imagen (en formato GIF) uisng Objeto MemoryStream.

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

Carga de datos crudos.

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

Parameters

rectangle Rectangle

El rectángulo para cargar datos crudos de.

rawDataSettings RawDataSettings

Las configuraciones de datos crudos para utilizar para los datos cargados. Nota si los datos no están en el formato especificado, entonces se realizará la conversión de datos.

rawDataLoader IPartialRawDataLoader

El cargador de datos crudo.

Examples

El siguiente ejemplo muestra cómo extraer píxeles de los datos de la imagen cruda utilizando RawDataSettings. Por ejemplo, considere un problema de contar píxeles completamente transparentes de una imagen.

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)

Carga de datos crudos.

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

Parameters

rectangle Rectangle

El rectángulo para cargar datos crudos de.

destImageBounds Rectangle

Los límites de la imagen.

rawDataSettings RawDataSettings

Las configuraciones de datos crudos para utilizar para los datos cargados. Nota si los datos no están en el formato especificado, entonces se realizará la conversión de datos.

rawDataLoader IPartialRawDataLoader

El cargador de datos crudo.

NormalizeAngle()

Normalizar el ángulo.Este método se aplica a los documentos de texto escaneados para deshacerse de la escaneada escaneada.Este método utiliza los métodos Aspose.Imaging.RasterImage.GetSkewAngle y Aspose.Imaging.RasterImage.Rotate(System.Single.

public void NormalizeAngle()

NormalizeAngle(Cuerpo, color)

Normalizar el ángulo.Este método se aplica a los documentos de texto escaneados para deshacerse de la escaneada escaneada.Este método utiliza los métodos Aspose.Imaging.RasterImage.GetSkewAngle y Aspose.Imaging.RasterImage.Rotate(System.Single,System.Boolean,Aspose.Imaging.Color.

public virtual void NormalizeAngle(bool resizeProportionally, Color backgroundColor)

Parameters

resizeProportionally bool

si se establece a ‘verdad’ tendrás su tamaño de imagen cambiado de acuerdo con las proyecciones rectangulares rotadas (puntos de esquina) en otro caso que deja las dimensiones no tocadas y sólo los contenidos de la imagen interna son rotados.

backgroundColor Color

El color del fondo.

Examples

Skew es un artefato que puede aparecer durante el proceso de escaneamiento de documentos cuando el texto/imágenes del documento se vuelven en un ángulo ligero. Puede tener varias causas pero lo más común es que el papel se mueve mal durante un escaneo. Por lo tanto, deskew es el proceso de detectar y corregir este problema en los archivos escaneados (es decir, bitmap) para que los documentos deskeados tengan el texto/imágenes correctamente y horizontalmente ajustados.

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()

Normalizar el histograma de la imagen — ajustar los valores de píxeles para utilizar todos los intervalos disponibles.

public virtual void NormalizeHistogram()

ReadArgb32ScanLine(Int)

Lea toda la línea de escaneo por el índice de la línea de escaneo especificado.

public int[] ReadArgb32ScanLine(int scanLineIndex)

Parameters

scanLineIndex int

ndice basado en cero de la línea de escaneo.

Returns

int [][]

La línea de escaneo de 32 bits ARGB valores de color array.

ReadScanLine(Int)

Lea toda la línea de escaneo por el índice de la línea de escaneo especificado.

public Color[] ReadScanLine(int scanLineIndex)

Parameters

scanLineIndex int

ndice basado en cero de la línea de escaneo.

Returns

Color [][]

La línea de escaneo de los valores de color de los píxeles.

ReleaseManagedResources()

Asegúrese de que los recursos no gestionados no se liberan aquí, ya que pueden haber sido ya liberados.

protected override void ReleaseManagedResources()

RemoveMetadata()

Elimina estos metadatos de instancia de la imagen al configurar este Aspose.Imaging.Xmp.IHasXMPData. Nula.

public override void RemoveMetadata()

ReplaceColor(Color, byte y color)

Reemplaza una color por otra con la diferencia permitida y conserva el valor alfa original para ahorrar lados suaves.

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

Parameters

oldColor Color

El color antiguo debe ser reemplazado.

oldColorDiff byte

Permite la diferencia en el color antiguo para poder ampliar el tono de color sustituido.

newColor Color

Nuevo color para reemplazar el color antiguo.

ReplaceColor(Int, byte y int)

Reemplaza una color por otra con la diferencia permitida y conserva el valor alfa original para ahorrar lados suaves.

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

Parameters

oldColorArgb int

El antiguo color ARGB será reemplazado.

oldColorDiff byte

Permite la diferencia en el color antiguo para poder ampliar el tono de color sustituido.

newColorArgb int

Nuevo valor de color ARGB para reemplazar el color antiguo.

ReplaceNonTransparentColors(Color)

Reemplaza todos los colores no transparentes con un nuevo color y conserva el valor alfa original para ahorrar lados suaves.Nota: si lo usa en imágenes sin transparencia, todos los colores serán reemplazados por un único.

public void ReplaceNonTransparentColors(Color newColor)

Parameters

newColor Color

Nuevo color para reemplazar con colores no transparentes.

ReplaceNonTransparentColors(Int)

Reemplaza todos los colores no transparentes con un nuevo color y conserva el valor alfa original para ahorrar lados suaves.Nota: si lo usa en imágenes sin transparencia, todos los colores serán reemplazados por un único.

public virtual void ReplaceNonTransparentColors(int newColorArgb)

Parameters

newColorArgb int

Nuevo valor de color ARGB para reemplazar los colores no transparentes con.

Resize(int, int, ImageResizeSettings)

Recupera la imagen con opciones ampliadas.

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

Parameters

newWidth int

La nueva amplitud.

newHeight int

La nueva altura.

settings ImageResizeSettings

los ajustes de residuos.

Examples

Este ejemplo carga una imagen de raster y la resisa utilizando diferentes configuraciones de resisación.

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, color)

Imagen rotativa alrededor del centro.

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

Parameters

angle float

El ángulo de rotación en grados. valores positivos rotarán de manera horaria.

resizeProportionally bool

si se establece a ‘verdad’ tendrás su tamaño de imagen cambiado de acuerdo con las proyecciones rectangulares rotadas (puntos de esquina) en otro caso que deja las dimensiones no tocadas y sólo los contenidos de la imagen interna son rotados.

backgroundColor Color

El color del fondo.

Exceptions

NotImplementedException

Excepción no aplicada

Rotate(float)

Imagen rotativa alrededor del centro.

public override void Rotate(float angle)

Parameters

angle float

El ángulo de rotación en grados. valores positivos rotarán de manera horaria.

Save(El flujo, ImageOptionsBase, Rectangle)

Salva los datos de la imagen a la corriente especificada en el formato de archivo especificado según las opciones de almacenamiento.

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

Parameters

stream Stream

El flujo para salvar los datos de la imagen a.

optionsBase ImageOptionsBase

Las opciones de ahorro.

boundsRectangle Rectangle

La imagen de destino limita el rectángulo. Configure el rectángulo vacío para utilizar los límites de fuente.

SaveArgb32Pixels(El rectángulo, int[])

Conserva los píxeles ARGB 32 bits.

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

Parameters

rectangle Rectangle

El rectángulo para salvar los píxeles a.

pixels int [][]

El 32 bits ARGB pixels array.

Examples

El siguiente ejemplo llena la zona central de una imagen de raster con píxeles negros utilizando el método 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(El rectángulo, int[])

Salva los píxeles.

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

Parameters

rectangle Rectangle

El rectángulo para salvar los píxeles a.

pixels int [][]

Los píxeles CMYK presentados como los valores integrales de 32 bits.

Examples

El siguiente ejemplo llena la zona central de una imagen de raster con píxeles negros utilizando el método 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(Rectangle y CmykColor[])

Salva los píxeles.Por favor, use más eficaz el método Aspose.Imaging.RasterImage.SaveCmyk32Pixels(Aspose.Imaging.Rectangle,System.Int32.

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

Parameters

rectangle Rectangle

El rectángulo para salvar los píxeles a.

pixels CmykColor [][]

Los píxeles CMYK se arreglan.

SavePixels(Rectangle, color[])

Salva los píxeles.

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

Parameters

rectangle Rectangle

El rectángulo para salvar los píxeles a.

pixels Color [][]

Los píxeles se arreglan.

Examples

El siguiente ejemplo llena la zona central de una imagen de raster con píxeles negros utilizando el método 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");
                                                                                                                                                   }

Este ejemplo muestra cómo cargar la información de Pixel en un Array de tipo de color, manipula el array y la ponga de vuelta a la imagen. Para realizar estas operaciones, este ejemplo crea un nuevo archivo de imagen (en formato GIF) uisng Objeto MemoryStream.

//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(El byte[][], int, Rectangle, RawDataSettings)

Ahorra los datos crudos.

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

Parameters

data byte [][]

Los datos crudos.

dataOffset int

Los datos primos de comienzo se desembolsan.

rectangle Rectangle

El rectángulo de los datos crudos.

rawDataSettings RawDataSettings

Los datos crudos establecen los datos que se encuentran en.

SetArgb32Pixel(Int, int, int)

Establece un pictograma de imagen de 32 bits ARGB para la posición especificada.

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

Parameters

x int

La ubicación del pixel x.

y int

El pixel y la ubicación.

argb32Color int

El píxel ARGB de 32 bits para la posición especificada.

Examples

El siguiente ejemplo carga una imagen raster, y establece el color de un pixel arbitrario.

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(Página web, bool)

Coloca la paleta de imagen.

public override void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

La paleta se establece.

updateColors bool

si se ha ajustado a los colores ‘verdaderos’ se actualizará de acuerdo con la nueva paleta; de lo contrario, los índices de color permanecerán inalterados.Tenga en cuenta que los índices inalterados pueden romper la imagen en carga si algunos índices no tienen entradas de paleta correspondientes.

SetPixel(int, int, color)

Establecer un pixel de imagen para la posición especificada.

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

Parameters

x int

La ubicación del pixel x.

y int

El pixel y la ubicación.

color Color

El color del pixel para la posición especificada.

Examples

El siguiente ejemplo carga una imagen raster, y establece el color de un pixel arbitrario.

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(doble, doble)

Establece la resolución para este Aspose.Imaging.RasterImage.

public virtual void SetResolution(double dpiX, double dpiY)

Parameters

dpiX double

La resolución horizontal, en puntos por pulgón, del Aspose.Imaging.RasterImage.

dpiY double

La resolución vertical, en puntos por pulgón, del Aspose.Imaging.RasterImage.

Examples

El siguiente ejemplo muestra cómo configurar la resolución horizontal/vertical de una imagen de raster.

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()

Convertir la imagen de raster en el bitmap.Este método no está soportado en versiones de .Net7.0 y superiores

public virtual Bitmap ToBitmap()

Returns

Bitmap

El bitmap

UpdateDimensions(El int, int)

Actualizar las dimensiones de la imagen.

protected abstract void UpdateDimensions(int newWidth, int newHeight)

Parameters

newWidth int

La nueva imagen es amplia.

newHeight int

El nuevo tamaño de la imagen.

UpdateMetadata()

Actualizar los metadatos de la imagen.

protected virtual void UpdateMetadata()

WriteArgb32ScanLine(El int, int[])

Escribe toda la línea de escaneo al índice de la línea de escaneo especificada.

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

Parameters

scanLineIndex int

ndice basado en cero de la línea de escaneo.

argb32Pixels int [][]

Los colores de 32 bits ARGB se ajustan a escribir.

WriteScanLine(El color, color[])

Escribe toda la línea de escaneo al índice de la línea de escaneo especificada.

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

Parameters

scanLineIndex int

ndice basado en cero de la línea de escaneo.

pixels Color [][]

Los colores de los píxeles están listos para escribir.

 Español