Class RasterImage

Class RasterImage

ชื่อพื้นที่: Aspose.Imaging การประกอบ: Aspose.Imaging.dll (25.4.0)

แสดงภาพ raster ที่สนับสนุนการดําเนินงานกราฟิก raster

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

Inheritance

object DisposableObject DataStreamSupporter Image RasterImage

Derived

RasterCachedImage

Implements

IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasXmpData , IHasMetadata

อนุญาโตตุลาการ

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

ตัวอย่างนี้แสดงให้เห็นถึงวิธีการโหลดข้อมูล Pixel ใน Array ของ Type Color การจัดการ array และตั้งค่ากลับไปยังภาพ ในการดําเนินการเหล่านี้ ตัวอย่างนี้สร้างไฟล์ภาพใหม่ (ในรูปแบบ GIF) uisng วัตถุ MemoryStream

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

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

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

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

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

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

Constructors

RasterImage()

เริ่มต้นตัวอย่างใหม่ของชั้น Aspose.Imaging.RasterImage

[JsonConstructor]
protected RasterImage()

RasterImage(คอลัมน์)

เริ่มต้นตัวอย่างใหม่ของชั้น Aspose.Imaging.RasterImage

protected RasterImage(IColorPalette colorPalette)

Parameters

colorPalette IColorPalette

แผ่นสี

Fields

xmpData

Metadata ของ XMP

[JsonProperty]
protected XmpPacketWrapper xmpData

หมายเลข

XmpPacketWrapper

Properties

DataLoader

รับหรือตั้งค่าเครื่องโหลดข้อมูล

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

คุณสมบัติมูลค่า

IRasterImageArgb32PixelLoader

HasAlpha

ได้รับค่าแสดงให้เห็นว่าตัวอย่างนี้มีอัลฟาหรือไม่

public virtual bool HasAlpha { get; }

คุณสมบัติมูลค่า

bool

Examples

ตัวอย่างต่อไปนี้โหลดภาพสกรูและพิมพ์ข้อมูลเกี่ยวกับรูปแบบข้อมูลดิบและช่องอัลฟา

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

ตัวอย่างต่อไปนี้แสดงให้เห็นว่าวิธีการสกัดข้อมูลเกี่ยวกับรูปแบบข้อมูลดิบและช่องอัลฟาจากภาพ BMP

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

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

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

HasTransparentColor

ได้รับค่าแสดงให้เห็นว่าภาพมีสีโปร่งใสหรือไม่

public virtual bool HasTransparentColor { get; set; }

คุณสมบัติมูลค่า

bool

HorizontalResolution

รับหรือตั้งค่าความละเอียดแนวนอนใน pixels per inch ของ Aspose.Imaging.RasterImage นี้

public virtual double HorizontalResolution { get; set; }

คุณสมบัติมูลค่า

double

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการตั้งค่าความละเอียดแนวนอน/แนวตั้งของภาพเรสเตอร์

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

หมายเหตุตาม default หมายเลขนี้เป็น 96 เนื่องจากแพลตฟอร์มที่แตกต่างกันไม่สามารถคืนความละเอียดหน้าจอได้ คุณสามารถพิจารณาการใช้วิธีการ SetResolution เพื่อปรับปรุงค่าความละเอียดทั้งสองในโทรเดียว

ImageOpacity

ได้รับความไม่ชัดเจนของภาพนี้

public virtual float ImageOpacity { get; }

คุณสมบัติมูลค่า

float

IsRawDataAvailable

ได้รับค่าที่แสดงให้เห็นว่าการโหลดข้อมูลวัตถุดิบมีอยู่หรือไม่

public bool IsRawDataAvailable { get; }

คุณสมบัติมูลค่า

bool

PremultiplyComponents

รับหรือตั้งค่าหมายความว่าส่วนประกอบภาพควรจะมีการเพิ่มขึ้น

public virtual bool PremultiplyComponents { get; set; }

คุณสมบัติมูลค่า

bool

Examples

ตัวอย่างต่อไปนี้สร้างภาพ raster ใหม่บันทึกพิกเซลครึ่งโปร่งใสที่ระบุแล้วโหลดพิกเซลเหล่านี้และได้รับสีสุดท้ายในรูปแบบที่เพิ่มขึ้น

int imageWidth = 3;
                                                                                                                                                                                  int imageHeight = 2;

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

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

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

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

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

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

RawCustomColorConverter

รับหรือตั้งค่าเครื่องแปลงสีที่กําหนดเอง

public IColorConverter RawCustomColorConverter { get; set; }

คุณสมบัติมูลค่า

IColorConverter

RawDataFormat

รับรูปแบบข้อมูลดิบ

public virtual PixelDataFormat RawDataFormat { get; }

คุณสมบัติมูลค่า

PixelDataFormat

Examples

ตัวอย่างต่อไปนี้โหลดภาพสกรูและพิมพ์ข้อมูลเกี่ยวกับรูปแบบข้อมูลดิบและช่องอัลฟา

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

