Class Image

Class Image

İsim alanı : Aspose.Imaging Toplantı: Aspose.Imaging.dll (25.4.0)

Görüntü, her türlü görüntü için temel sınıfıdır.

[JsonObject(MemberSerialization.OptIn)]
public abstract class Image : DataStreamSupporter, IDisposable, IObjectWithBounds

Inheritance

object DisposableObject DataStreamSupporter Image

Derived

RasterImage , VectorImage

Implements

IDisposable , IObjectWithBounds

mirasçı üyeleri

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

Paletin resim tarafından kullanıldığını belirleyin.

using (var image = Image.Load(folder + "Sample.bmp"))
                                                         {
                                                             if (image.UsePalette)
                                                             {
                                                                 Console.WriteLine("The palette is used by the image");
                                                             }
                                                         }

Resize özel resize türü kullanarak resize görüntü.

using (var image = Image.Load("Photo.jpg"))
                                                   {
                                                       image.Resize(640, 480, ResizeType.CatmullRom);
                                                       image.Save("ResizedPhoto.jpg");

                                                       image.Resize(1024, 768, ResizeType.CubicConvolution);
                                                       image.Save("ResizedPhoto2.jpg");

                                                       var resizeSettings = new ImageResizeSettings
                                                       {
                                                           Mode = ResizeType.CubicBSpline,
                                                           FilterType = ImageFilterType.SmallRectangular
                                                       };

                                                       image.Resize(800, 800, resizeSettings);
                                                       image.Save("ResizedPhoto3.jpg");
                                                   }

Bu örnek, BmpOptions örneğinin Kaynak özellikleri tarafından belirtildiği gibi bir disk konumunda yeni bir Görüntü dosyası oluşturur. BmpOptions örneğinin çeşitli özellikleri gerçek görüntü oluşturmadan önce ayarlanır.

//Create an instance of BmpOptions and set its various properties
                                                                                                                                                                                                                                                                                                             Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                                                                                                                                                                                                                                                                                                             bmpOptions.BitsPerPixel = 24;

                                                                                                                                                                                                                                                                                                             //Create an instance of FileCreateSource and assign it as Source for the instance of BmpOptions
                                                                                                                                                                                                                                                                                                             //Second Boolean parameter determines if the file to be created IsTemporal or not
                                                                                                                                                                                                                                                                                                             bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\output.bmp", false);

                                                                                                                                                                                                                                                                                                             //Create an instance of Image and initialize it with instance of BmpOptions by calling Create method
                                                                                                                                                                                                                                                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                 //do some image processing

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

Constructors

Image()

Aspose.Imaging.Image sınıfının yeni bir örneğini başlatır.

[JsonConstructor]
protected Image()

Image(İKOLORPALETİ)

Aspose.Imaging.Image sınıfının yeni bir örneğini başlatır.

protected Image(IColorPalette colorPalette)

Parameters

colorPalette IColorPalette

Renk paleti var.

Properties

AutoAdjustPalette

Otomatik düzeltme paleti olup olmadığını gösteren bir değer alır veya ayarlar.

public bool AutoAdjustPalette { get; set; }

Mülkiyet Değer

bool

BackgroundColor

Arka plan rengi için bir değer alır veya ayarlar.

public virtual Color BackgroundColor { get; set; }

Mülkiyet Değer

Color

BitsPerPixel

Görüntü bitlerini piksel sayımına göre alır.

public abstract int BitsPerPixel { get; }

Mülkiyet Değer

int

Bounds

Görüntü sınırlarını alır.

public Rectangle Bounds { get; }

Mülkiyet Değer

Rectangle

BufferSizeHint

Tüm iç bufferler için maksimum izin verilen büyüklüğü belirleyen buffer boyutu ipucu alır veya ayarlar.

public int BufferSizeHint { get; set; }

Mülkiyet Değer

int

Container

Aspose.Imaging.Image konteynerini kullanın.

public Image Container { get; }

Mülkiyet Değer

Image

Remarks

Bu mülk sıfır değilse, görüntü başka bir görüntü içinde yer alır.

FileFormat

Dosya biçiminin değerini alır

public virtual FileFormat FileFormat { get; }

Mülkiyet Değer

FileFormat

HasBackgroundColor

Görüntünün arka plan rengi olup olmadığını gösteren bir değer alır veya ayarlar.

public virtual bool HasBackgroundColor { get; set; }

Mülkiyet Değer

bool

Height

Görüntü yüksekliğine sahiptir.

public abstract int Height { get; }

Mülkiyet Değer

int

InterruptMonitor

Monitörün kesilmesini veya kesilmesini sağlar.

public InterruptMonitor InterruptMonitor { get; set; }

Mülkiyet Değer

InterruptMonitor

Palette

Renk paleti alınır veya ayarlanır.Renk paleti doğrudan piksel olarak temsil edildiğinde kullanılmaz.

public IColorPalette Palette { get; set; }

Mülkiyet Değer

IColorPalette

Size

Görüntü boyutunu alır.

public Size Size { get; }

Mülkiyet Değer

Size

Examples

Bu örnek, bir dosya akışından bir DJVU görüntüsünü nasıl yükleyeceğinizi ve sayfalar hakkında bilgi nasıl yazdırılacağını gösterir.

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

UsePalette

Görüntü paleti kullanıldığını gösteren bir değer alır.

public virtual bool UsePalette { get; }

Mülkiyet Değer

bool

Examples

Paletin resim tarafından kullanıldığını belirleyin.

using (var image = Image.Load(folder + "Sample.bmp"))
                                                         {
                                                             if (image.UsePalette)
                                                             {
                                                                 Console.WriteLine("The palette is used by the image");
                                                             }
                                                         }

Width

Görüntü genişliğine sahiptir.

public abstract int Width { get; }

Mülkiyet Değer

int

Methods

CanLoad(Sırt)

Görüntünün belirlenmiş dosya yolundan yüklenebileceğini belirler.

public static bool CanLoad(string filePath)

Parameters

filePath string

Dosya Yolu.

Returns

bool

‘gerçek’ eğer görüntü belirtilen dosyadan yüklenebilir; aksi takdirde, ‘yanlış’.

Examples

Bu örnek, bir dosyadan görüntü yükleme olup olmadığını belirler.

// Use an absolute path to the file
                                                                           bool canLoad = Aspose.Imaging.Image.CanLoad(@"c:\temp\sample.gif");

CanLoad(Çerçeve, LoadOptions)

Görüntü belirlenen dosya yolundan yüklenebilir olup olmadığını belirler ve seçmeli olarak belirlenen açık seçenekleri kullanır.

public static bool CanLoad(string filePath, LoadOptions loadOptions)

Parameters

filePath string

Dosya Yolu.

loadOptions LoadOptions

Yükleme seçenekleri için.

Returns

bool

‘gerçek’ eğer görüntü belirtilen dosyadan yüklenebilir; aksi takdirde, ‘yanlış’.

CanLoad(Stream)

Görüntünün belirtilen akımdan yüklenebileceğini belirler.

public static bool CanLoad(Stream stream)

Parameters

stream Stream

Üretmek için bir akım.

Returns

bool

‘gerçek’ eğer görüntü belirtilen akımdan yüklenebilir; aksi takdirde, ‘yanlış’.

Examples

Bu örnek, bir dosya akışından görüntü yükleme olup olmadığını belirler.

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

                                                                                  bool canLoad;

                                                                                  // Use a file stream
                                                                                  using (System.IO.FileStream stream = System.IO.File.OpenRead(dir + "sample.bmp"))
                                                                                  {
                                                                                      canLoad = Aspose.Imaging.Image.CanLoad(stream);
                                                                                  }

                                                                                  // The following data is not a valid image stream, so CanLoad returns false.
                                                                                  byte[] imageData = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 };
                                                                                  using (System.IO.MemoryStream stream = new System.IO.MemoryStream(imageData))
                                                                                  {
                                                                                      canLoad = Aspose.Imaging.Image.CanLoad(stream);
                                                                                  }

CanLoad(Çıkış, LoadOptions)

