Class Image

Class Image

Именује се: Aspose.Imaging Асамблеја: Aspose.Imaging.dll (25.4.0)

Слика је основна класа за све врсте слика.

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

Inheritance

object DisposableObject DataStreamSupporter Image

Derived

RasterImage , VectorImage

Implements

IDisposable , IObjectWithBounds

Наслеђени чланови

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

Одређивање да ли је палет коришћен сликом.

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

Рециклирајте слику користећи одређени тип рецидива.

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

Овај пример креира нови Слика датотеку на неком локацији диска, као што је наведено изворном својством инстанције Бмпоптионс. Неколико својстава за Инстанцију БМп опције се поставља пре стварања стварног слике.

//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.Име класе.

[JsonConstructor]
protected Image()

Image(ИЦОЛОРПАЛЕТ)

Иницијалише нову инстанцију Aspose.Imaging.Име класе.

protected Image(IColorPalette colorPalette)

Parameters

colorPalette IColorPalette

Палет боја је.

Properties

AutoAdjustPalette

Добија или поставља вредност која указује на то да ли се палет аутоматски прилагођава.

public bool AutoAdjustPalette { get; set; }

Вредност имовине

bool

BackgroundColor

Добија или поставља вредност за боју позадине.

public virtual Color BackgroundColor { get; set; }

Вредност имовине

Color

BitsPerPixel

Добије слику бита по пикселу рачуна.

public abstract int BitsPerPixel { get; }

Вредност имовине

int

Bounds

Добијте границе слике.

public Rectangle Bounds { get; }

Вредност имовине

Rectangle

BufferSizeHint

Добије или поставља индикацију величине буфера која је дефинисана максимално дозвољена величина за све унутрашње буфере.

public int BufferSizeHint { get; set; }

Вредност имовине

int

Container

Добијете Aspose.Imaging.Име контејнер.

public Image Container { get; }

Вредност имовине

Image

Remarks

Ако ова имовина није нула, то указује на слику која се налази у другој слици.

FileFormat

Добија вредност формат датотеке

public virtual FileFormat FileFormat { get; }

Вредност имовине

FileFormat

HasBackgroundColor

Добија или поставља вредност која указује на то да ли слика има боју позадине.

public virtual bool HasBackgroundColor { get; set; }

Вредност имовине

bool

Height

Добија висину слике.

public abstract int Height { get; }

Вредност имовине

int

InterruptMonitor

Добија или поставља прекинутог монитора.

public InterruptMonitor InterruptMonitor { get; set; }

Вредност имовине

InterruptMonitor

Palette

Добија или поставља палету боја. палету боја се не користи када се пиксели директно представљају.

public IColorPalette Palette { get; set; }

Вредност имовине

IColorPalette

Size

Добије величину слике.

public Size Size { get; }

Вредност имовине

Size

Examples

Овај пример показује како да преузмете ДЈВУ слику из протока датотека и штампате информације о страницама.

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

Добије вредност која указује на то да ли се користи палет слике.

public virtual bool UsePalette { get; }

Вредност имовине

bool

Examples

Одређивање да ли је палет коришћен сликом.

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

Width

Добија ширину слике.

public abstract int Width { get; }

Вредност имовине

int

Methods

CanLoad(Стринг)

Одређује да ли се слика може преузети са одређеног пута датотеке.

public static bool CanLoad(string filePath)

Parameters

filePath string

Пут датотеке .

Returns

bool

‘истина’ ако се слика може преузети из одређеног датотеке; иначе, ‘фалсификована’.

Examples

Овај пример одређује да ли се слика може преузети из датотеке.

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

CanLoad(КСНУМКС, LoadOptions)

Одређује да ли се слика може преузети са одређеног пута датотеке и опционално користећи одређене отворене опције.

public static bool CanLoad(string filePath, LoadOptions loadOptions)

Parameters

filePath string

Пут датотеке .

loadOptions LoadOptions

Опције за оптерећење.

Returns