ตัวอย่างนี้แสดงให้เห็นวิธีการโหลดภาพ DJVU จากไฟล์และพิมพ์ข้อมูลเกี่ยวกับหน้า

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

รับการตั้งค่าข้อมูลวัตถุดิบปัจจุบัน โปรดทราบเมื่อใช้การตั้งค่าเหล่านี้ข้อมูลโหลดโดยไม่ต้องแปลง

[JsonIgnore]
public RawDataSettings RawDataSettings { get; }

คุณสมบัติมูลค่า

RawDataSettings

RawFallbackIndex

รับหรือตั้งค่าอัตราการลดลงเพื่อใช้เมื่ออัตราการลดลงไม่ได้ จํากัด

public int RawFallbackIndex { get; set; }

คุณสมบัติมูลค่า

int

RawIndexedColorConverter

รับหรือตั้งค่าเครื่องแปลงสีที่ระบุ

public IIndexedColorConverter RawIndexedColorConverter { get; set; }

คุณสมบัติมูลค่า

IIndexedColorConverter

RawLineSize

รับขนาดเส้นดิบในไบต์

public virtual int RawLineSize { get; }

คุณสมบัติมูลค่า

int

TransparentColor

ได้รับภาพสีโปร่งใส

public virtual Color TransparentColor { get; set; }

คุณสมบัติมูลค่า

Color

UpdateXmpData

ได้รับหรือตั้งค่าค่าที่ระบุว่าจะอัปเดต metadata XMP หรือไม่

public virtual bool UpdateXmpData { get; set; }

คุณสมบัติมูลค่า

bool

UsePalette

ได้รับค่าที่แสดงให้เห็นว่าแผงภาพจะถูกใช้หรือไม่

public override bool UsePalette { get; }

คุณสมบัติมูลค่า

bool

UseRawData

ได้รับหรือตั้งค่าค่าแสดงให้เห็นว่าควรใช้การโหลดข้อมูลดิบเมื่อการโหลดข้อมูลดิบที่มีอยู่หรือไม่

public virtual bool UseRawData { get; set; }

คุณสมบัติมูลค่า

bool

VerticalResolution

รับหรือตั้งค่าความละเอียดแนวตั้งใน pixels per inch ของ Aspose.Imaging.RasterImage นี้

public virtual double VerticalResolution { get; set; }

คุณสมบัติมูลค่า

double

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการตั้งค่าความละเอียดแนวนอน/แนวตั้งของภาพเรสเตอร์

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

หมายเหตุตาม default หมายเลขนี้เป็น 96 เนื่องจากแพลตฟอร์มที่แตกต่างกันไม่สามารถคืนความละเอียดหน้าจอได้ คุณสามารถพิจารณาการใช้วิธีการ SetResolution เพื่อปรับปรุงค่าความละเอียดทั้งสองในโทรเดียว

XmpData

รับหรือตั้งค่า metadata XMP

public virtual XmpPacketWrapper XmpData { get; set; }

คุณสมบัติมูลค่า

XmpPacketWrapper

Methods

AdjustBrightness(int)

การปรับความสว่างสําหรับภาพ

public virtual void AdjustBrightness(int brightness)

Parameters

brightness int

ความสว่าง

Examples

ตัวอย่างต่อไปนี้ทําการแก้ไขความสว่างของภาพ

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

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

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

AdjustContrast(เฟอร์รี่)

ความต้านทานภาพ

public virtual void AdjustContrast(float contrast)

Parameters

contrast float

คะแนนความต้านทาน (ในช่วง [-100; 100])

Examples

ตัวอย่างต่อไปนี้จะดําเนินการการแก้ไขข้อตกลงของภาพ

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

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

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

AdjustGamma(เฟอร์รี่, เฟอร์รี่, เฟอร์รี่)

แก้ไข Gamma ของภาพ

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

Parameters

gammaRed float

Gamma สําหรับช่องแดง Coefficient

gammaGreen float

Gamma สําหรับ Coefficient ช่องสีเขียว

gammaBlue float

Gamma สําหรับ Coefficient ช่องสีฟ้า

Examples

ตัวอย่างต่อไปนี้จะดําเนินการการแก้ไขรูปทรงกลมของภาพโดยใช้ค่าเฉลี่ยที่แตกต่างกันสําหรับส่วนประกอบสี

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

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

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

AdjustGamma(เฟอร์รี่)

แก้ไข Gamma ของภาพ

public virtual void AdjustGamma(float gamma)

Parameters

gamma float

GAMMA สําหรับช่องแดงสีเขียวและสีน้ําเงิน

Examples

ตัวอย่างต่อไปนี้จะดําเนินการการแก้ไขแก๊มของภาพ

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

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

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

BinarizeBradley(คู่)

การไบนารายการของภาพโดยใช้แอลกอริทึมการปรับตัวของ Bradley โดยใช้แอลกอริทึมภาพแบบบูรณาการ

public virtual void BinarizeBradley(double brightnessDifference)

Parameters

brightnessDifference double

ความแตกต่างของแสงระหว่างพิกเซลและเฉลี่ยของหน้าต่าง s x s ของพิกเซลที่มุ่งเน้นรอบพิกเซลนี้