Görüntü belirlenmiş akımdan yüklenebilir olup olmadığını belirler ve seçmeli olarak belirlenen <kod sınıfı=“paramref”>loadOptions’ı kullanır.

public static bool CanLoad(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

Üretmek için bir akım.

loadOptions LoadOptions

Yükleme seçenekleri için.

Returns

bool

‘gerçek’ eğer görüntü belirtilen akımdan yüklenebilir; aksi takdirde, ‘yanlış’.

CanSave(ImageOptionsBase)

Görüntünün geçmiş kaydetme seçenekleri tarafından temsil edilen belirli dosya biçimine kaydedilebilir olup olmadığını belirler.

public bool CanSave(ImageOptionsBase options)

Parameters

options ImageOptionsBase

Kullanmak için tasarruf seçenekleri.

Returns

bool

‘gerçek’ eğer görüntü geçmiş kaydetme seçenekleri tarafından temsil edilen dosya biçiminde kaydedilebilir; aksi takdirde, ‘yanlış’.

Examples

Bu örnek, geçmiş kaydetme seçenekleri tarafından temsil edilen dosya biçiminde görüntü kaydedilebilir olup olmadığını nasıl belirleyeceğini gösterir.

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

                                                                                                                                              using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                              {
                                                                                                                                                  Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();
                                                                                                                                                  saveOptions.Quality = 50;

                                                                                                                                                  // Determine whether the image can be saved to Jpeg
                                                                                                                                                  bool canSave = image.CanSave(saveOptions);
                                                                                                                                              }

Create(ImageOptionsBase, int, int)

Yeni bir görüntü oluşturmak, belirtilen oluşturma seçeneklerini kullanarak.

public static Image Create(ImageOptionsBase imageOptions, int width, int height)

Parameters

imageOptions ImageOptionsBase

Görüntü seçenekleri.

width int

Genişlik için.

height int

Yükseklik için.

Returns

Image

Yeni oluşturulan görüntü.

Examples

Bu örnek, BmpOptions örneğinin Kaynak özellikleri tarafından belirtildiği gibi bir disk konumunda yeni bir Görüntü dosyası oluşturur. BmpOptions örneğinin çeşitli özellikleri gerçek görüntü oluşturmadan önce ayarlanır.

//Create an instance of BmpOptions and set its various properties
                                                                                                                                                                                                                                                                                                             Aspose.Imaging.ImageOptions.BmpOptions bmpOptions = new Aspose.Imaging.ImageOptions.BmpOptions();
                                                                                                                                                                                                                                                                                                             bmpOptions.BitsPerPixel = 24;

                                                                                                                                                                                                                                                                                                             //Create an instance of FileCreateSource and assign it as Source for the instance of BmpOptions
                                                                                                                                                                                                                                                                                                             //Second Boolean parameter determines if the file to be created IsTemporal or not
                                                                                                                                                                                                                                                                                                             bmpOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\temp\output.bmp", false);

                                                                                                                                                                                                                                                                                                             //Create an instance of Image and initialize it with instance of BmpOptions by calling Create method
                                                                                                                                                                                                                                                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(bmpOptions, 500, 500))
                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                 //do some image processing

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

Create(Image[])

Yeni bir görüntü oluşturmak sayfalar olarak belirtilen görüntüleri kullanarak

public static Image Create(Image[] images)

Parameters

images Image […]

Görüntüler için .

Returns

Image

Görüntüleme imultipageImage

Create(MultipageCreateOptions)

Belirlenmiş çok sayfa oluşturma seçenekleri oluşturur.

public static Image Create(MultipageCreateOptions multipageCreateOptions)

Parameters

multipageCreateOptions MultipageCreateOptions

Çeşitli sayfa seçenekleri oluşturur.

Returns

Image

Çok sayfalık görüntü

Create(Sırt[…], Bool için)

Belirlenen dosyaları içeren çok sayfalık görüntü oluşturur.

public static Image Create(string[] files, bool throwExceptionOnLoadError)

Parameters

files string […]

Bu dosyaları .

throwExceptionOnLoadError bool

eğer “gerçek” olarak ayarlanırsa [şarj hatası için istisna atın].

Returns

Image

Çok sayfalık görüntü

Create(Sırt[])

Belirlenen dosyaları içeren çok sayfalık görüntü oluşturur.

public static Image Create(string[] files)

Parameters

files string […]

Bu dosyaları .

Returns

Image

Çok sayfalık görüntü

Create(Image[…], Bool için)

Yeni bir görüntü sayfalar olarak belirtilen görüntüleri oluşturur.

public static Image Create(Image[] images, bool disposeImages)

Parameters

images Image […]

Görüntüler için .

disposeImages bool

Eğer “gerçek” olarak ayarlanırsa [görüntüleri mevcuttur].

Returns

Image

Görüntüleme imultipageImage

Crop(Rectangle)

Belirlenmiş rektangleyi kırar.

public virtual void Crop(Rectangle rectangle)

Parameters

rectangle Rectangle

Doğrudan bir şekilde.

Examples

Aşağıdaki örnekte bir raster görüntüsü toplanır. toplanma alanı Aspose.Imaging.Rectangle aracılığıyla belirtilir.

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

                                                                                                                      using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                      {
                                                                                                                          // Crop the image. The cropping area is the rectangular central area of the image.
                                                                                                                          Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(rasterImage.Width / 4, rasterImage.Height / 4, rasterImage.Width / 2, rasterImage.Height / 2);
                                                                                                                          image.Crop(area);

                                                                                                                          // Save the cropped image to PNG
                                                                                                                          image.Save(dir + "sample.Crop.png");
                                                                                                                      }

Crop(int , int , int , int , int)

Bitki görüntüsü değişkenlik ile.

public virtual void Crop(int leftShift, int rightShift, int topShift, int bottomShift)

Parameters

leftShift int

Sağdaki değişim.

rightShift int

Doğru değişim için.

topShift int

Yukarıdaki değişim.

bottomShift int

Aşağıdaki değişim.

Examples

Aşağıdaki örnekte bir raster görüntüsü toplanır. toplanma alanı Sol, Üst, Sağ, Alt marjları aracılığıyla belirtilir.

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

                                                                                                                           using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
                                                                                                                           {
                                                                                                                               // Crop again. Set a margin of 10% of the image size.
                                                                                                                               int horizontalMargin = rasterImage.Width / 10;
                                                                                                                               int verticalMargin = rasterImage.Height / 10;
                                                                                                                               image.Crop(horizontalMargin, horizontalMargin, verticalMargin, verticalMargin);

                                                                                                                               // Save the cropped image to PNG.
                                                                                                                               image.Save(dir + "sample.Crop.png");
                                                                                                                           }

~Image()

protected ~Image()

GetCanNotSaveMessage(ImageOptionsBase)

Mesajı kurtaramıyor, mesajı kurtaramıyor.

protected virtual string GetCanNotSaveMessage(ImageOptionsBase optionsBase)

Parameters

optionsBase ImageOptionsBase

Görüntü seçenekleri.

Returns

string

Mesajı kurtaramazsınız.

GetDefaultOptions(nesne[])

Default seçenekleri alınır.

public virtual ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object […]

ve argümanları.

Returns

ImageOptionsBase

Default seçenekleri

GetFileFormat(Sırt)

Dosya formatını alır.

public static FileFormat GetFileFormat(string filePath)

Parameters

filePath string

Dosya Yolu.

Returns

FileFormat

Belirli dosya biçimi.

Examples

Bu örnek, bir dosyadan tüm görüntü yüklemeden görüntü biçimini nasıl belirleyeceğinizi gösterir.

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

                                                                                                             // Use an absolute path to the file
                                                                                                             Aspose.Imaging.FileFormat format = Aspose.Imaging.Image.GetFileFormat(dir + "sample.gif");
                                                                                                             System.Console.WriteLine("The file format is {0}", format);

Remarks

Belirlenen dosya biçimi, belirlenen görüntünün yüklenebileceği anlamına gelmez. dosya yüklenebilir olup olmadığını belirlemek için CanLoad yönteminden birini kullanın.

GetFileFormat(Stream)

Dosya formatını alır.

public static FileFormat GetFileFormat(Stream stream)

Parameters