bool

‘истина’ ако се слика може преузети из одређеног датотеке; иначе, ‘фалсификована’.

CanLoad(Stream)

Одређује да ли се слика може преузети из одређеног тока.

public static bool CanLoad(Stream stream)

Parameters

stream Stream

Поток да се наплати.

Returns

bool

‘истина’ ако се слика може преузети из одређеног тока; иначе, ‘фалсификована’.

Examples

Овај пример одређује да ли се слика може преузети из протока датотеке.

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(Стрејм, опције за опције)

Одређује да ли се слика може преузети из одређеног тока и опционално користи loadOptions’.

public static bool CanLoad(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

Поток да се наплати.

loadOptions LoadOptions

Опције за оптерећење.

Returns

bool

‘истина’ ако се слика може преузети из одређеног тока; иначе, ‘фалсификована’.

CanSave(ImageOptionsBase)

Одређује да ли се слика може сачувати у одређеном формату датотеке представљен прошлим опцијама за сачување.

public bool CanSave(ImageOptionsBase options)

Parameters

options ImageOptionsBase

Сачувај опције за коришћење.

Returns

bool

‘истина’ ако се слика може сачувати у одређеном формату датотеке представљен прошлим опцијама за сачување; иначе, ‘фалсификовани’.

Examples

Овај пример показује како да се утврди да ли се слика може сачувати у одређеном формату датотеке представљен прошлим опцијама за складиштење.

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)

Креира нова слика користећи одређене опције за креирање.

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

Parameters

imageOptions ImageOptionsBase

Опције за слику.

width int

То је ширина.

height int

То је висина.

Returns

Image

Слике које је ново створен.

Examples

Овај пример креира нови Слика датотеку на неком локацији диска, као што је наведено изворном својством инстанције Бмпоптионс. Неколико својстава за Инстанцију БМп опције се поставља пре стварања стварног слике.

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

Креира нова слика користећи одређене слике као странице

public static Image Create(Image[] images)

Parameters

images Image []

и слике .

Returns

Image

Слика као ИмултипагеИмаге

Create(MultipageCreateOptions)

Креирање одређене мултистранице креира опције.

public static Image Create(MultipageCreateOptions multipageCreateOptions)

Parameters

multipageCreateOptions MultipageCreateOptions

Мултистраница ствара опције.

Returns

Image

Mnogobrojna slika

Create(Стринг[], Боол)

Креира мултистрани слику која садржи одређене датотеке.

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

Parameters

files string []

и датотеке .

throwExceptionOnLoadError bool

Ако је постављен на “истину” [баците изузетак на грешку оптерећења].

Returns

Image

Mnogobrojna slika

Create(Стринг[])

Креира мултистрани слику која садржи одређене датотеке.

public static Image Create(string[] files)

Parameters

files string []

и датотеке .

Returns

Image

Mnogobrojna slika

Create(Image[], Боол)

Креира нова слика одређене слике као странице.

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

Parameters

images Image []

и слике .

disposeImages bool

Ако је постављен на “истину” [поставите слике].

Returns

Image

Слика као ИмултипагеИмаге

Crop(Rectangle)

Покреће одређени правоугао.

public virtual void Crop(Rectangle rectangle)

Parameters

rectangle Rectangle

То је правоугао.

Examples

Sledeći primer uzgaja raster sliku. površina uzgoja je navedena preko Aspose.Imaging.Rectangle.

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)

Слика узгоја са променама.

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

Parameters

leftShift int

Левица се мења.

rightShift int

И прави промен.

topShift int

На врхунском прелазу.

bottomShift int

Доњи промен.

Examples

Sledeći primer uzgaja raster sliku. površina uzgoja je navedena preko lijevih, gornjih, desnih, donjih margina.

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)

Ne možeš da štediš poruku.

protected virtual string GetCanNotSaveMessage(ImageOptionsBase optionsBase)

Parameters

optionsBase ImageOptionsBase

Опције за слику.

Returns