BinarizeBradley(สอง, int)

การไบนารายการของภาพโดยใช้แอลกอริทึมการปรับตัวของ Bradley โดยใช้แอลกอริทึมภาพแบบบูรณาการ

public virtual void BinarizeBradley(double brightnessDifference, int windowSize)

Parameters

brightnessDifference double

ความแตกต่างของแสงระหว่างพิกเซลและเฉลี่ยของหน้าต่าง s x s ของพิกเซลที่มุ่งเน้นรอบพิกเซลนี้

windowSize int

ขนาดหน้าต่าง s x s ของพิกเซลที่มุ่งเน้นรอบพิกเซลนี้

Examples

ตัวอย่างต่อไปนี้ไบนารีภาพเรสเตอร์กับอัลกอริทึมการปรับแต่งของ Bradley กับขนาดหน้าต่างที่ระบุ ภาพไบนารีมีเพียง 2 สี - สีดําและสีขาว

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

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

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

BinarizeFixed(บิต)

การไบนารีของภาพที่มีข้อ จํากัด ที่กําหนดไว้

public virtual void BinarizeFixed(byte threshold)

Parameters

threshold byte

หมายเลข จํากัด หากหมายเลขสีเทาของพิกเซลที่ตรงกันข้ามสูงกว่าหมายเลข จํากัด หมายเลข 255 จะถูกกําหนดให้เป็นหมายเลข 0 ฯลฯ

Examples

ตัวอย่างต่อไปนี้ไบนารีภาพเรสเตอร์ที่มีข้อจํากัดที่กําหนดไว้ ภาพไบนารีมีเพียง 2 สี - สีดําและสีขาว

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

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

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

BinarizeOtsu()

Binarization ของภาพ ด้วย Otsu thresholding

public virtual void BinarizeOtsu()

Examples

ตัวอย่างต่อไปนี้ไบนารีภาพสกรูด้วย Otsu เกรด ภาพไบนารีมีเพียง 2 สี - สีดําและสีขาว

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

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

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

Blend(จุด, RasterImage, Rectangle, byte)

ผสมตัวอย่างภาพนี้กับภาพ overlay"

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

Parameters

origin Point

รูปภาพพื้นหลังผสมต้นกําเนิด

overlay RasterImage

ภาพ Overlay

overlayArea Rectangle

พื้นที่ Overlay

overlayAlpha byte

อัลฟา Overlay

Blend(จุด, RasterImage, byte)

ผสมตัวอย่างภาพนี้กับภาพ overlay"

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

Parameters

origin Point

รูปภาพพื้นหลังผสมต้นกําเนิด

overlay RasterImage

ภาพ Overlay

overlayAlpha byte

อัลฟา Overlay

Dither(หลักสูตรการวิเคราะห์, int)

การแสดงผลไทเทเนียมบนภาพปัจจุบัน

public void Dither(DitheringMethod ditheringMethod, int bitsCount)

Parameters

ditheringMethod DitheringMethod

วิธีการไดร์เวอร์

bitsCount int

บิตสุดท้ายคํานวณสําหรับ dithering

Examples

ตัวอย่างต่อไปนี้โหลดภาพเรสเตอร์และทําขอบเขตและลอยไทเทอร์โดยใช้ความลึกของแพลตฟอร์มที่แตกต่างกัน

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

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

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

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

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

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

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

Dither(DitheringMethod, int, IColorPalette)

การแสดงผลไทเทเนียมบนภาพปัจจุบัน

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

Parameters

ditheringMethod DitheringMethod

วิธีการไดร์เวอร์

bitsCount int

บิตสุดท้ายคํานวณสําหรับ dithering

customPalette IColorPalette

แพลิเคชันที่กําหนดเองสําหรับ dithering

Filter(Rectangle, FilterOptionsBase)

กรองแนวตั้งที่ระบุ

public virtual void Filter(Rectangle rectangle, FilterOptionsBase options)

Parameters

rectangle Rectangle

ตุ๊กตา

options FilterOptionsBase

ตัวเลือก

Examples

ตัวอย่างต่อไปนี้ใช้ประเภทต่างๆของกรองสําหรับภาพสกรู

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

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

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

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

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

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

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

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

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

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

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

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

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

GetArgb32Pixel(int, int)

ได้รับภาพ 32 บิต ARGB pixel

public int GetArgb32Pixel(int x, int y)

Parameters

x int

พิกเซล x ตําแหน่ง

y int

พิกเซล Y ตําแหน่ง

Returns

int

พิกเซล ARGB 32 บิตสําหรับตําแหน่งที่ระบุ

Examples

ตัวอย่างต่อไปนี้โหลดภาพเรสเตอร์และได้รับสีของพิกเซลที่ปรากฏเป็นค่าที่สมบูรณ์ 32 บิต

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

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

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

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

ตัวอย่างต่อไปนี้แสดงให้เห็นว่าการเข้ารหัสภาพมีผลต่อประสิทธิภาพ ในกรณีทั่วไปการอ่านข้อมูลเข้ารหัสจะดําเนินการเร็วกว่าการอ่านข้อมูลที่ไม่เข้ารหัส

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

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

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

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

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

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

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

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

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