stream Stream

akış için.

Returns

FileFormat

Belirli dosya biçimi.

Examples

Bu örnek, bir dosya akışından tüm görüntüyü yüklemeden görüntü biçimini nasıl belirleyeceğinizi gösterir.

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

                                                                                                                    // Use a file stream
                                                                                                                    using (System.IO.FileStream stream = System.IO.File.OpenRead(dir + "sample.bmp"))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.FileFormat format = Aspose.Imaging.Image.GetFileFormat(stream);
                                                                                                                        System.Console.WriteLine("The file format is {0}", format);
                                                                                                                    }

                                                                                                                    // The following data is not a valid image stream, so GetFileFormat returns FileFormat.Undefined.
                                                                                                                    byte[] imageData = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 };
                                                                                                                    using (System.IO.MemoryStream stream = new System.IO.MemoryStream(imageData))
                                                                                                                    {
                                                                                                                        Aspose.Imaging.FileFormat format = Aspose.Imaging.Image.GetFileFormat(stream);
                                                                                                                        System.Console.WriteLine("The file format is {0}", format);
                                                                                                                    }

Remarks

Belirlenen dosya biçimi, belirtilen görüntünün yüklenebileceği anlamına gelmez. CanLoad yönteminden birini kullanarak akışın yüklenebileceğini belirleyebilirsiniz.

GetFitRectangle(Rectangle)

Mevcut görüntüye uygun bir düz açı elde eder.

protected Rectangle GetFitRectangle(Rectangle rectangle)

Parameters

rectangle Rectangle

Doğrudan doğrudan doğru doğru doğru doğru doğru doğru doğru doğru.

Returns

Rectangle

Doğru düzlem

GetFitRectangle(Çerçeve , int[])

Geçmiş pikselleri göz önünde bulundurarak mevcut bit haritasına uygun bir düz açı elde edilir. Geçmiş piksel array sayısı uygun düz açı boyutuna eşit olmalıdır.

protected Rectangle GetFitRectangle(Rectangle rectangle, int[] pixels)

Parameters

rectangle Rectangle

Doğrudan doğrudan doğru doğru doğru doğru doğru doğru doğru doğru.

pixels int […]

32 bit ARGB piksel array.

Returns

Rectangle

Uygun bir düzlem.

GetFittingRectangle(Çerçeve, int, int)

Mevcut görüntüye uygun bir düz açı elde eder.

public static Rectangle GetFittingRectangle(Rectangle rectangle, int width, int height)

Parameters

rectangle Rectangle

Doğrudan doğrudan doğru doğru doğru doğru doğru doğru doğru doğru.

width int

nesne genişliği vardır.

height int

nesne yüksekliği.

Returns

Rectangle

Uygun düz açı veya istisna, uygun düz açı bulunamazsa.

GetFittingRectangle(Çerçeve , int[…], int , int)

Mevcut görüntüye uygun bir düz açı elde eder.

public static Rectangle GetFittingRectangle(Rectangle rectangle, int[] pixels, int width, int height)

Parameters

rectangle Rectangle

Doğrudan doğrudan doğru doğru doğru doğru doğru doğru doğru doğru.

pixels int […]

32 bit ARGB piksel.

width int

nesne genişliği vardır.

height int

nesne yüksekliği.

Returns

Rectangle

Uygun düz açı veya istisna, uygun düz açı bulunamazsa.

GetImage2Export(ImageOptionsBase, Rectangle ve IImageExporter)

Görüntüleri ihraç etmek için kullanın.

[Obsolete("Will be changed by method with other signature")]
protected virtual Image GetImage2Export(ImageOptionsBase optionsBase, Rectangle boundsRectangle, IImageExporter exporter)

Parameters

optionsBase ImageOptionsBase

Görüntü seçenekleri taban.

boundsRectangle Rectangle

Sınırları düz açılıyor.

exporter IImageExporter

Bir ihracatçı.

Returns

Image

Görüntüleri ihraç etmek

GetOriginalOptions()

Orijinal dosya ayarlarına göre seçenekleri alır.Bu, bit derinliği ve orijinal görüntünün diğer parametrelerini değişmez tutmak için yararlı olabilir.Örneğin, bir piksel başına 1 bit ile siyah beyaz bir PNG görüntüsünü yüklerseniz ve sonra kaydedin.Aspose.Imaging.DataStreamSupporter.Save(System.String) yöntemi, piksel başına 8 bit çıkış PNG görüntüsü üretilecektir.Bunu önlemek ve piksel başına 1 bit PNG görüntüsünü kaydetmek için, bu yöntemi uygun tasarruf seçenekleri elde etmek ve bunları geçmek için kullanınAspose.Imaging.Image.Save (System.String,Aspose.Imaging.ImageOptionsBase) yöntemi ikinci parametredir.

public virtual ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

Orijinal dosya ayarlarına dayalı seçenekler.

GetProportionalHeight(int , int , int , int)

Orantılı bir yükseklik alır.

public static int GetProportionalHeight(int width, int height, int newWidth)

Parameters

width int

Genişlik için.

height int

Yükseklik için.

newWidth int

Yeni bir genişlik.

Returns

int

Yükseklik orantılıdır.

GetProportionalWidth(int , int , int , int)

Orantılı genişliğe sahiptir.

public static int GetProportionalWidth(int width, int height, int newHeight)

Parameters

width int

Genişlik için.

height int

Yükseklik için.

newHeight int

Yeni bir yükseklik.

Returns

int

Orantılı genişlik için.

GetSerializedStream(ImageOptionsBase, Rectangle, dışarı int)

Aps’e dönüştürülür.

public virtual Stream GetSerializedStream(ImageOptionsBase imageOptions, Rectangle clippingRectangle, out int pageNumber)

Parameters

imageOptions ImageOptionsBase

Görüntü seçenekleri.

clippingRectangle Rectangle

Yüzük düzlemini yaptırın.

pageNumber int

sayfa sayısı için.

Returns

Stream

serializasyon akışı

Load(Çerçeve, LoadOptions)

Belirlenen dosya yolundan veya URL’den yeni bir görüntü yüklenir.Eğer filePath’ bir dosya yolu ise yöntemi sadece dosyayı açır.Eğer filePath’ bir URL ise, yöntemi dosyayı indir, geçici bir olarak kaydeder ve açır.

public static Image Load(string filePath, LoadOptions loadOptions)

Parameters

filePath string

Dosya yolu veya görüntü yüklemek için URL.

loadOptions LoadOptions

Yükleme seçenekleri için.

Returns

Image

yüklenmiş görüntü.

Load(Sırt)

Belirlenen dosya yolundan veya URL’den yeni bir görüntü yüklenir.Eğer filePath’ bir dosya yolu ise yöntemi sadece dosyayı açır.Eğer filePath’ bir URL ise, yöntemi dosyayı indir, geçici bir olarak kaydeder ve açır.

public static Image Load(string filePath)

Parameters

filePath string

Dosya yolu veya görüntü yüklemek için URL.

Returns

Image

yüklenmiş görüntü.

Examples

Bu örnek, mevcut bir Görüntü dosyasının Aspose.Imaging.Image örneğine yüklendiğini gösterir.

//Create Image instance and initialize it with an existing image file from disk location
                                                                                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"C:\temp\sample.bmp"))
                                                                                                                                             {
                                                                                                                                                 //do some image processing
                                                                                                                                             }

Load(Çıkış, LoadOptions)

Belirlenen akımdan yeni bir görüntü yüklenir.

public static Image Load(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

Görüntüyü yüklemek için akış.

loadOptions LoadOptions

Yükleme seçenekleri için.

Returns

Image

yüklenmiş görüntü.

Load(Stream)

Belirlenen akımdan yeni bir görüntü yüklenir.

public static Image Load(Stream stream)

Parameters

stream Stream

Görüntüyü yüklemek için akış.

Returns

Image

yüklenmiş görüntü.

Examples

Bu örnek, mevcut bir Görüntü dosyasını yüklemek için System.IO.Stream nesnelerinin kullanıldığını gösterir.

//Create an instance of FileStream
                                                                                                       using (System.IO.FileStream stream = new System.IO.FileStream(@"C:\temp\sample.bmp", System.IO.FileMode.Open))
                                                                                                       {
                                                                                                           //Create an instance of Image class and load an existing file through FileStream object by calling Load method
                                                                                                           using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(stream))
                                                                                                           {
                                                                                                               //do some image processing.
                                                                                                           }
                                                                                                       }