string

Ne može da štedi poruku.

GetDefaultOptions(Објекат[])

Покушајте да добијете дефолт опције.

public virtual ImageOptionsBase GetDefaultOptions(object[] args)

Parameters

args object []

i argumentima .

Returns

ImageOptionsBase

Default opcije

GetFileFormat(Стринг)

Добијете формат датотеке.

public static FileFormat GetFileFormat(string filePath)

Parameters

filePath string

Пут датотеке .

Returns

FileFormat

Одређени формат датотеке.

Examples

Овај пример показује како одредити формат слике без преузимања целокупног слика из датотеке.

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

Одређени формат датотеке не значи да се одређена слика може преузети. Користите један од метода преоптерећења CanLoad да бисте утврдили да ли се датотека може преузети.

GetFileFormat(Stream)

Добијете формат датотеке.

public static FileFormat GetFileFormat(Stream stream)

Parameters

stream Stream

У току струје.

Returns

FileFormat

Одређени формат датотеке.

Examples

Овај пример показује како одредити формат слике без преузимања целог слика из протока датотеке.

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

Дефинисани формат датотеке не значи да се одређена слика може преузети. Користите један од метода преоптерећења CanLoad да бисте утврдили да ли се струја може преузети.

GetFitRectangle(Rectangle)

Добија правоугао који одговара тренутном слици.

protected Rectangle GetFitRectangle(Rectangle rectangle)

Parameters

rectangle Rectangle

правоугао да би се прилагодио правоугао за.

Returns

Rectangle

Прилагођени правоугао

GetFitRectangle(Ректангл, инт[])

Добије правоугао који одговара текућој битмапи узимајући у обзир прођене пикселе. Број прођених пиксела треба да буде једнак величини правоугао који одговара.

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

Parameters

rectangle Rectangle

правоугао да би се прилагодио правоугао за.

pixels int []

32-битни АРГБ пиксели се налазе.

Returns

Rectangle

Одговарајуће правоугао.

GetFittingRectangle(Трчање, инт, инт)

Добија правоугао који одговара тренутном слици.

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

Parameters

rectangle Rectangle

правоугао да би се прилагодио правоугао за.

width int

Објекат ширине.

height int

висине објекта.

Returns

Rectangle

Прилагођени правоугао или изузетак ако се не може наћи прилагођени правоугао.

GetFittingRectangle(Ректангл, инт[], int , int)

Добија правоугао који одговара тренутном слици.

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

Parameters

rectangle Rectangle

правоугао да би се прилагодио правоугао за.

pixels int []

32-битни АРГБ пиксели

width int

Објекат ширине.

height int

висине објекта.

Returns

Rectangle

Прилагођени правоугао или изузетак ако се не може наћи прилагођени правоугао.

GetImage2Export(ImageOptionsBase, Rectangle, IImageЕкспортер)

Добијају слику за извоз.

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

Parameters

optionsBase ImageOptionsBase

База опција слике.

boundsRectangle Rectangle

Линије су правоугаоне.

exporter IImageExporter

То је извозник.

Returns

Image

Слика за извоз

GetOriginalOptions()

Добија опције засноване на оригиналним подешавањама датотеке.Ово може бити корисно за одржавање детаљне дубине и других параметара оригиналне слике непромењене.На пример, ако наплаћујемо црно-белу ПНГ слику са 1 битом по пикселу, а затим га сачувате користећиAspose.Imaging.DataStreamSupporter.Save(System.String) метода, излазна ПНГ слика са 8 бита по пикселу ће бити произведена.Да бисте то избегли и сачували ПНГ слику са 1 битом по пикселу, користите ову методу да бисте добили одговарајуће опције за штедњу и прошли их.до метода Aspose.Imaging.Image.Save(System.String,_Wl17.ImageOptionsBase) као други параметар.

public virtual ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

Опције засноване на оригиналним поставкама датотеке.

GetProportionalHeight(int, int, int)

Добијају пропорционалну висину.

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