GetDefaultArgb32Pixels(Rectangle)

ได้รับการตั้งค่า 32 บิต ARGB pixels array

public int[] GetDefaultArgb32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

ทางตรงที่จะได้รับ pixels สําหรับ

Returns

int [ ]

พิกเซลแบบ default array

GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader)

ได้รับการจัดเรียง pixel แบบกําหนดเองโดยใช้ตัวโหลด pixel ส่วน

public void GetDefaultPixels(Rectangle rectangle, IPartialArgb32PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

ทางตรงที่จะได้รับ pixels สําหรับ

partialPixelLoader IPartialArgb32PixelLoader

ชิ้นส่วน pixel loader

GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings)

ได้รับการจัดเก็บข้อมูลวัตถุดิบแบบกําหนดเองโดยใช้เครื่องชาร์จ pixel ส่วน

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

Parameters

rectangle Rectangle

ทางตรงที่จะได้รับ pixels สําหรับ

partialRawDataLoader IPartialRawDataLoader

เครื่องชาร์จข้อมูลดิบส่วน

rawDataSettings RawDataSettings

การตั้งค่าข้อมูลดิบ

GetDefaultRawData(Rectangle, RawDataSettings)

ได้รับการจัดเก็บข้อมูลวัตถุดิบที่กําหนดเอง

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

Parameters

rectangle Rectangle

ตรงเพื่อรับข้อมูลดิบ

rawDataSettings RawDataSettings

การตั้งค่าข้อมูลดิบ

Returns

byte [ ]

การจัดเก็บข้อมูลวัตถุดิบแบบ default

GetModifyDate(บอล)

ได้รับวันที่และเวลาภาพทรัพยากรได้รับการแก้ไขครั้งสุดท้าย

public virtual DateTime GetModifyDate(bool useDefault)

Parameters

useDefault bool

ถ้าตั้งค่าเป็น “จริง” ใช้ข้อมูลจาก FileInfo เป็นค่าเริ่มต้น

Returns

DateTime

วันที่และเวลาภาพทรัพยากรได้รับการแก้ไขครั้งสุดท้าย

GetPixel(int, int)

ได้รับภาพ pixel

public Color GetPixel(int x, int y)

Parameters

x int

พิกเซล x ตําแหน่ง

y int

พิกเซล Y ตําแหน่ง

Returns

Color

สีพิกเซลสําหรับตําแหน่งที่ระบุ

Examples

ตัวอย่างต่อไปนี้โหลดภาพเรสเตอร์และได้รับสีของพิกเซลที่กําหนดเอง

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

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

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

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

GetSkewAngle()

ได้รับมุมสกี้วิธีการนี้ใช้กับเอกสารข้อความที่สแกนเพื่อกําหนดมุมสแกนเมื่อสแกน

public float GetSkewAngle()

Returns

float

แข็งมุมในเกรด

Grayscale()

การแปลงภาพไปสู่การแสดงผลสีเทา

public virtual void Grayscale()

Examples

ตัวอย่างต่อไปนี้จะแปลงภาพเรสเตอร์ที่มีสีสันเพื่อการแสดงภาพสีเทา รูปภาพสีเทาประกอบด้วยภาพสีเทาและมีข้อมูลความเข้มเท่านั้น

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

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

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

LoadArgb32Pixels(Rectangle)

ดาวน์โหลด 32 บิต ARGB pixels

public int[] LoadArgb32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

ตรงเพื่อโหลดพิกเซลจาก

Returns

int [ ]

พิกเซล ARGB 32 บิตที่โหลดได้

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นว่าวิธีการโหลดและประมวลผล pixels ของภาพ raster pixels ถูกแสดงเป็น 32 บิตค่ารวม ตัวอย่างเช่นพิจารณาปัญหาของการคํานวณ pixels ที่โปร่งใสเต็มรูปแบบของภาพ

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

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

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

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

LoadArgb64Pixels(Rectangle)

ดาวน์โหลด 64 บิต ARGB พิกเซล

public long[] LoadArgb64Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

ตรงเพื่อโหลดพิกเซลจาก

Returns

long [ ]

ชิ้นส่วน 64 บิต ARGB Array

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นว่าวิธีการโหลดและประมวลผลพิกเซลของภาพเรสเตอร์ พิกเซลจะถูกแสดงเป็นค่ารวม 64 บิต ตัวอย่างเช่นพิจารณาปัญหาของการคํานวณพิกเซลที่โปร่งใสเต็มรูปแบบของภาพ

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

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

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

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

LoadCmyk32Pixels(Rectangle)

ดาวน์โหลดพิกเซลในรูปแบบ CMYK

public int[] LoadCmyk32Pixels(Rectangle rectangle)

Parameters

rectangle Rectangle

ตรงเพื่อโหลดพิกเซลจาก

Returns

int [ ]

พิกเซล CMYK ที่โหลดจะนําเสนอเป็นค่า 32 บิต inateger

LoadCmykPixels(Rectangle)