OnPaletteChanged(İKOLOR, İKOLOR İKOLOR)

Palet değiştirildiğinde arama yapılır.

protected virtual void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette

O eski palet.

newPalette IColorPalette

Yeni palet için.

OnPaletteChanging(İKOLOR, İKOLOR İKOLOR)

Palet değiştiğinde söylenir.

protected virtual void OnPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette

O eski palet.

newPalette IColorPalette

Yeni palet için.

ReleaseManagedResources()

Yönetilen kaynakları serbest bırakın. yönetilmemiş kaynakların burada serbest bırakılmadığından emin olun, çünkü zaten serbest bırakılmış olabilirler.

protected override void ReleaseManagedResources()

RemoveMetadata()

Metadata çıkarmak için.

public virtual void RemoveMetadata()

Resize(int , int , int)

Görüntüyü yeniden oluşturur. varsayılan Aspose.Imaging.ResizeType.NearestNeighbourResample kullanılır.

public void Resize(int newWidth, int newHeight)

Parameters

newWidth int

Yeni bir genişlik.

newHeight int

Yeni bir yükseklik.

Examples

Aşağıdaki örnek, bir metafilin (WMF ve EMF) nasıl yeniden ölçüldüğünü gösterir.

string dir = "c:\\aspose.imaging\\issues\\net\\3280\\";
                                                                              string[] fileNames = new[] { "image3.emf", "image4.wmf" };
                                                                              foreach (string fileName in fileNames)
                                                                              {
                                                                                  string inputFilePath = dir + fileName;
                                                                                  string outputFilePath = dir + "Downscale_" + fileName;

                                                                                  using (Aspose.Imaging.FileFormats.Emf.MetaImage image = (Aspose.Imaging.FileFormats.Emf.MetaImage)Aspose.Imaging.Image.Load(inputFilePath))
                                                                                  {
                                                                                      image.Resize(image.Width / 4, image.Height / 4);
                                                                                      image.Save(outputFilePath);
                                                                                  }
                                                                              }

Aşağıdaki örnek SVG görüntüsünü yeniden boyamak ve PNG’ye kaydetmek için nasıl gösterilir.

string dir = "c:\\aspose.imaging\\net\\issues\\3549";
                                                                                  string[] fileNames = new string[]
                                                                                  {
                                                                                      "Logotype.svg",
                                                                                      "sample_car.svg",
                                                                                      "rg1024_green_grapes.svg",
                                                                                      "MidMarkerFigure.svg",
                                                                                      "embeddedFonts.svg"
                                                                                  };

                                                                                  Aspose.Imaging.PointF[] scales = new Aspose.Imaging.PointF[]
                                                                                  {
                                                                                      new Aspose.Imaging.PointF(0.5f, 0.5f),
                                                                                      new Aspose.Imaging.PointF(1f, 1f),
                                                                                      new Aspose.Imaging.PointF(2f, 2f),
                                                                                      new Aspose.Imaging.PointF(3.5f, 9.2f),
                                                                                  };

                                                                                  foreach (string inputFile in fileNames)
                                                                                  {
                                                                                      foreach (Aspose.Imaging.PointF scale in scales)
                                                                                      {
                                                                                          string outputFile = string.Format("{0}_{1}_{2}.png", inputFile, scale.X.ToString(System.Globalization.CultureInfo.InvariantCulture), scale.Y.ToString(System.Globalization.CultureInfo.InvariantCulture));
                                                                                          using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(System.IO.Path.Combine(dir, inputFile)))
                                                                                          {
                                                                                              image.Resize((int)(image.Width * scale.X), (int)(image.Height * scale.Y));
                                                                                              image.Save(System.IO.Path.Combine(dir, outputFile), new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                          }
                                                                                      }
                                                                                  }

Resize(int, int, resizeType)

Görüntüyü yeniden canlandırır.

public virtual void Resize(int newWidth, int newHeight, ResizeType resizeType)

Parameters

newWidth int

Yeni bir genişlik.

newHeight int

Yeni bir yükseklik.

resizeType ResizeType

Resize türü vardır.

Examples

EPS görüntüsünü yeniden kaydedin ve PNG biçiminde ihraç edin.

// Load EPS image
                                                        using (var image = Image.Load("AstrixObelix.eps"))
                                                        {
                                                            // Resize the image using the Mitchell cubic interpolation method
                                                            image.Resize(400, 400, ResizeType.Mitchell);

                                                            // Export image to PNG format
                                                            image.Save("ExportResult.png", new PngOptions());
                                                        }

Resize özel resize türü kullanarak resize görüntü.

using (var image = Image.Load("Photo.jpg"))
                                                   {
                                                       image.Resize(640, 480, ResizeType.CatmullRom);
                                                       image.Save("ResizedPhoto.jpg");

                                                       image.Resize(1024, 768, ResizeType.CubicConvolution);
                                                       image.Save("ResizedPhoto2.jpg");

                                                       var resizeSettings = new ImageResizeSettings
                                                       {
                                                           Mode = ResizeType.CubicBSpline,
                                                           FilterType = ImageFilterType.SmallRectangular
                                                       };

                                                       image.Resize(800, 800, resizeSettings);
                                                       image.Save("ResizedPhoto3.jpg");
                                                   }

Bu örnek bir WMF görüntüsünü yükler ve çeşitli geri dönüşüm yöntemleri kullanılarak resize eder.

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

                                                                                        using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.wmf"))
                                                                                        {
                                                                                            // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                            image.Resize(image.Width * 2, image.Height * 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
                                                                                        }

                                                                                        using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.wmf"))
                                                                                        {
                                                                                            // Scale down by 2 times using Nearest Neighbour resampling.
                                                                                            image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
                                                                                        }

                                                                                        using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.wmf"))
                                                                                        {
                                                                                            // Scale up by 2 times using Bilinear resampling.
                                                                                            image.Resize(image.Width * 2, image.Height * 2, Aspose.Imaging.ResizeType.BilinearResample);
                                                                                        }

                                                                                        using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.wmf"))
                                                                                        {
                                                                                            // Scale down by 2 times using Bilinear resampling.
                                                                                            image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
                                                                                        }

Bu örnek bir resim yüklüyor ve çeşitli resim yöntemleri kullanarak resim yapıyor.

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

                                                                                     using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                     {
                                                                                         // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                         image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
                                                                                         image.Save(dir + "upsample.nearestneighbour.gif");
                                                                                     }

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

                                                                                     using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                     {
                                                                                         // Scale up by 2 times using Bilinear resampling.
                                                                                         image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);
                                                                                         image.Save(dir + "upsample.bilinear.gif");
                                                                                     }

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

Bu örnek bir raster görüntüsünü yükler ve çeşitli resize yöntemleri kullanılarak resize eder.

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

                                                                                           using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                           {
                                                                                               // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                               image.Resize(image.Width * 2, image.Height * 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
                                                                                               image.Save(dir + "upsample.nearestneighbour.gif");
                                                                                           }

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

                                                                                           using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                           {
                                                                                               // Scale up by 2 times using Bilinear resampling.
                                                                                               image.Resize(image.Width * 2, image.Height * 2, Aspose.Imaging.ResizeType.BilinearResample);
                                                                                               image.Save(dir + "upsample.bilinear.gif");
                                                                                           }

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

Bu örnek, çok sayfalık bir ODG görüntüsünü yüklenir ve çeşitli resize yöntemleri kullanılarak resize eder.

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

                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.odg"))
                                                                                                   {
                                                                                                       // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                                       image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                                       // Save to PNG with default options.
                                                                                                       image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                   }

                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.odg"))
                                                                                                   {
                                                                                                       // Scale down by 2 times using Nearest Neighbour resampling.
                                                                                                       image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                                       // Save to PNG with default options.
                                                                                                       image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                   }

                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.odg"))
                                                                                                   {
                                                                                                       // Scale up by 2 times using Bilinear resampling.
                                                                                                       image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);

                                                                                                       // Save to PNG with default options.
                                                                                                       image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                   }

                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.odg"))
                                                                                                   {
                                                                                                       // Scale down by 2 times using Bilinear resampling.
                                                                                                       image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);

                                                                                                       // Save to PNG with default options.
                                                                                                       image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                   }