Parameters

width int

То је ширина.

height int

То је висина.

newWidth int

Нова ширина је.

Returns

int

Пропорционална висина .

GetProportionalWidth(int, int, int)

Добијају пропорционалну ширину.

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

Parameters

width int

То је ширина.

height int

То је висина.

newHeight int

Нова висина је.

Returns

int

Пропорционална ширина

GetSerializedStream(ImageOptionsBase, Rectangle, out int)

Претварање у апс.

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

Parameters

imageOptions ImageOptionsBase

Опције за слику.

clippingRectangle Rectangle

Кључање у правоугао.

pageNumber int

Број странице .

Returns

Stream

Серијализовани ток

Load(КСНУМКС, LoadOptions)

Преузмите нову слику са одређеног пута датотеке или УРЛ-а.Ако је filePath’ патекс, метода је само отварање фајла.Иако је уРл, метод преузима, чува га као привремени, и отвара га.

public static Image Load(string filePath, LoadOptions loadOptions)

Parameters

filePath string

Пут датотеке или УРЛ за преузимање слике из.

loadOptions LoadOptions

Опције за оптерећење.

Returns

Image

То је оптерећена слика.

Load(Стринг)

Преузмите нову слику са одређеног пута датотеке или УРЛ-а.Ако је filePath’ патекс, метода је само отварање фајла.Иако је уРл, метод преузима, чува га као привремени, и отвара га.

public static Image Load(string filePath)

Parameters

filePath string

Пут датотеке или УРЛ за преузимање слике из.

Returns

Image

То је оптерећена слика.

Examples

Овај пример показује преузимање постојеће слике датотеке у примјену Aspose.Imaging.Слика користећи фајл пут одређен

//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(Стрејм, опције за опције)

Преузмите нову слику из одређеног тока.

public static Image Load(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

Поток за преузимање слике из.

loadOptions LoadOptions

Опције за оптерећење.

Returns

Image

То је оптерећена слика.

Load(Stream)

Преузмите нову слику из одређеног тока.

public static Image Load(Stream stream)

Parameters

stream Stream

Поток за преузимање слике из.

Returns

Image

То је оптерећена слика.

Examples

Овај пример показује употребу објеката System.IO.Stream за преузимање постојеће слике датотеке

//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(ИЦОЛОРПАЛЕТ, ИЦОЛОРПАЛЕТ)

Позива се када се палет мења.

protected virtual void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette

Стари палети.

newPalette IColorPalette

Нова палета је.

OnPaletteChanging(ИЦОЛОРПАЛЕТ, ИЦОЛОРПАЛЕТ)

Позива се када се палет мења.

protected virtual void OnPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette

Стари палети.

newPalette IColorPalette

Нова палета је.

ReleaseManagedResources()

Ослобађа управљане ресурсе. Уверите се да се овде не ослобађају управљани ресурси, јер се они можда већ ослобађају.

protected override void ReleaseManagedResources()

RemoveMetadata()

Уклањање метаданих.

public virtual void RemoveMetadata()

Resize(Инт, Инт)

Преузмите слику. користи се подразумевани Aspose.Imaging.ResizeType.NearestNeighbourResample.

public void Resize(int newWidth, int newHeight)

Parameters

newWidth int

Нова ширина је.

newHeight int

Нова висина је.

Examples

Следећи пример показује како рецизирати метафил (ММФ и ЕМП).

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

Следећи пример показује како да рецимирате СВГ слику и сачувате га на ПНГ.

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)

Рециклирају слику.

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

Parameters

newWidth int

Нова ширина је.

newHeight int

Нова висина је.

resizeType ResizeType

Тип рецидива .

Examples

Рециклирајте ЕПС слику и извозите је у ПНГ формат.

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

Рециклирајте слику користећи одређени тип рецидива.

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

Овај пример наплаћује слику ВМФ-а и рецизира га користећи различите методе рецесирања.

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