ดาวน์โหลดพิกเซลในรูปแบบ CMYKวิธีการนี้ถูกลดลง โปรดใช้วิธีการ Aspose.Imaging.RasterImage.LoadCmyk32Pixels(Aspose.Imaging.Rectangle) อย่างมีประสิทธิภาพมากขึ้น

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

Parameters

rectangle Rectangle

ตรงเพื่อโหลดพิกเซลจาก

Returns

CmykColor [ ]

โหลด CMYK pixels array

LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader)

บัตร 32 บิต ARGB ชิ้นส่วนโดยแพ็ค

public void LoadPartialArgb32Pixels(Rectangle rectangle, IPartialArgb32PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

คู่มือที่ต้องการ

partialPixelLoader IPartialArgb32PixelLoader

เครื่องชาร์จพิกเซล ARGB 32 บิต

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการโหลดและประมวลผล pixels ของภาพ raster โดยใช้เครื่องประมวลผลส่วนของคุณเอง ตัวอย่างเช่นพิจารณาปัญหาของการคํานวณ pixels ที่โปร่งใสเต็มรูปแบบของภาพ เพื่อคํานวณ pixels ที่โปร่งใสโดยใช้กลไกการโหลดส่วนได้ Class TransparentArgb32PixelCounter ที่นําไปใช้ Aspose.Imaging.IPartialArgb32PixelLoader

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

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

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

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

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

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

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

LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader)

บัตร 64 บิต ARGB ชิ้นส่วนโดยแพ็ค

public void LoadPartialArgb64Pixels(Rectangle rectangle, IPartialArgb64PixelLoader partialPixelLoader)

Parameters

rectangle Rectangle

คู่มือที่ต้องการ

partialPixelLoader IPartialArgb64PixelLoader

64 บิต ARGB pixel loader

LoadPartialPixels(Rectangle, IPartialPixelLoader)

บรรจุพิกเซลโดยแพคเกจ

public void LoadPartialPixels(Rectangle desiredRectangle, IPartialPixelLoader pixelLoader)

Parameters

desiredRectangle Rectangle

คู่มือที่ต้องการ

pixelLoader IPartialPixelLoader

เครื่องชาร์จพิกเซล

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นว่าวิธีการโหลดและประมวลผล pixels ของภาพ raster โดยใช้เครื่องประมวลผลส่วนของคุณเอง ตัวอย่างเช่นพิจารณาปัญหาของการคํานวณ pixels แบบโปร่งใสของภาพ เพื่อคํานวณแบบโปร่งใสโดยใช้กลไกการโหลดส่วนได้ Class TransparentPixelCounter ที่นําเสนอ Aspose.Imaging.IPartialPixelLoader

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

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

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

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

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

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

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

LoadPixels(Rectangle)

โหลด pixels

public Color[] LoadPixels(Rectangle rectangle)

Parameters

rectangle Rectangle

ตรงเพื่อโหลดพิกเซลจาก

Returns

Color [ ]

พิกเซลที่โหลดได้

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นว่าวิธีการโหลดและประมวลผล pixels ของภาพ raster ตัวอย่างเช่นพิจารณาปัญหาของการคํานวณ pixels ที่โปร่งใสเต็มรูปแบบของภาพ

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

ตัวอย่างนี้แสดงให้เห็นถึงวิธีการโหลดข้อมูล Pixel ใน Array ของ Type Color การจัดการ array และตั้งค่ากลับไปยังภาพ ในการดําเนินการเหล่านี้ ตัวอย่างนี้สร้างไฟล์ภาพใหม่ (ในรูปแบบ GIF) uisng วัตถุ MemoryStream

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

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

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

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

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

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

LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader)

การโหลดข้อมูลวัตถุดิบ

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

Parameters

rectangle Rectangle

ตรงเพื่อโหลดข้อมูลดิบจาก

rawDataSettings RawDataSettings

การตั้งค่าข้อมูลวัตถุดิบที่จะใช้สําหรับการโหลดข้อมูล โปรดทราบว่าหากข้อมูลไม่ได้อยู่ในรูปแบบที่ระบุแล้วการแปลงข้อมูลจะดําเนินการ

rawDataLoader IPartialRawDataLoader

เครื่องโหลดข้อมูลดิบ

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นว่าวิธีการ استخراجพิกเซลจากข้อมูลภาพดิบโดยใช้ RawDataSettings ตัวอย่างเช่นพิจารณาปัญหาของการคํานวณพิกเซลที่โปร่งใสเต็มรูปแบบของภาพ

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

                                                                                                                                                                                                    TransparentPixelRawDataCounter rawDataLoader = new TransparentPixelRawDataCounter(settings);

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

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

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

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

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

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

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

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

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

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

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

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

LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader)

การโหลดข้อมูลวัตถุดิบ

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

Parameters

rectangle Rectangle

ตรงเพื่อโหลดข้อมูลดิบจาก

destImageBounds Rectangle

ภาพที่ซ่อนอยู่ จํากัด

rawDataSettings RawDataSettings

