Class RasterImage

Class RasterImage

Namespace: Aspose.Imaging
Assembly: Aspose.Imaging.dll (25.2.0)

Represents a raster image supporting raster graphics operations.

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

Inheritance

objectDisposableObjectDataStreamSupporterImageRasterImage

Derived

RasterCachedImage

Implements

IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata

Inherited Members

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

Examples

This example shows how to Loads Pixel information in an Array of Type Color, manipulates the array and set it back to the image. To perform these operations, this example creates a new Image file (in GIF format) uisng MemoryStream object.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage__ctor"></a> RasterImage\(\)

Initializes a new instance of the Aspose.Imaging.RasterImage class.

```csharp
[JsonConstructor]
protected RasterImage()

RasterImage(IColorPalette)

Initializes a new instance of the Aspose.Imaging.RasterImage class.

protected RasterImage(IColorPalette colorPalette)

Parameters

colorPalette IColorPalette

The color palette.

Fields

xmpData

The XMP metadata

[JsonProperty]
protected XmpPacketWrapper xmpData

Field Value

XmpPacketWrapper

Properties

DataLoader

Gets or sets the data loader.

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

Property Value

IRasterImageArgb32PixelLoader

HasAlpha

Gets a value indicating whether this instance has alpha.

public virtual bool HasAlpha { get; }

Property Value

bool

Examples

The following example loads raster images and prints information about raw data format and alpha channel.```csharp [C#]

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

The following example shows how to extract information about raw data format and alpha channel from a BMP image.```csharp
[C#]

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

Gets a value indicating whether image has transparent color.

public virtual bool HasTransparentColor { get; set; }

Property Value

bool

HorizontalResolution

Gets or sets the horizontal resolution, in pixels per inch, of this Aspose.Imaging.RasterImage.

public virtual double HorizontalResolution { get; set; }

Property Value

double

Examples

The following example shows how to set horizontal/vertical resolution of a raster image.```csharp [C#]

                                                                                               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

Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.

### <a id="Aspose_Imaging_RasterImage_ImageOpacity"></a> ImageOpacity

Gets opacity of this image.

```csharp
public virtual float ImageOpacity { get; }

Property Value

float

IsRawDataAvailable

Gets a value indicating whether raw data loading is available.

public bool IsRawDataAvailable { get; }

Property Value

bool

PremultiplyComponents

Gets or sets a value indicating whether the image components must be premultiplied.

public virtual bool PremultiplyComponents { get; set; }

Property Value

bool

Examples

The following example creates a new raster image, saves the specified semi-transparent pixels, then loads those pixels and gets final colors in the premultiplied form.```csharp [C#]

                                                                                                                                                                              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 &lt; colors.Length; i++)
                                                                                                                                                                                  {
                                                                                                                                                                                      System.Console.WriteLine("Original color: {0}", colors[i].ToString());
                                                                                                                                                                                      System.Console.WriteLine("Premultiplied color: {0}", premultipliedColors[i].ToString());
                                                                                                                                                                                  }
                                                                                                                                                                              }

### <a id="Aspose_Imaging_RasterImage_RawCustomColorConverter"></a> RawCustomColorConverter

Gets or sets the custom color converter

```csharp
public IColorConverter RawCustomColorConverter { get; set; }

Property Value

IColorConverter

RawDataFormat

Gets the raw data format.

public virtual PixelDataFormat RawDataFormat { get; }

Property Value

PixelDataFormat

Examples

The following example loads raster images and prints information about raw data format and alpha channel.```csharp [C#]

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

This example shows how to load a DJVU image from a file stream and print information about the pages.```csharp
[C#]

                                                                                                                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

Gets the current raw data settings. Note when using these settings the data loads without conversion.

[JsonIgnore]
public RawDataSettings RawDataSettings { get; }

Property Value

RawDataSettings

RawFallbackIndex

Gets or sets the fallback index to use when palette index is out of bounds

public int RawFallbackIndex { get; set; }

Property Value

int

RawIndexedColorConverter

Gets or sets the indexed color converter

public IIndexedColorConverter RawIndexedColorConverter { get; set; }

Property Value

IIndexedColorConverter

RawLineSize

Gets the raw line size in bytes.

public virtual int RawLineSize { get; }

Property Value

int

TransparentColor

Gets the image transparent color.

public virtual Color TransparentColor { get; set; }

Property Value

Color

UpdateXmpData

Gets or sets a value indicating whether to update the XMP metadata.

public virtual bool UpdateXmpData { get; set; }

Property Value

bool

UsePalette

Gets a value indicating whether the image palette is used.

public override bool UsePalette { get; }

Property Value

bool

UseRawData

Gets or sets a value indicating whether to use raw data loading when the raw data loading is available.

public virtual bool UseRawData { get; set; }

Property Value

bool

VerticalResolution

Gets or sets the vertical resolution, in pixels per inch, of this Aspose.Imaging.RasterImage.

public virtual double VerticalResolution { get; set; }

Property Value

double

Examples

The following example shows how to set horizontal/vertical resolution of a raster image.```csharp [C#]

                                                                                               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

Note by default this value is always 96 since different platforms cannot return the screen resolution. You may consider using the SetResolution method for updating both resolution values in single call.

### <a id="Aspose_Imaging_RasterImage_XmpData"></a> XmpData

Gets or sets the XMP metadata.

```csharp
public virtual XmpPacketWrapper XmpData { get; set; }

Property Value

XmpPacketWrapper

Methods

AdjustBrightness(int)

Adjust of a brightness for image.

public virtual void AdjustBrightness(int brightness)

Parameters

brightness int

Brightness value.

Examples

The following example performs brightness correction of an image.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_AdjustContrast_System_Single_"></a> AdjustContrast\(float\)

Image contrasting

```csharp
public virtual void AdjustContrast(float contrast)

Parameters

contrast float

Contrast value (in range [-100; 100])

Examples

The following example performs contrast correction of an image.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_AdjustGamma_System_Single_System_Single_System_Single_"></a> AdjustGamma\(float, float, float\)

Gamma-correction of an image.

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

Parameters

gammaRed float

Gamma for red channel coefficient

gammaGreen float

Gamma for green channel coefficient

gammaBlue float

Gamma for blue channel coefficient

Examples

The following example performs gamma-correction of an image applying different coefficients for color components.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_AdjustGamma_System_Single_"></a> AdjustGamma\(float\)

Gamma-correction of an image.

```csharp
public virtual void AdjustGamma(float gamma)

Parameters

gamma float

Gamma for red, green and blue channels coefficient

Examples

The following example performs gamma-correction of an image.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_BinarizeBradley_System_Double_"></a> BinarizeBradley\(double\)

Binarization of an image using Bradley's adaptive thresholding algorithm using the integral image thresholding

```csharp
public virtual void BinarizeBradley(double brightnessDifference)

Parameters

brightnessDifference double

The brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.

BinarizeBradley(double, int)

Binarization of an image using Bradley’s adaptive thresholding algorithm using the integral image thresholding

public virtual void BinarizeBradley(double brightnessDifference, int windowSize)

Parameters

brightnessDifference double

The brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.

windowSize int

The size of s x s window of pixels centered around this pixel

Examples

The following example binarizes a raster image with Bradley’s adaptive thresholding algorithm with the specified window size. Binarized images contain only 2 colors - black and white.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_BinarizeFixed_System_Byte_"></a> BinarizeFixed\(byte\)

Binarization of an image with predefined threshold

```csharp
public virtual void BinarizeFixed(byte threshold)

Parameters

threshold byte

Threshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise.

Examples

The following example binarizes a raster image with the predefined threshold. Binarized images contain only 2 colors - black and white.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_BinarizeOtsu"></a> BinarizeOtsu\(\)

Binarization of an image with Otsu thresholding

```csharp
public virtual void BinarizeOtsu()

Examples

The following example binarizes a raster image with Otsu thresholding. Binarized images contain only 2 colors - black and white.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_Blend_Aspose_Imaging_Point_Aspose_Imaging_RasterImage_Aspose_Imaging_Rectangle_System_Byte_"></a> Blend\(Point, RasterImage, Rectangle, byte\)

Blends this image instance with the <code class="paramref">overlay</code> image.

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

Parameters

origin Point

The background image blending origin.

overlay RasterImage

The overlay image.

overlayArea Rectangle

The overlay area.

overlayAlpha byte

The overlay alpha.

Blend(Point, RasterImage, byte)

Blends this image instance with the overlay image.

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

Parameters

origin Point

The background image blending origin.

overlay RasterImage

The overlay image.

overlayAlpha byte

The overlay alpha.

Dither(DitheringMethod, int)

Performs dithering on the current image.

public void Dither(DitheringMethod ditheringMethod, int bitsCount)

Parameters

ditheringMethod DitheringMethod

The dithering method.

bitsCount int

The final bits count for dithering.

Examples

The following example loads a raster image and performs threshold and floyd dithering using different palette depth.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_Dither_Aspose_Imaging_DitheringMethod_System_Int32_Aspose_Imaging_IColorPalette_"></a> Dither\(DitheringMethod, int, IColorPalette\)

Performs dithering on the current image.

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

Parameters

ditheringMethod DitheringMethod

The dithering method.

bitsCount int

The final bits count for dithering.

customPalette IColorPalette

The custom palette for dithering.

Filter(Rectangle, FilterOptionsBase)

Filters the specified rectangle.

public virtual void Filter(Rectangle rectangle, FilterOptionsBase options)

Parameters

rectangle Rectangle

The rectangle.

options FilterOptionsBase

The options.

Examples

The following example applies various types of filters to a raster image.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_GetArgb32Pixel_System_Int32_System_Int32_"></a> GetArgb32Pixel\(int, int\)

Gets an image 32-bit ARGB pixel.

```csharp
public int GetArgb32Pixel(int x, int y)

Parameters

x int

The pixel x location.

y int

The pixel y location.

Returns

int

The 32-bit ARGB pixel for the specified location.

Examples

The following example loads a raster image and obtains the color of an arbitrary pixel represented as a 32-bit integer value.```csharp [C#]

                                                                                                                                    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 &gt;&gt; 24) &amp; 0xff;
                                                                                                                                        int red = (color &gt;&gt; 16) &amp; 0xff;
                                                                                                                                        int green = (color &gt;&gt; 8) &amp; 0xff;
                                                                                                                                        int blue = (color &gt;&gt; 0) &amp; 0xff;

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

The following example shows how image caching affects performance. In general case, reading cached data is performed faster than reading non-cached data.```csharp
[C#]

                                                                                                                                                                    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 &lt; image.Height; y++)
                                                                                                                                                                        {
                                                                                                                                                                            for (int x = 0; x &lt; 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 &lt; image.Height; y++)
                                                                                                                                                                        {
                                                                                                                                                                            for (int x = 0; x &lt; 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)

Gets the default 32-bit ARGB pixels array.

public int[] GetDefaultArgb32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

The rectangle to get pixels for.

Returns

int[]

The default pixels array.

GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader)

Gets the default pixels array using partial pixel loader.

public void GetDefaultPixels(Rectangle rectangle, IPartialArgb32PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

The rectangle to get pixels for.

partialPixelLoader IPartialArgb32PixelLoader

The partial pixel loader.

GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings)

Gets the default raw data array using partial pixel loader.

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

Parameters

rectangle Rectangle

The rectangle to get pixels for.

partialRawDataLoader IPartialRawDataLoader

The partial raw data loader.

rawDataSettings RawDataSettings

The raw data settings.

GetDefaultRawData(Rectangle, RawDataSettings)

Gets the default raw data array.

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

Parameters

rectangle Rectangle

The rectangle to get raw data for.

rawDataSettings RawDataSettings

The raw data settings.

Returns

byte[]

The default raw data array.

GetModifyDate(bool)

Gets the date and time the resource image was last modified.

public virtual DateTime GetModifyDate(bool useDefault)

Parameters

useDefault bool

if set to true uses the information from FileInfo as default value.

Returns

DateTime

The date and time the resource image was last modified.

GetPixel(int, int)

Gets an image pixel.

public Color GetPixel(int x, int y)

Parameters

x int

The pixel x location.

y int

The pixel y location.

Returns

Color

The pixel color for the specified location.

Examples

The following example loads a raster image and obtains the color of an arbitrary pixel.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_GetSkewAngle"></a> GetSkewAngle\(\)

Gets the skew angle.
This method is applicable to scanned text documents, to determine the skew angle when scanning.

```csharp
public float GetSkewAngle()

Returns

float

The skew angle, in degrees.

Grayscale()

Transformation of an image to its grayscale representation

public virtual void Grayscale()

Examples

The following example transforms a colored raster image to its grayscale representation. Grayscale images are composed exclusively of shades of gray and carry only intensity information.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_LoadArgb32Pixels_Aspose_Imaging_Rectangle_"></a> LoadArgb32Pixels\(Rectangle\)

Loads 32-bit ARGB pixels.

```csharp
public int[] LoadArgb32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

The rectangle to load pixels from.

Returns

int[]

The loaded 32-bit ARGB pixels array.

Examples

The following example shows how to load and process pixels of a raster image. The pixels are represented as 32-bit integer values. For example, consider a problem of counting of fully transparent pixels of an image.```csharp [C#]

                                                                                                                                                                                                                              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 &gt;&gt; 24) &amp; 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);
                                                                                                                                                                                                                              }

### <a id="Aspose_Imaging_RasterImage_LoadArgb64Pixels_Aspose_Imaging_Rectangle_"></a> LoadArgb64Pixels\(Rectangle\)

Loads 64-bit ARGB pixels.

```csharp
public long[] LoadArgb64Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

The rectangle to load pixels from.

Returns

long[]

The loaded 64-bit ARGB pixels array.

Examples

The following example shows how to load and process pixels of a raster image. The pixels are represented as 64-bit integer values. For example, consider a problem of counting of fully transparent pixels of an image.```csharp [C#]

                                                                                                                                                                                                                              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 &gt;&gt; 48) &amp; 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);
                                                                                                                                                                                                                              }