Овај пример оптерећује слику и рецизира је користећи различите методе рецесирања.

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

Овај пример оптерећује растер слику и рецизира је користећи различите методе резизинга.

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

Овај пример наплаћује вишестраничну ОДГ слику и рецизира је користећи различите методе рецесирања.

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

Коришћење сегментарне маске за убрзавање процеса сегментације

// 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, ImageResizeСеттингс)

Рециклирају слику.

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

Parameters

newWidth int

Нова ширина је.

newHeight int

Нова висина је.

settings ImageResizeSettings

Успостављају се подешавања.

Examples

Рециклирајте слику користећи одређени тип рецидива.

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

Рециклирајте ЕПС слику користећи напредне подешавања.

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

Овај пример оптерећује слику и рецизира је користећи различите подешавања ресинга.

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(Инт)

Рецизира висину пропорционално. користи се подразумевани Aspose.Imaging.ResizeType.NearestNeighbourResample.

public void ResizeHeightProportionally(int newHeight)

Parameters

newHeight int

Нова висина је.

ResizeHeightProportionally(Инт, РезимеТип)

Пропорционално смањити висину.

public virtual void ResizeHeightProportionally(int newHeight, ResizeType resizeType)

Parameters

newHeight int

Нова висина је.

resizeType ResizeType

Тип резиме.

Examples

Овај пример оптерећује слику и рецизира је пропорционално користећи различите методе рецесирања. само висина се одређује, ширина се израчунава аутоматски.

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

Коришћење сегментарне маске за убрзавање процеса сегментације

// 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(int, ImageResizeСеттингс)

Пропорционално смањити висину.

public virtual void ResizeHeightProportionally(int newHeight, ImageResizeSettings settings)

Parameters

newHeight int

Нова висина је.

settings ImageResizeSettings

Слика рецимира подешавања.

ResizeWidthProportionally(Инт)

Рецизира ширину пропорционално. користи се подразумевани Aspose.Imaging.ResizeType.NearestNeighbourResample.

public void ResizeWidthProportionally(int newWidth)

Parameters

newWidth int

Нова ширина је.

ResizeWidthProportionally(Инт, РезимеТип)

Пропорционално смањити ширину.

public virtual void ResizeWidthProportionally(int newWidth, ResizeType resizeType)

Parameters

newWidth int

Нова ширина је.

resizeType ResizeType

Тип резиме.

Examples

Овај пример оптерећује слику и рецизира је пропорционално користећи различите методе рецесирања. само ширина се одређује, висина се израчунава аутоматски.

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(int, ImageResizeСеттингс)

Пропорционално смањити ширину.

public virtual void ResizeWidthProportionally(int newWidth, ImageResizeSettings settings)

Parameters

newWidth int

Нова ширина је.

settings ImageResizeSettings

Слика рецимира подешавања.

Rotate(Флоат)

Ротирајте слику око центра.

public virtual void Rotate(float angle)

Parameters

angle float

Угао ротације у степени. позитивне вредности ће ротирати сат.

RotateFlip(RotateFlipType)

Ротира, флип, или ротира и флип слику.

public abstract void RotateFlip(RotateFlipType rotateFlipType)

Parameters

rotateFlipType RotateFlipType

Тип ротираног флипа.

Examples

Овај пример показује употребу операције Ротате на слици.Пример преузима постојећу слику датотеку са одређене локације диска и врши операцију Ротата на фотографији према вредности Енум ВЛ17.РоттеФлипТип

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

Овај пример оптерећује слику, окреће је на 90 степени са часовима и опционално флипира слике хоризонтално и (или) вертикално.

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

Овај пример оптерећује ОДГ слику, окреће је на 90 степени са часовима и опционално флипира слике хоризонтално и (или) вертикално.

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

Сачува податке слике у подземном току.

public override sealed void Save()

Examples

Следећи пример показује како сачувати интегрисани БМП слику или део ње у датотеке или току.

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(Стринг)

Сачува слику на одређеном локацији датотеке.