การตั้งค่าข้อมูลวัตถุดิบที่จะใช้สําหรับการโหลดข้อมูล โปรดทราบว่าหากข้อมูลไม่ได้อยู่ในรูปแบบที่ระบุแล้วการแปลงข้อมูลจะดําเนินการ

rawDataLoader IPartialRawDataLoader

เครื่องโหลดข้อมูลดิบ

NormalizeAngle()

ปรับปรุงมุมวิธีการนี้ใช้กับเอกสารข้อความที่สแกนเพื่อกําจัดสแกนที่สกปรกวิธีการนี้ใช้วิธีการ Aspose.Imaging.RasterImage.GetSkewAngle และ Aspose.Imaging.RasterImage.Rotate(System.Single)

public void NormalizeAngle()

NormalizeAngle(บอล, สี)

ปรับปรุงมุมวิธีการนี้ใช้กับเอกสารข้อความที่สแกนเพื่อกําจัดสแกนที่สกปรกวิธีการนี้ใช้วิธีการ Aspose.Imaging.RasterImage.GetSkewAngle และ Aspose.Imaging.RasterImage.Rotate(System.Single,System.Boolean,Aspose.Imaging.Color)

public virtual void NormalizeAngle(bool resizeProportionally, Color backgroundColor)

Parameters

resizeProportionally bool

ถ้าคุณตั้งค่าเป็น “จริง” คุณจะมีการเปลี่ยนแปลงขนาดภาพของคุณตามแนวตั้งหมุน (จุดมุม) projections ในกรณีอื่น ๆ ที่ปล่อยให้ขนาดไม่สัมผัสและเนื้อหาภาพภายในเท่านั้นจะหมุน

backgroundColor Color

สีของพื้นหลัง

Examples

Skew เป็นศิลปะที่อาจปรากฏในระหว่างกระบวนการสแกนเอกสารเมื่อข้อความ / ภาพของเอกสารจะหมุนในมุมเล็ก ๆ มันอาจมีสาเหตุที่แตกต่างกัน แต่ที่พบมากที่สุดคือกระดาษจะไม่ได้ตั้งอยู่ในระหว่างสแกน ดังนั้น deskew เป็นกระบวนการของการตรวจจับและแก้ไขปัญหานี้บนไฟล์สแกน (เช่น bitmap) ดังนั้นเอกสารที่สแกนจะมีการปรับข้อความ / ภาพอย่างถูกต้องและแนวนอน

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

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

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

NormalizeHistogram()

normalizes the image histogram — ปรับค่า pixel เพื่อใช้ช่วงที่มีอยู่ทั้งหมด

public virtual void NormalizeHistogram()

ReadArgb32ScanLine(int)

อ่านเส้นสแกนทั้งหมดโดยอินเดอร์เส้นสแกนที่ระบุ

public int[] ReadArgb32ScanLine(int scanLineIndex)

Parameters

scanLineIndex int

ดัชนีการสแกนแบบ Zero Based

Returns

int [ ]

สายการสแกน 32 บิต ARGB หมายเลขสี

ReadScanLine(int)

อ่านเส้นสแกนทั้งหมดโดยอินเดอร์เส้นสแกนที่ระบุ

public Color[] ReadScanLine(int scanLineIndex)

Parameters

scanLineIndex int

ดัชนีการสแกนแบบ Zero Based

Returns

Color [ ]

สายการสแกนสี pixel หมายเลข

ReleaseManagedResources()

เปิดตัวทรัพยากรที่จัดการ ตรวจสอบให้แน่ใจว่าไม่มีทรัพยากรที่ไม่ได้จัดการจะเปิดตัวที่นี่เนื่องจากอาจมีการเปิดตัวแล้ว

protected override void ReleaseManagedResources()

RemoveMetadata()

ลบตัวอย่างภาพนี้ metadata โดยการตั้งค่า Aspose.Imaging.Xmp.IHasXMPData.xmp หมายเลขนี้ 0 0 0.

public override void RemoveMetadata()

ReplaceColor(สี, byte, สี)

เปลี่ยนสีหนึ่งกับสีอื่น ๆ ด้วยความแตกต่างที่อนุญาตและรักษาค่าอัลฟาเดิมเพื่อบันทึกขอบเรียบ

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

Parameters

oldColor Color

สีเก่าที่จะถูกแทนที่

oldColorDiff byte

อนุญาตให้แตกต่างในสีเก่าเพื่อให้สามารถขยายสีที่ถูกแทนที่

newColor Color

สีใหม่เพื่อแทนที่สีเก่าด้วย

ReplaceColor(int, byte, int)

เปลี่ยนสีหนึ่งกับสีอื่น ๆ ด้วยความแตกต่างที่อนุญาตและรักษาค่าอัลฟาเดิมเพื่อบันทึกขอบเรียบ

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

Parameters

oldColorArgb int

สีเก่า ARGB หมายเลขจะถูกแทนที่

oldColorDiff byte

อนุญาตให้แตกต่างในสีเก่าเพื่อให้สามารถขยายสีที่ถูกแทนที่

newColorArgb int