Segmentasyon sürecini hızlandırmak için bir segment maskesi kullanın

// Masking export options
                                                                    Aspose.Imaging.ImageOptions.PngOptions exportOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                    exportOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
                                                                    exportOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());

                                                                    Aspose.Imaging.Masking.Options.MaskingOptions maskingOptions = new Aspose.Imaging.Masking.Options.MaskingOptions();

                                                                    // Use GraphCut clustering.
                                                                    maskingOptions.Method = Masking.Options.SegmentationMethod.GraphCut;
                                                                    maskingOptions.Decompose = false;
                                                                    maskingOptions.Args = new Aspose.Imaging.Masking.Options.AutoMaskingArgs();

                                                                    // The backgroung color will be transparent.
                                                                    maskingOptions.BackgroundReplacementColor = Aspose.Imaging.Color.Transparent;
                                                                    maskingOptions.ExportOptions = exportOptions;

                                                                    string dir = "c:\\temp\\";
                                                                    using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
                                                                    {
                                                                        Aspose.Imaging.Size imageSize = image.Size;

                                                                        // Reducing image size to speed up the segmentation process
                                                                        image.ResizeHeightProportionally(600, Aspose.Imaging.ResizeType.HighQualityResample);

                                                                        // Create an instance of the ImageMasking class.
                                                                        Aspose.Imaging.Masking.ImageMasking masking = new Aspose.Imaging.Masking.ImageMasking(image);

                                                                        // Divide the source image into several clusters (segments).
                                                                        using (Aspose.Imaging.Masking.Result.MaskingResult maskingResult = masking.Decompose(maskingOptions))
                                                                        {
                                                                            // Getting the foreground mask
                                                                            using (Aspose.Imaging.RasterImage foregroundMask = maskingResult[1].GetMask()) 
                                                                            {
                                                                                // Increase the size of the mask to the size of the original image
                                                                                foregroundMask.Resize(imageSize.Width, imageSize.Height, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                // Applying the mask to the original image to obtain a foreground segment
                                                                                using (Aspose.Imaging.RasterImage originImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
                                                                                {
                                                                                    Aspose.Imaging.Masking.ImageMasking.ApplyMask(originImage, foregroundMask, maskingOptions);
                                                                                    originImage.Save(dir + "BigImage_foreground.png", exportOptions);
                                                                                }
                                                                            }
                                                                        }
                                                                    }

Resize(int, int, ImageResizeSettings İndir)

Görüntüyü yeniden canlandırır.

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

Parameters

newWidth int

Yeni bir genişlik.

newHeight int

Yeni bir yükseklik.

settings ImageResizeSettings

Değerlendirme ayarları.

Examples

Resize özel resize türü kullanarak resize görüntü.

using (var image = Image.Load("Photo.jpg"))
                                                   {
                                                       image.Resize(640, 480, ResizeType.CatmullRom);
                                                       image.Save("ResizedPhoto.jpg");

                                                       image.Resize(1024, 768, ResizeType.CubicConvolution);
                                                       image.Save("ResizedPhoto2.jpg");

                                                       var resizeSettings = new ImageResizeSettings
                                                       {
                                                           Mode = ResizeType.CubicBSpline,
                                                           FilterType = ImageFilterType.SmallRectangular
                                                       };

                                                       image.Resize(800, 800, resizeSettings);
                                                       image.Save("ResizedPhoto3.jpg");
                                                   }

Gelişmiş ayarları kullanarak EPS görüntüsünü yeniden oluşturun.

// Load EPS image
                                                    using (var image = Image.Load("AstrixObelix.eps"))
                                                    {
                                                        // Resize the image using advanced resize settings
                                                        image.Resize(400, 400, new ImageResizeSettings
                                                        {
                                                            // Set the interpolation mode
                                                            Mode = ResizeType.LanczosResample,

                                                            // Set the type of the filter
                                                            FilterType = ImageFilterType.SmallRectangular,

                                                            // Sets the color compare method
                                                            ColorCompareMethod = ColorCompareMethod.Euclidian,

                                                            // Set the color quantization method
                                                            ColorQuantizationMethod = ColorQuantizationMethod.Popularity
                                                        });

                                                        // Export image to PNG format
                                                        image.Save("ExportResult.png", new PngOptions());
                                                    }

Bu örnek bir görüntü yükler ve çeşitli yeniden ayarları kullanılarak resize eder.

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

ResizeHeightProportionally(int ile)

Standart Aspose.Imaging.ResizeType.NearestNeighbourResample kullanılır.

public void ResizeHeightProportionally(int newHeight)

Parameters

newHeight int

Yeni bir yükseklik.

ResizeHeightProportionally(ResizeType , ResizeType)

Yüksekliği orantılı olarak azaltır.

public virtual void ResizeHeightProportionally(int newHeight, ResizeType resizeType)

Parameters

newHeight int

Yeni bir yükseklik.

resizeType ResizeType

Resize’nin türü

Examples

Bu örnek bir görüntü yükler ve çeşitli resizleme yöntemleri kullanılarak orantılı olarak resizler. yalnızca yükseklik belirtilir, genişlik otomatik olarak hesaplanır.

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

                                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                                                         {
                                                                                                                                                                             // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                                                                                                             image.ResizeHeightProportionally(image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
                                                                                                                                                                             image.Save(dir + "upsample.nearestneighbour.gif");
                                                                                                                                                                         }

                                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                                                         {
                                                                                                                                                                             // Scale down by 2 times using Nearest Neighbour resampling.
                                                                                                                                                                             image.ResizeHeightProportionally(image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
                                                                                                                                                                             image.Save(dir + "upsample.nearestneighbour.gif");
                                                                                                                                                                         }

                                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                                                         {
                                                                                                                                                                             // Scale up by 2 times using Bilinear resampling.
                                                                                                                                                                             image.ResizeHeightProportionally(image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);
                                                                                                                                                                             image.Save(dir + "upsample.bilinear.gif");
                                                                                                                                                                         }

                                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                                                         {
                                                                                                                                                                             // Scale down by 2 times using Bilinear resampling.
                                                                                                                                                                             image.ResizeHeightProportionally(image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
                                                                                                                                                                             image.Save(dir + "downsample.bilinear.gif");
                                                                                                                                                                         }

Segmentasyon sürecini hızlandırmak için bir segment maskesi kullanın

// Masking export options
                                                                    Aspose.Imaging.ImageOptions.PngOptions exportOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                    exportOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
                                                                    exportOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());

                                                                    Aspose.Imaging.Masking.Options.MaskingOptions maskingOptions = new Aspose.Imaging.Masking.Options.MaskingOptions();

                                                                    // Use GraphCut clustering.
                                                                    maskingOptions.Method = Masking.Options.SegmentationMethod.GraphCut;
                                                                    maskingOptions.Decompose = false;
                                                                    maskingOptions.Args = new Aspose.Imaging.Masking.Options.AutoMaskingArgs();

                                                                    // The backgroung color will be transparent.
                                                                    maskingOptions.BackgroundReplacementColor = Aspose.Imaging.Color.Transparent;
                                                                    maskingOptions.ExportOptions = exportOptions;

                                                                    string dir = "c:\\temp\\";
                                                                    using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
                                                                    {
                                                                        Aspose.Imaging.Size imageSize = image.Size;

                                                                        // Reducing image size to speed up the segmentation process
                                                                        image.ResizeHeightProportionally(600, Aspose.Imaging.ResizeType.HighQualityResample);

                                                                        // Create an instance of the ImageMasking class.
                                                                        Aspose.Imaging.Masking.ImageMasking masking = new Aspose.Imaging.Masking.ImageMasking(image);

                                                                        // Divide the source image into several clusters (segments).
                                                                        using (Aspose.Imaging.Masking.Result.MaskingResult maskingResult = masking.Decompose(maskingOptions))
                                                                        {
                                                                            // Getting the foreground mask
                                                                            using (Aspose.Imaging.RasterImage foregroundMask = maskingResult[1].GetMask()) 
                                                                            {
                                                                                // Increase the size of the mask to the size of the original image
                                                                                foregroundMask.Resize(imageSize.Width, imageSize.Height, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                // Applying the mask to the original image to obtain a foreground segment
                                                                                using (Aspose.Imaging.RasterImage originImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
                                                                                {
                                                                                    Aspose.Imaging.Masking.ImageMasking.ApplyMask(originImage, foregroundMask, maskingOptions);
                                                                                    originImage.Save(dir + "BigImage_foreground.png", exportOptions);
                                                                                }
                                                                            }
                                                                        }
                                                                    }

ResizeHeightProportionally(Görüntüleme, ImageResizeSettings)

Yüksekliği orantılı olarak azaltır.

public virtual void ResizeHeightProportionally(int newHeight, ImageResizeSettings settings)

Parameters

newHeight int

Yeni bir yükseklik.

settings ImageResizeSettings

Görüntü ayarları yeniden oluşturur.

ResizeWidthProportionally(int ile)

Aspose.Imaging.ResizeType.NearestNeighbourResample varsayılan olarak kullanılır.

public void ResizeWidthProportionally(int newWidth)

Parameters

newWidth int

Yeni bir genişlik.

ResizeWidthProportionally(ResizeType , ResizeType)

Genişliği orantılı olarak azaltır.

public virtual void ResizeWidthProportionally(int newWidth, ResizeType resizeType)

Parameters

newWidth int

Yeni bir genişlik.

resizeType ResizeType

Resize’nin türü

Examples

Bu örnek bir görüntü yükler ve çeşitli resizleme yöntemleri kullanılarak orantılı olarak resizler. yalnızca genişlik belirtilir, yükseklik otomatik olarak hesaplanır.

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

                                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                                                         {
                                                                                                                                                                             // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                                                                                                             image.ResizeWidthProportionally(image.Width* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
                                                                                                                                                                             image.Save(dir + "upsample.nearestneighbour.gif");
                                                                                                                                                                         }

                                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                                                         {
                                                                                                                                                                             // Scale down by 2 times using Nearest Neighbour resampling.
                                                                                                                                                                             image.ResizeWidthProportionally(image.Width / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
                                                                                                                                                                             image.Save(dir + "downsample.nearestneighbour.gif");
                                                                                                                                                                         }

                                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                                                         {
                                                                                                                                                                             // Scale up by 2 times using Bilinear resampling.
                                                                                                                                                                             image.ResizeWidthProportionally(image.Width* 2, Aspose.Imaging.ResizeType.BilinearResample);
                                                                                                                                                                             image.Save(dir + "upsample.bilinear.gif");
                                                                                                                                                                         }

                                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                                                         {
                                                                                                                                                                             // Scale down by 2 times using Bilinear resampling.
                                                                                                                                                                             image.ResizeWidthProportionally(image.Width / 2, Aspose.Imaging.ResizeType.BilinearResample);
                                                                                                                                                                             image.Save(dir + "downsample.bilinear.gif");
                                                                                                                                                                         }

ResizeWidthProportionally(Görüntüleme, ImageResizeSettings)

Genişliği orantılı olarak azaltır.

public virtual void ResizeWidthProportionally(int newWidth, ImageResizeSettings settings)

Parameters

newWidth int

Yeni bir genişlik.

settings ImageResizeSettings

Görüntü ayarları yeniden oluşturur.

Rotate(Floransa)

Görüntüleri merkezin etrafında döndürün.

public virtual void Rotate(float angle)

Parameters

angle float

Pozitif değerler saatlik olarak döndürülür.

RotateFlip(RotateFlipType)

Görüntüyü döndürür, döndürür veya döndürür ve döndürür.

public abstract void RotateFlip(RotateFlipType rotateFlipType)

Parameters

rotateFlipType RotateFlipType

Rotat flip türü.

Examples

Örnek, bir disk konumundan mevcut bir görüntü dosyasını yükler ve Enum Aspose.Imaging.RotateFlipType değerine göre görüntü üzerinde Rotate işlemini gerçekleştirir.

//Create an instance of image class and initialize it with an existing image file through File path
                                                                                                                                                                                                                                                       using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"C:\temp\sample.bmp"))
                                                                                                                                                                                                                                                       {
                                                                                                                                                                                                                                                           //Rotate the image at 180 degree about X axis
                                                                                                                                                                                                                                                           image.RotateFlip(Aspose.Imaging.RotateFlipType.Rotate180FlipX);

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

Bu örnek bir görüntü yükler, 90 derecelik saatlik olarak döndürür ve seçmeli olarak görüntüyi yatay ve/veya dikey olarak kaydırır.

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

                                                                                                                                          Aspose.Imaging.RotateFlipType[] rotateFlipTypes = new Aspose.Imaging.RotateFlipType[]
                                                                                                                                          {
                                                                                                                                              Aspose.Imaging.RotateFlipType.Rotate90FlipNone,
                                                                                                                                              Aspose.Imaging.RotateFlipType.Rotate90FlipX,
                                                                                                                                              Aspose.Imaging.RotateFlipType.Rotate90FlipXY,
                                                                                                                                              Aspose.Imaging.RotateFlipType.Rotate90FlipY,
                                                                                                                                          };

                                                                                                                                          foreach (Aspose.Imaging.RotateFlipType rotateFlipType in rotateFlipTypes)
                                                                                                                                          {
                                                                                                                                              // Rotate, flip and save to the output file.
                                                                                                                                              using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                              {
                                                                                                                                                  image.RotateFlip(rotateFlipType);
                                                                                                                                                  image.Save(dir + "sample." + rotateFlipType + ".bmp");
                                                                                                                                              }
                                                                                                                                          }

Bu örnek bir ODG görüntüsünü yükler, 90 derecelik saat açısıyla döndürür ve seçmeli olarak görüntüyü yatay ve/veya dikey olarak kaydırır.

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

                                                                                                                                             Aspose.Imaging.RotateFlipType[] rotateFlipTypes = new Aspose.Imaging.RotateFlipType[]
                                                                                                                                             {
                                                                                                                                                 Aspose.Imaging.RotateFlipType.Rotate90FlipNone,
                                                                                                                                                 Aspose.Imaging.RotateFlipType.Rotate90FlipX,
                                                                                                                                                 Aspose.Imaging.RotateFlipType.Rotate90FlipXY,
                                                                                                                                                 Aspose.Imaging.RotateFlipType.Rotate90FlipY,
                                                                                                                                             };

                                                                                                                                             foreach (Aspose.Imaging.Image rotateFlipType in rotateFlipTypes)
                                                                                                                                             {
                                                                                                                                                 // Rotate, flip and save to the output file.
                                                                                                                                                 using (Aspose.Imaging.Image image = (Aspose.Imaging.FileFormats.OpenDocument.OdImage)Aspose.Imaging.Image.Load(dir + "sample.odg"))
                                                                                                                                                 {
                                                                                                                                                     image.RotateFlip(rotateFlipType);
                                                                                                                                                     image.Save(dir + "sample." + rotateFlipType + ".png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                 }
                                                                                                                                             }

Save()

Görüntü verilerini alt akışa kaydeder.

public override sealed void Save()

Examples

Aşağıdaki örnek, bir BMP resmini veya bir kısmını bir dosyaya veya akışa nasıl kaydedeceğinizi gösterir.

string dir = "c:\\temp\\";
                                                                                                          using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                          {
                                                                                                              Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;

                                                                                                              // Convert to a black-white image
                                                                                                              bmpImage.BinarizeOtsu();

                                                                                                              // Save to the same location with default options.
                                                                                                              image.Save();

                                                                                                              Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();

                                                                                                              // A palette contains only two colors: Black and White in this case.
                                                                                                              saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.CreateMonochrome();

                                                                                                              // For all monochrome images (including black-white ones) it is enough to allocate 1 bit per pixel.
                                                                                                              saveOptions.BitsPerPixel = 1;

                                                                                                              // Save to another location with the specified options.
                                                                                                              image.Save(dir + "sample.bw.palettized.bmp", saveOptions);

                                                                                                              // Save only the central part of the image.
                                                                                                              Aspose.Imaging.Rectangle bounds = new Aspose.Imaging.Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
                                                                                                              image.Save(dir + "sample.bw.palettized.part.bmp", saveOptions, bounds);

                                                                                                              // Save the entire image to a memory stream
                                                                                                              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                              {
                                                                                                                  image.Save(stream, saveOptions);
                                                                                                                  System.Console.WriteLine("The size of the whole image in bytes: {0}", stream.Length);
                                                                                                              }

                                                                                                              // Save the central part of the image to a memory stream
                                                                                                              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                              {
                                                                                                                  image.Save(stream, saveOptions, bounds);
                                                                                                                  System.Console.WriteLine("The size of the central part of the image in bytes: {0}", stream.Length);
                                                                                                              }
                                                                                                          }
                                                                                                          //The output may look like this:
                                                                                                          //The size of the whole image in bytes: 24062
                                                                                                          //The size of the central part of the image in bytes: 6046

Save(Sırt)

Görüntüyü belirlenen dosya konumuna kaydeder.

public override void Save(string filePath)

Parameters

filePath string

Görüntüyü kaydetmek için dosya yolu.

Save(Çerçeve, ImageOptionsBase)

Önerilen dosya biçiminde belirtilen dosya konumuna kaydedilen nesnenin verilerini kaydetme seçeneklerine göre kaydeder.

public virtual void Save(string filePath, ImageOptionsBase options)

Parameters

filePath string

Dosya Yolu.

options ImageOptionsBase

Seçenekler için.

Examples

Aşağıdaki örnek bir dosyadan bir BMP görüntüsünü yükler, daha sonra görüntüyi bir PNG dosyasına kaydeder.

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

                                                                                                   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                   {
                                                                                                       // Save the entire image to a PNG file.
                                                                                                       Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                       image.Save(dir + "output.png", saveOptions);
                                                                                                   }

Bu örnek bir görüntü kaydetmek için basit adımları gösterir. bu işlemi göstermek için, mevcut bir dosyayı bir disk konumundan yüklemek, görüntü üzerinde döndürme işlemi gerçekleştirmek ve Dosya Yolu kullanarak PSD biçiminde görüntü kaydetmek

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

                                                                                                                                                                                                                                         //Create an instance of image class and initialize it with an existing file through File path
                                                                                                                                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                             //Rotate the image at 180 degree about X axis
                                                                                                                                                                                                                                             image.RotateFlip(Aspose.Imaging.RotateFlipType.Rotate180FlipX);

                                                                                                                                                                                                                                             //Save the Image as PSD to File Path with default PsdOptions settings
                                                                                                                                                                                                                                             image.Save(dir + "output.psd", new Aspose.Imaging.ImageOptions.PsdOptions());
                                                                                                                                                                                                                                         }

Aşağıdaki örnek, bir BMP resmini veya bir kısmını bir dosyaya veya akışa nasıl kaydedeceğinizi gösterir.

string dir = "c:\\temp\\";
                                                                                                          using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                          {
                                                                                                              Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;

                                                                                                              // Convert to a black-white image
                                                                                                              bmpImage.BinarizeOtsu();

                                                                                                              // Save to the same location with default options.
                                                                                                              image.Save();

                                                                                                              Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();

                                                                                                              // A palette contains only two colors: Black and White in this case.
                                                                                                              saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.CreateMonochrome();

                                                                                                              // For all monochrome images (including black-white ones) it is enough to allocate 1 bit per pixel.
                                                                                                              saveOptions.BitsPerPixel = 1;

                                                                                                              // Save to another location with the specified options.
                                                                                                              image.Save(dir + "sample.bw.palettized.bmp", saveOptions);

                                                                                                              // Save only the central part of the image.
                                                                                                              Aspose.Imaging.Rectangle bounds = new Aspose.Imaging.Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
                                                                                                              image.Save(dir + "sample.bw.palettized.part.bmp", saveOptions, bounds);

                                                                                                              // Save the entire image to a memory stream
                                                                                                              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                              {
                                                                                                                  image.Save(stream, saveOptions);
                                                                                                                  System.Console.WriteLine("The size of the whole image in bytes: {0}", stream.Length);
                                                                                                              }

                                                                                                              // Save the central part of the image to a memory stream
                                                                                                              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                              {
                                                                                                                  image.Save(stream, saveOptions, bounds);
                                                                                                                  System.Console.WriteLine("The size of the central part of the image in bytes: {0}", stream.Length);
                                                                                                              }
                                                                                                          }
                                                                                                          //The output may look like this:
                                                                                                          //The size of the whole image in bytes: 24062
                                                                                                          //The size of the central part of the image in bytes: 6046

Save(Çerçeve, ImageOptionsBase, Rectangle)

Önerilen dosya biçiminde belirtilen dosya konumuna kaydedilen nesnenin verilerini kaydetme seçeneklerine göre kaydeder.

public virtual void Save(string filePath, ImageOptionsBase options, Rectangle boundsRectangle)

Parameters

filePath string

Dosya Yolu.

options ImageOptionsBase

Seçenekler için.

boundsRectangle Rectangle

Hedef görüntüsü düz açı sınırlar. kaynak sınırlarını kullanmak için boş düz açı ayarlayın.

Examples

Aşağıdaki örnek bir dosyadan bir BMP görüntüsünü yükler, ardından resmin düz bir kısmını bir PNG dosyasına kaydeder.

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

                                                                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                         {
                                                                                                                             // Save the upper half of the image to a PNG file.
                                                                                                                             Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                             Aspose.Imaging.Rectangle bounds = new Aspose.Imaging.Rectangle(0, 0, image.Width, image.Height / 2);
                                                                                                                             image.Save(dir + "output.png", saveOptions, bounds);
                                                                                                                         }

Aşağıdaki örnek, bir BMP resmini veya bir kısmını bir dosyaya veya akışa nasıl kaydedeceğinizi gösterir.

string dir = "c:\\temp\\";
                                                                                                          using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                          {
                                                                                                              Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;

                                                                                                              // Convert to a black-white image
                                                                                                              bmpImage.BinarizeOtsu();

                                                                                                              // Save to the same location with default options.
                                                                                                              image.Save();

                                                                                                              Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();

                                                                                                              // A palette contains only two colors: Black and White in this case.
                                                                                                              saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.CreateMonochrome();

                                                                                                              // For all monochrome images (including black-white ones) it is enough to allocate 1 bit per pixel.
                                                                                                              saveOptions.BitsPerPixel = 1;

                                                                                                              // Save to another location with the specified options.
                                                                                                              image.Save(dir + "sample.bw.palettized.bmp", saveOptions);

                                                                                                              // Save only the central part of the image.
                                                                                                              Aspose.Imaging.Rectangle bounds = new Aspose.Imaging.Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
                                                                                                              image.Save(dir + "sample.bw.palettized.part.bmp", saveOptions, bounds);

                                                                                                              // Save the entire image to a memory stream
                                                                                                              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                              {
                                                                                                                  image.Save(stream, saveOptions);
                                                                                                                  System.Console.WriteLine("The size of the whole image in bytes: {0}", stream.Length);
                                                                                                              }

                                                                                                              // Save the central part of the image to a memory stream
                                                                                                              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                              {
                                                                                                                  image.Save(stream, saveOptions, bounds);
                                                                                                                  System.Console.WriteLine("The size of the central part of the image in bytes: {0}", stream.Length);
                                                                                                              }
                                                                                                          }
                                                                                                          //The output may look like this:
                                                                                                          //The size of the whole image in bytes: 24062
                                                                                                          //The size of the central part of the image in bytes: 6046

Exceptions

ArgumentNullException

Seçenekler

ImageSaveException

Fotoğraf tasarrufu başarısız oldu.

Save(Görüntüleme, ImageOptionsBase)

Görüntü verilerini kaydetme seçeneklerine göre belirli dosya biçiminde belirtilen akışa kaydeder.

public void Save(Stream stream, ImageOptionsBase optionsBase)

Parameters

stream Stream

Görüntünün verilerini kaydetmek için akış.

optionsBase ImageOptionsBase

Tasarruf seçenekleri.

Examples

Aşağıdaki örnek bir dosyadan bir görüntü yükler, ardından görüntüyi bir PNG dosya akışına kaydeder.

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

                                                                                                       using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                       {
                                                                                                           Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                           using (System.IO.Stream outputStream = System.IO.File.Open(dir + "output.png", System.IO.FileMode.Create))
                                                                                                           {
                                                                                                               // Save the entire image to a file stream.
                                                                                                               image.Save(outputStream, saveOptions);
                                                                                                           }
                                                                                                       }

Bu örnek MemoryStream’a bir görüntü kaydetme işlemi gösterir. bu işlemi göstermek için, örnek bir disk konumundan mevcut bir dosyayı yükler, görüntü üzerinde döndürme işlemi gerçekleştirir ve görüntüyi PSD biçiminde kaydeder.

//Create an instance of MemoryStream
                                                                                                                                                                                                                                            using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                                //Create an instance of image class and initialize it with an existing file through File path
                                                                                                                                                                                                                                                using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"C:\temp\sample.bmp"))
                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                    //Rotate the image at 180 degree about X axis
                                                                                                                                                                                                                                                    image.RotateFlip(Aspose.Imaging.RotateFlipType.Rotate180FlipX);

                                                                                                                                                                                                                                                    //Save the Image as PSD to MemoryStream with default PsdOptions settings
                                                                                                                                                                                                                                                    image.Save(stream, new Aspose.Imaging.ImageOptions.PsdOptions());
                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                            }

Aşağıdaki örnek, bir BMP resmini veya bir kısmını bir dosyaya veya akışa nasıl kaydedeceğinizi gösterir.

string dir = "c:\\temp\\";
                                                                                                          using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                          {
                                                                                                              Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;

                                                                                                              // Convert to a black-white image
                                                                                                              bmpImage.BinarizeOtsu();

                                                                                                              // Save to the same location with default options.
                                                                                                              image.Save();

                                                                                                              Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();

                                                                                                              // A palette contains only two colors: Black and White in this case.
                                                                                                              saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.CreateMonochrome();

                                                                                                              // For all monochrome images (including black-white ones) it is enough to allocate 1 bit per pixel.
                                                                                                              saveOptions.BitsPerPixel = 1;

                                                                                                              // Save to another location with the specified options.
                                                                                                              image.Save(dir + "sample.bw.palettized.bmp", saveOptions);

                                                                                                              // Save only the central part of the image.
                                                                                                              Aspose.Imaging.Rectangle bounds = new Aspose.Imaging.Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
                                                                                                              image.Save(dir + "sample.bw.palettized.part.bmp", saveOptions, bounds);

                                                                                                              // Save the entire image to a memory stream
                                                                                                              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                              {
                                                                                                                  image.Save(stream, saveOptions);
                                                                                                                  System.Console.WriteLine("The size of the whole image in bytes: {0}", stream.Length);
                                                                                                              }

                                                                                                              // Save the central part of the image to a memory stream
                                                                                                              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                              {
                                                                                                                  image.Save(stream, saveOptions, bounds);
                                                                                                                  System.Console.WriteLine("The size of the central part of the image in bytes: {0}", stream.Length);
                                                                                                              }
                                                                                                          }
                                                                                                          //The output may look like this:
                                                                                                          //The size of the whole image in bytes: 24062
                                                                                                          //The size of the central part of the image in bytes: 6046

Exceptions

ArgumentNullException

seçenekler

ArgumentException

Şu anda desteklenmediği için belirtilen biçimde kaydedilemez; seçeneklerBase

ImageSaveException

Görüntü ihracatı başarısız oldu.

Save(Akış, ImageOptionsBase, Rectangle)

Görüntü verilerini kaydetme seçeneklerine göre belirli dosya biçiminde belirtilen akışa kaydeder.

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

Parameters

stream Stream

Görüntünün verilerini kaydetmek için akış.

optionsBase ImageOptionsBase

Tasarruf seçenekleri.

boundsRectangle Rectangle

Hedef görüntüsü düz açıyı sınırlar. kaynak sınırlarını kullanmak için boş düz açıyı ayarlayın.

Examples

Aşağıdaki örnek bir dosyadan bir görüntü yükler, daha sonra bir PNG dosya akışına resmin düz bir kısmını kaydeder.

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

                                                                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                                             {
                                                                                                                                 Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                                 Aspose.Imaging.Rectangle bounds = new Aspose.Imaging.Rectangle(0, 0, image.Width, image.Height / 2);
                                                                                                                                 using (System.IO.Stream outputStream = System.IO.File.Open(dir + "sample.output.png", System.IO.FileMode.Create))
                                                                                                                                 {
                                                                                                                                     // Save the upper half of the image to a file stream.
                                                                                                                                     image.Save(outputStream, saveOptions, bounds);
                                                                                                                                 }
                                                                                                                             }

Aşağıdaki örnek, bir BMP resmini veya bir kısmını bir dosyaya veya akışa nasıl kaydedeceğinizi gösterir.

string dir = "c:\\temp\\";
                                                                                                          using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.bmp"))
                                                                                                          {
                                                                                                              Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;

                                                                                                              // Convert to a black-white image
                                                                                                              bmpImage.BinarizeOtsu();

                                                                                                              // Save to the same location with default options.
                                                                                                              image.Save();

                                                                                                              Aspose.Imaging.ImageOptions.BmpOptions saveOptions = new Aspose.Imaging.ImageOptions.BmpOptions();

                                                                                                              // A palette contains only two colors: Black and White in this case.
                                                                                                              saveOptions.Palette = Aspose.Imaging.ColorPaletteHelper.CreateMonochrome();

                                                                                                              // For all monochrome images (including black-white ones) it is enough to allocate 1 bit per pixel.
                                                                                                              saveOptions.BitsPerPixel = 1;

                                                                                                              // Save to another location with the specified options.
                                                                                                              image.Save(dir + "sample.bw.palettized.bmp", saveOptions);

                                                                                                              // Save only the central part of the image.
                                                                                                              Aspose.Imaging.Rectangle bounds = new Aspose.Imaging.Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
                                                                                                              image.Save(dir + "sample.bw.palettized.part.bmp", saveOptions, bounds);

                                                                                                              // Save the entire image to a memory stream
                                                                                                              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                              {
                                                                                                                  image.Save(stream, saveOptions);
                                                                                                                  System.Console.WriteLine("The size of the whole image in bytes: {0}", stream.Length);
                                                                                                              }

                                                                                                              // Save the central part of the image to a memory stream
                                                                                                              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                                                                                                              {
                                                                                                                  image.Save(stream, saveOptions, bounds);
                                                                                                                  System.Console.WriteLine("The size of the central part of the image in bytes: {0}", stream.Length);
                                                                                                              }
                                                                                                          }
                                                                                                          //The output may look like this:
                                                                                                          //The size of the whole image in bytes: 24062
                                                                                                          //The size of the central part of the image in bytes: 6046

Exceptions

ArgumentNullException

seçenekler

ArgumentException

Şu anda desteklenmediği için belirtilen biçimde kaydedilemez; seçeneklerBase

ImageSaveException

Görüntü ihracatı başarısız oldu.

SetPalette(İKOLORPALET, BOOL)

Görüntü paletini oluşturun.

public abstract void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

Palet ayarlamak için.

updateColors bool

Eğer ‘gerçek’ renkler ayarlanırsa, yeni paletine göre güncellenir; aksi takdirde renk göstergeleri değişmez kalır. değiştirilmemiş göstergeler, bazı göstergelerin ilgili palet girişleri olmadığı takdirde yükleme görüntüsünü bozabilir.

UpdateContainer(Image)

Konteyneri güncelleyin

protected void UpdateContainer(Image container)

Parameters

container Image

Konteyner için.

Ayrıca bakın

DataStreamSupporter , IObjectWithBounds

 Türkçe