### <a id="Aspose_Imaging_RasterImage_LoadCmyk32Pixels_Aspose_Imaging_Rectangle_"></a> LoadCmyk32Pixels\(Rectangle\)

Loads pixels in CMYK format.

```csharp
public int[] LoadCmyk32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

The rectangle to load pixels from.

Returns

int[]

The loaded CMYK pixels presentes as 32-bit inateger values.

LoadCmykPixels(Rectangle)

Loads pixels in CMYK format. This method is deprecated. Please use more effective the Aspose.Imaging.RasterImage.LoadCmyk32Pixels(Aspose.Imaging.Rectangle) method.

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

Parameters

rectangle Rectangle

The rectangle to load pixels from.

Returns

CmykColor[]

The loaded CMYK pixels array.

LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader)

Loads 32-bit ARGB pixels partially by packs.

public void LoadPartialArgb32Pixels(Rectangle rectangle, IPartialArgb32PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

The desired rectangle.

partialPixelLoader IPartialArgb32PixelLoader

The 32-bit ARGB pixel loader.

Examples

The following example shows how to load and process pixels of a raster image using your own partial processor. For example, consider a problem of counting of fully transparent pixels of an image. In order to count transparent pixels using partial loading mechanism, a separate class TransparentArgb32PixelCounter implementing Aspose.Imaging.IPartialArgb32PixelLoader is introduced.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_LoadPartialArgb64Pixels_Aspose_Imaging_Rectangle_Aspose_Imaging_IPartialArgb64PixelLoader_"></a> LoadPartialArgb64Pixels\(Rectangle, IPartialArgb64PixelLoader\)

Loads 64-bit ARGB pixels partially by packs.

```csharp
public void LoadPartialArgb64Pixels(Rectangle rectangle, IPartialArgb64PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

The desired rectangle.

partialPixelLoader IPartialArgb64PixelLoader

The 64-bit ARGB pixel loader.

LoadPartialPixels(Rectangle, IPartialPixelLoader)

Loads pixels partially by packs.

public void LoadPartialPixels(Rectangle desiredRectangle, IPartialPixelLoader pixelLoader)

Parameters

desiredRectangle Rectangle

The desired rectangle.

pixelLoader IPartialPixelLoader

The pixel loader.

Examples

The following example shows how to load and process pixels of a raster image using your own partial processor. For example, consider a problem of counting of fully transparent pixels of an image. In order to count transparent using partial loading mechanism, a separate class TransparentPixelCounter implementing Aspose.Imaging.IPartialPixelLoader is introduced.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_LoadPixels_Aspose_Imaging_Rectangle_"></a> LoadPixels\(Rectangle\)

Loads pixels.

```csharp
public Color[] LoadPixels(Rectangle rectangle)

Parameters

rectangle Rectangle

The rectangle to load pixels from.

Returns

Color[]

The loaded pixels array.

Examples

The following example shows how to load and process pixels of a raster image. For example, consider a problem of counting of fully transparent pixels of an image.```csharp [C#]

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

This example shows how to Loads Pixel information in an Array of Type Color, manipulates the array and set it back to the image. To perform these operations, this example creates a new Image file (in GIF format) uisng MemoryStream object.```csharp
[C#]

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

Loads raw data.

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

Parameters

rectangle Rectangle

The rectangle to load raw data from.

rawDataSettings RawDataSettings

The raw data settings to use for loaded data. Note if data is not in the format specified then data conversion will be performed.

rawDataLoader IPartialRawDataLoader

The raw data loader.

Examples

The following example shows how to extract pixels from the raw image data using RawDataSettings. For example, consider a problem of counting of fully transparent pixels of an image.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_LoadRawData_Aspose_Imaging_Rectangle_Aspose_Imaging_Rectangle_Aspose_Imaging_RawDataSettings_Aspose_Imaging_IPartialRawDataLoader_"></a> LoadRawData\(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader\)

Loads raw data.

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

Parameters

rectangle Rectangle

The rectangle to load raw data from.

destImageBounds Rectangle

The dest image bounds.

rawDataSettings RawDataSettings

The raw data settings to use for loaded data. Note if data is not in the format specified then data conversion will be performed.

rawDataLoader IPartialRawDataLoader

The raw data loader.

NormalizeAngle()

Normalizes the angle. This method is applicable to scanned text documents to get rid of the skewed scan. This method uses Aspose.Imaging.RasterImage.GetSkewAngle and Aspose.Imaging.RasterImage.Rotate(System.Single) methods.

public void NormalizeAngle()

NormalizeAngle(bool, Color)

Normalizes the angle. This method is applicable to scanned text documents to get rid of the skewed scan. This method uses Aspose.Imaging.RasterImage.GetSkewAngle and Aspose.Imaging.RasterImage.Rotate(System.Single,System.Boolean,Aspose.Imaging.Color) methods.

public virtual void NormalizeAngle(bool resizeProportionally, Color backgroundColor)

Parameters

resizeProportionally bool

if set to true you will have your image size changed according to rotated rectangle (corner points) projections in other case that leaves dimensions untouched and only internal image contents are rotated.

backgroundColor Color

Color of the background.

Examples

Skew is an artifact that might appear during document scanning process when the text/images of the document get rotated at a slight angle. It can have various causes but the most common is that the paper get misplaced during a scan. Therefore, deskew is the process of detecting and fixing this issue on scanned files(i.e. bitmap) so deskewed documents will have the text/images correctly and horizontally adjusted.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_ReadArgb32ScanLine_System_Int32_"></a> ReadArgb32ScanLine\(int\)

Reads the whole scan line by the specified scan line index.

```csharp
public int[] ReadArgb32ScanLine(int scanLineIndex)

Parameters

scanLineIndex int

Zero based index of the scan line.

Returns

int[]

The scan line 32-bit ARGB color values array.

ReadScanLine(int)

Reads the whole scan line by the specified scan line index.

public Color[] ReadScanLine(int scanLineIndex)

Parameters

scanLineIndex int

Zero based index of the scan line.

Returns

Color[]

The scan line pixel color values array.

ReleaseManagedResources()

Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.

protected override void ReleaseManagedResources()

RemoveMetadata()

Removes this image instance metadata by setting this Aspose.Imaging.Xmp.IHasXmpData.XmpData value to null.

public override void RemoveMetadata()

ReplaceColor(Color, byte, Color)

Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.

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

Parameters

oldColor Color

Old color to be replaced.

oldColorDiff byte

Allowed difference in old color to be able to widen replaced color tone.

newColor Color

New color to replace old color with.

ReplaceColor(int, byte, int)

Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.

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

Parameters

oldColorArgb int

Old color ARGB value to be replaced.

oldColorDiff byte

Allowed difference in old color to be able to widen replaced color tone.

newColorArgb int

New color ARGB value to replace old color with.

ReplaceNonTransparentColors(Color)

Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges. Note: if you use it on images without transparency, all colors will be replaced with a single one.

public void ReplaceNonTransparentColors(Color newColor)

Parameters

newColor Color

New color to replace non transparent colors with.

ReplaceNonTransparentColors(int)

Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges. Note: if you use it on images without transparency, all colors will be replaced with a single one.

public virtual void ReplaceNonTransparentColors(int newColorArgb)

Parameters

newColorArgb int

New color ARGB value to replace non transparent colors with.

Resize(int, int, ImageResizeSettings)

Resizes the image with extended options.

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

Parameters

newWidth int

The new width.

newHeight int

The new height.

settings ImageResizeSettings

The resize settings.

Examples

This example loads a raster image and resizes it using various resizing settings.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_Rotate_System_Single_System_Boolean_Aspose_Imaging_Color_"></a> Rotate\(float, bool, Color\)

Rotate image around the center.

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

Parameters

angle float

The rotate angle in degrees. Positive values will rotate clockwise.

resizeProportionally bool

if set to true you will have your image size changed according to rotated rectangle (corner points) projections in other case that leaves dimensions untouched and only internal image contents are rotated.

backgroundColor Color

Color of the background.

Exceptions

NotImplementedException

Not implemented exception

Rotate(float)

Rotate image around the center.

public override void Rotate(float angle)

Parameters

angle float

The rotate angle in degrees. Positive values will rotate clockwise.

Save(Stream, ImageOptionsBase, Rectangle)

Saves the image’s data to the specified stream in the specified file format according to save options.

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

Parameters

stream Stream

The stream to save the image’s data to.

optionsBase ImageOptionsBase

The save options.

boundsRectangle Rectangle

The destination image bounds rectangle. Set the empty rectangle for use source bounds.

SaveArgb32Pixels(Rectangle, int[])

Saves the 32-bit ARGB pixels.

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

Parameters

rectangle Rectangle

The rectangle to save pixels to.

pixels int[]

The 32-bit ARGB pixels array.

Examples

The following example fills the central area of a raster image with black pixels using the Aspose.Imaging.RasterImage.SaveArgb32Pixels method.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_SaveCmyk32Pixels_Aspose_Imaging_Rectangle_System_Int32___"></a> SaveCmyk32Pixels\(Rectangle, int\[\]\)

Saves the pixels.

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

Parameters

rectangle Rectangle

The rectangle to save pixels to.

pixels int[]

The CMYK pixels presented as the 32-bit integer values.

Examples

The following example fills the central area of a raster image with black pixels using the Aspose.Imaging.RasterImage.SaveCmyk32Pixels method.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_SaveCmykPixels_Aspose_Imaging_Rectangle_Aspose_Imaging_CmykColor___"></a> SaveCmykPixels\(Rectangle, CmykColor\[\]\)

Saves the pixels.
This method is deprecated. Please use more effective the Aspose.Imaging.RasterImage.SaveCmyk32Pixels(Aspose.Imaging.Rectangle,System.Int32[]) method.

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

Parameters

rectangle Rectangle

The rectangle to save pixels to.

pixels CmykColor[]

The CMYK pixels array.

SavePixels(Rectangle, Color[])

Saves the pixels.

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

Parameters

rectangle Rectangle

The rectangle to save pixels to.

pixels Color[]

The pixels array.

Examples

The following example fills the central area of a raster image with black pixels using the Aspose.Imaging.RasterImage.SavePixels method.```csharp [C#]

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

This example shows how to Loads Pixel information in an Array of Type Color, manipulates the array and set it back to the image. To perform these operations, this example creates a new Image file (in GIF format) uisng MemoryStream object.```csharp
[C#]

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

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

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

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

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

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

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

Saves the raw data.

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

Parameters

data byte[]

The raw data.

dataOffset int

The starting raw data offset.

rectangle Rectangle

The raw data rectangle.

rawDataSettings RawDataSettings

The raw data settings the data is in.

SetArgb32Pixel(int, int, int)

Sets an image 32-bit ARGB pixel for the specified position.

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

Parameters

x int

The pixel x location.

y int

The pixel y location.

argb32Color int

The 32-bit ARGB pixel for the specified position.

Examples

The following example loads a raster image, and sets the color of an arbitrary pixel.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_SetPalette_Aspose_Imaging_IColorPalette_System_Boolean_"></a> SetPalette\(IColorPalette, bool\)

Sets the image palette.

```csharp
public override void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

The palette to set.

updateColors bool

if set to true colors will be updated according to the new palette; otherwise color indexes remain unchanged. Note that unchanged indexes may crash the image on loading if some indexes have no corresponding palette entries.

SetPixel(int, int, Color)

Sets an image pixel for the specified position.

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

Parameters

x int

The pixel x location.

y int

The pixel y location.

color Color

The pixel color for the specified position.

Examples

The following example loads a raster image, and sets the color of an arbitrary pixel.```csharp [C#]

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

### <a id="Aspose_Imaging_RasterImage_SetResolution_System_Double_System_Double_"></a> SetResolution\(double, double\)

Sets the resolution for this Aspose.Imaging.RasterImage.

```csharp
public virtual void SetResolution(double dpiX, double dpiY)

Parameters

dpiX double

The horizontal resolution, in dots per inch, of the Aspose.Imaging.RasterImage.

dpiY double

The vertical resolution, in dots per inch, of the Aspose.Imaging.RasterImage.

Examples

The following example shows how to set horizontal/vertical resolution of a raster image.```csharp [C#]

                                                                                               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
                                                                                               }

### <a id="Aspose_Imaging_RasterImage_ToBitmap"></a> ToBitmap\(\)

Converts raster image to the bitmap.
This method is not supported in versions from .Net7.0 and higher

```csharp
public virtual Bitmap ToBitmap()

Returns

Bitmap

The bitmap

UpdateDimensions(int, int)

Updates the image dimensions.

protected abstract void UpdateDimensions(int newWidth, int newHeight)

Parameters

newWidth int

The new image width.

newHeight int

The new image height.

UpdateMetadata()

Updates the image metadata.

protected virtual void UpdateMetadata()

WriteArgb32ScanLine(int, int[])

Writes the whole scan line to the specified scan line index.

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

Parameters

scanLineIndex int

Zero based index of the scan line.

argb32Pixels int[]

The 32-bit ARGB colors array to write.

WriteScanLine(int, Color[])

Writes the whole scan line to the specified scan line index.

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

Parameters

scanLineIndex int

Zero based index of the scan line.

pixels Color[]

The pixel colors array to write.