สีใหม่ค่า ARGB เพื่อเปลี่ยนสีเก่าด้วย

ReplaceNonTransparentColors(Color)

เปลี่ยนสีที่ไม่โปร่งใสทั้งหมดด้วยสีใหม่และรักษาค่าอัลฟาเดิมเพื่อบันทึกขอบเรียบหมายเหตุ: หากคุณใช้ภาพโดยไม่มีความโปร่งใสสีทั้งหมดจะถูกแทนที่ด้วยสีเดียว

public void ReplaceNonTransparentColors(Color newColor)

Parameters

newColor Color

สีใหม่เพื่อแทนที่สีที่ไม่โปร่งใสด้วย

ReplaceNonTransparentColors(int)

เปลี่ยนสีที่ไม่โปร่งใสทั้งหมดด้วยสีใหม่และรักษาค่าอัลฟาเดิมเพื่อบันทึกขอบเรียบหมายเหตุ: หากคุณใช้ภาพโดยไม่มีความโปร่งใสสีทั้งหมดจะถูกแทนที่ด้วยสีเดียว

public virtual void ReplaceNonTransparentColors(int newColorArgb)

Parameters

newColorArgb int

สีใหม่ค่า ARGB เพื่อแทนที่สีที่ไม่โปร่งใสด้วย

Resize(int, int, ImageResizeSettings)

รีไซเคิลภาพด้วยตัวเลือกที่ขยาย

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

Parameters

newWidth int

ความกว้างใหม่

newHeight int

ความสูงใหม่

settings ImageResizeSettings

การตั้งค่ารีไซเคิล

Examples

ตัวอย่างนี้โหลดภาพเรสเตอร์และรีไซเคิลโดยใช้การตั้งค่ารีไซเคิลต่างๆ

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

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

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

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

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

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

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

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

Rotate(บอล, บอล, สี)

ภาพหมุนรอบศูนย์กลาง

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

Parameters

angle float

มุมหมุนในเกรด หมายเลขเชิงบวกจะหมุนตามชั่วโมง

resizeProportionally bool

ถ้าคุณตั้งค่าเป็น “จริง” คุณจะมีการเปลี่ยนแปลงขนาดภาพของคุณตามแนวตั้งหมุน (จุดมุม) projections ในกรณีอื่น ๆ ที่ปล่อยให้ขนาดไม่สัมผัสและเนื้อหาภาพภายในเท่านั้นจะหมุน

backgroundColor Color

สีของพื้นหลัง

Exceptions

NotImplementedException

การยกเว้นที่ไม่ได้นําไปใช้

Rotate(เฟอร์รี่)

ภาพหมุนรอบศูนย์กลาง

public override void Rotate(float angle)

Parameters

angle float

มุมหมุนในเกรด หมายเลขเชิงบวกจะหมุนตามชั่วโมง

Save(กระแส, ImageOptionsBase, Rectangle)

บันทึกข้อมูลของภาพไปยังกระแสที่ระบุในรูปแบบไฟล์ที่ระบุตามตัวเลือกการบันทึก

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

Parameters

stream Stream

กระแสเพื่อบันทึกข้อมูลของภาพ

optionsBase ImageOptionsBase

ตัวเลือกการประหยัด

boundsRectangle Rectangle

ภาพจุดหมายปลายทางขอบขอบขอบ ปรับขอบขอบที่ว่างเปล่าเพื่อใช้ขอบแหล่ง

SaveArgb32Pixels(ก้น, int[])

เก็บ 32 บิต ARGB พิกเซล

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

Parameters

rectangle Rectangle

ตรงเพื่อบันทึก pixels ไปยัง

pixels int [ ]

32 บิต ARGB pixels array

Examples

ตัวอย่างต่อไปนี้เติมพื้นที่กลางของภาพเรสเตอร์ด้วยพิกเซลสีดําโดยใช้วิธีการ Aspose.Imaging.RasterImage.SaveArgb32Pixels

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

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

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

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

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

SaveCmyk32Pixels(ก้น, int[])

เก็บ pixels

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

Parameters

rectangle Rectangle

ตรงเพื่อบันทึก pixels ไปยัง

pixels int [ ]

พิกเซล CMYK ได้รับการนําเสนอเป็นค่าที่สมบูรณ์ 32 บิต

Examples

ตัวอย่างต่อไปนี้เติมพื้นที่กลางของภาพเรสเตอร์ด้วยพิกเซลสีดําโดยใช้วิธีการ Aspose.Imaging.RasterImage.SaveCmyk32Pixels

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

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

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

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

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

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

SaveCmykPixels(ใบมีด CmykColor[])

เก็บ pixelsวิธีการนี้ถูกลดลง โปรดใช้วิธีการ Aspose.Imaging.RasterImage.SaveCmyk32Pixels(Aspose.Imaging.Rectangle,System.Int32[]) อย่างมีประสิทธิภาพมากขึ้น

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

Parameters

rectangle Rectangle

ตรงเพื่อบันทึก pixels ไปยัง

pixels CmykColor [ ]

CMYK pixels array

SavePixels(ตูดสี[])