public override void Save(string filePath)

Parameters

filePath string

Пут датотеке да сачувате слику на.

Save(Стринг, ImageOptionsBase)

Сачува податке објекта на одређеном локацији датотеке у одређеном формату датотеке према опцијама за сачување.

public virtual void Save(string filePath, ImageOptionsBase options)

Parameters

filePath string

Пут датотеке .

options ImageOptionsBase

о опцијама .

Examples

Следећи пример преузима БМП слику из датотеке, а затим сачува слика у ПНГ фајл.

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

Овај пример показује једноставне кораке за сачување слике. да би се показала ова операција, преузимамо постојећи датотеку са одређеног локације диска, обављамо операцију Ротација на слици и Сачувамо слику у ПСД формату користећи Патх Датотека

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

Следећи пример показује како сачувати интегрисани БМП слику или део ње у датотеке или току.

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(струја, ImageOptionsBase, Rectangle)

Сачува податке објекта на одређеном локацији датотеке у одређеном формату датотеке према опцијама за сачување.

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

Parameters

filePath string

Пут датотеке .

options ImageOptionsBase

о опцијама .

boundsRectangle Rectangle

Слика дестинације ограничава правоугао. Поставите празан правоугао за коришћење изворних граница.

Examples

Следећи пример преузима БМП слику из датотеке, а затим сачува правоугаони део слике у ПНГ фајл.

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

Следећи пример показује како сачувати интегрисани БМП слику или део ње у датотеке или току.

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

Опције

ImageSaveException

Slika spašavanja nije uspela.

Save(Стрејм, ImageOptionsBase)

Сачува податке слике у одређеном току у одређеном формату датотеке према опцијама за сачување.

public void Save(Stream stream, ImageOptionsBase optionsBase)

Parameters

stream Stream

Поток да сачувате податке слике на.

optionsBase ImageOptionsBase

Opcije za štednju.

Examples

Следећи пример преузима слику из датотеке, а затим сачува имиџ у ПНГ фалсификовани ток.

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

Да би се показала ова операција, пример преузима постојећи датотеку са одређене локације диска, врши операцију Ротација на слици и Сачува слику у ПСД формату.

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

Следећи пример показује како сачувати интегрисани БМП слику или део ње у датотеке или току.

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

Опције

ArgumentException

Не може се сачувати у одређеном формату, јер се тренутно не подржава; опције

ImageSaveException

Izvoz slika nije uspeo.

Save(Стрејм, ImageOptionsBase, Ректонгл)

Сачува податке слике у одређеном току у одређеном формату датотеке према опцијама за сачување.

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

Parameters

stream Stream

Поток да сачувате податке слике на.

optionsBase ImageOptionsBase

Opcije za štednju.

boundsRectangle Rectangle

Слика дестинације ограничава правоугао. Поставите празан правоугао за коришћење изворних граница.

Examples

Следећи пример преузима слику из датотеке, а затим сачува правоугаони део слике у ПНГ протоку.

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

Следећи пример показује како сачувати интегрисани БМП слику или део ње у датотеке или току.

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

Опције

ArgumentException

Не може се сачувати у одређеном формату, јер се тренутно не подржава; опције

ImageSaveException

Izvoz slika nije uspeo.

SetPalette(ИЦОЛОРПАЛЕТ, БООЛ)

Поставите палету слике.

public abstract void SetPalette(IColorPalette palette, bool updateColors)

Parameters

palette IColorPalette

Палет је постављен.

updateColors bool

ако је постављена на “истинске” боје ће бити ажурирана према новој палети; иначе индекси боја остају непромењени. Имајте на уму да непромењени индекси могу срушити слику на пуњењу ако неки индекси немају одговарајуће палети улоге.

UpdateContainer(Image)

Ажурирајте контејнер.

protected void UpdateContainer(Image container)

Parameters

container Image

То је контејнер.

Гледајте такође

DataStreamSupporter , IObjectWithBounds

 Српски