เก็บ pixels

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

Parameters

rectangle Rectangle

ตรงเพื่อบันทึก pixels ไปยัง

pixels Color [ ]

ชิ้นส่วนของ Pixel Array

Examples

ตัวอย่างต่อไปนี้เติมพื้นที่กลางของภาพเรสเตอร์ด้วยพิกเซลสีดําโดยใช้วิธีการ Aspose.Imaging.RasterImage.SavePixels

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

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

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

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

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

ตัวอย่างนี้แสดงให้เห็นถึงวิธีการโหลดข้อมูล Pixel ใน Array ของ Type Color การจัดการ array และตั้งค่ากลับไปยังภาพ ในการดําเนินการเหล่านี้ ตัวอย่างนี้สร้างไฟล์ภาพใหม่ (ในรูปแบบ GIF) uisng วัตถุ MemoryStream

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

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

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

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

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

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

SaveRawData(บิต[ ], int, Rectangle, RawDataSettings)

เก็บข้อมูลวัตถุดิบ

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

Parameters

data byte [ ]

ข้อมูลพื้นฐาน

dataOffset int

การเริ่มต้นข้อมูลวัตถุดิบจะลดลง

rectangle Rectangle

ทิศทางของข้อมูลดิบ

rawDataSettings RawDataSettings

การตั้งค่าข้อมูลวัตถุดิบที่ข้อมูลอยู่ใน

SetArgb32Pixel(int, int, int)

สร้างภาพ 32 บิต ARGB pixel สําหรับตําแหน่งที่ระบุ

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

Parameters

x int

พิกเซล x ตําแหน่ง

y int

พิกเซล Y ตําแหน่ง

argb32Color int

พิกเซล ARGB 32 บิตสําหรับตําแหน่งที่ระบุ

Examples

ตัวอย่างต่อไปนี้โหลดภาพสกรูและกําหนดสีของพิกเซลที่กําหนดเอง

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

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

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

SetPalette(IColorPalette, บอล)

สร้างภาพแพลตฟอร์ม

public override void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

แพลิเคชันที่กําหนดไว้

updateColors bool

หากกําหนดสี “จริง” จะได้รับการปรับปรุงตามแพลตฟอร์มใหม่; ในทางอื่น ๆ ตัวชี้วัดสีจะยังคงไม่เปลี่ยนแปลง. โปรดทราบว่าตัวชี้วัดที่ไม่ได้เปลี่ยนแปลงอาจรบกวนภาพบนโหลดถ้าบางตัวชี้วัดไม่มีรายการแพลตฟอร์มที่เกี่ยวข้อง.

SetPixel(int, int, สี)

ตั้งภาพ pixel สําหรับตําแหน่งที่ระบุ

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

Parameters

x int

พิกเซล x ตําแหน่ง

y int

พิกเซล Y ตําแหน่ง

color Color

สีพิกเซลสําหรับตําแหน่งที่ระบุ

Examples

ตัวอย่างต่อไปนี้โหลดภาพสกรูและกําหนดสีของพิกเซลที่กําหนดเอง

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

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

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

SetResolution(คู่, คู่)

สร้างความละเอียดสําหรับ Aspose.Imaging.RasterImage นี้

public virtual void SetResolution(double dpiX, double dpiY)

Parameters

dpiX double

ความละเอียดแนวนอนในจุดต่อ นิ้วของ Aspose.Imaging.RasterImage

dpiY double

ความละเอียดแนวตั้งในจุดต่อ นิ้วของ Aspose.Imaging.RasterImage

Examples

ตัวอย่างต่อไปนี้แสดงให้เห็นวิธีการตั้งค่าความละเอียดแนวนอน/แนวตั้งของภาพเรสเตอร์

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

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

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

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

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

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

ToBitmap()

แปลงภาพ raster ไปยัง bitmapวิธีการนี้ไม่ได้รับการสนับสนุนในเวอร์ชันจาก .Net7.0 และสูงกว่า

public virtual Bitmap ToBitmap()

Returns

Bitmap

บิตการ์ด

UpdateDimensions(int, int)

ปรับปรุงขนาดภาพ

protected abstract void UpdateDimensions(int newWidth, int newHeight)

Parameters

newWidth int

ความกว้างของภาพใหม่

newHeight int

ความสูงของภาพใหม่

UpdateMetadata()

การอัปเดตของภาพ metadata

protected virtual void UpdateMetadata()

WriteArgb32ScanLine(int, int[])

เขียนเส้นสแกนทั้งหมดไปยังดัชนีเส้นสแกนที่ระบุ

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

Parameters

scanLineIndex int

ดัชนีการสแกนแบบ Zero Based

argb32Pixels int [ ]

สี ARGB 32 บิตสามารถเขียนได้

WriteScanLine(int, สี[])

เขียนเส้นสแกนทั้งหมดไปยังดัชนีเส้นสแกนที่ระบุ

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

Parameters

scanLineIndex int

ดัชนีการสแกนแบบ Zero Based

pixels Color [ ]

สีพิกเซลพร้อมที่จะเขียน

 แบบไทย