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
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");
}
}
Резюме зображення за допомогою конкретного типу Resize.
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");
}
Цей приклад створює новий файл зображення на певній ділянці диска, як зазначено джерело властивості прикладу BmpOptions. Кілька властивостей для припущення Bmoptions встановлюються перед створенням реального знімку.
//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; }
вартість нерухомості
BackgroundColor
отримує або встановлює значення для кольору фону.
public virtual Color BackgroundColor { get; set; }
вартість нерухомості
BitsPerPixel
Знайдіть біти зображення за кількістю пікселів.
public abstract int BitsPerPixel { get; }
вартість нерухомості
Bounds
Знайдіть межі зображення.
public Rectangle Bounds { get; }
вартість нерухомості
BufferSizeHint
Знайдіть або встановить показник розміру буферу, який визначається максимально допустимою розміром для всіх внутрішніх буферів.
public int BufferSizeHint { get; set; }
вартість нерухомості
Container
Використовується контейнер Aspose.Imaging.Image.
public Image Container { get; }
вартість нерухомості
Remarks
Якщо ця власність не нульова, вона вказує на те, що зображення міститься в іншому зображенні.
FileFormat
Отримає вартість файлового формату
public virtual FileFormat FileFormat { get; }
вартість нерухомості
HasBackgroundColor
Приймає або встановлює значення, яке вказує на те, чи має зображення колір фону.
public virtual bool HasBackgroundColor { get; set; }
вартість нерухомості
Height
Знайдіть висоту зображення.
public abstract int Height { get; }
вартість нерухомості
InterruptMonitor
Приймає або встановлює відключений монитор.
public InterruptMonitor InterruptMonitor { get; set; }
вартість нерухомості
Palette
Палет кольорів не використовується, коли пікселі представлені безпосередньо.
public IColorPalette Palette { get; set; }
вартість нерухомості
Size
Знайдіть розмір зображення.
public Size Size { get; }
вартість нерухомості
Examples
Цей приклад показує, як завантажити зображення DJVU з потоку файлів і друкувати інформацію про сторінки.
string dir = "c:\\temp\\";
// Load a DJVU image from a file stream.
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.djvu"))
{
using (Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = new Aspose.Imaging.FileFormats.Djvu.DjvuImage(stream))
{
System.Console.WriteLine("The total number of pages: {0}", djvuImage.Pages.Length);
System.Console.WriteLine("The active page number: {0}", djvuImage.ActivePage.PageNumber);
System.Console.WriteLine("The first page number: {0}", djvuImage.FirstPage.PageNumber);
System.Console.WriteLine("The last page number: {0}", djvuImage.LastPage.PageNumber);
foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage djvuPage in djvuImage.Pages)
{
System.Console.WriteLine("--------------------------------------------------");
System.Console.WriteLine("Page number: {0}", djvuPage.PageNumber);
System.Console.WriteLine("Page size: {0}", djvuPage.Size);
System.Console.WriteLine("Page raw format: {0}", djvuPage.RawDataFormat);
}
}
}
//The output may look like this:
//The total number of pages: 2
//The active page number: 1
//The first page number: 1
//The last page number: 2
//--------------------------------------------------
//Page number: 1
//Page size: { Width = 2481, Height = 3508}
//Page raw format: RgbIndexed1Bpp, used channels: 1
//--------------------------------------------------
//Page number: 2
//Page size: { Width = 2481, Height = 3508}
//Page raw format: RgbIndexed1Bpp, used channels: 1
UsePalette
Отримається значення, яке вказує на те, чи використовується палетка зображення.
public virtual bool UsePalette { get; }
вартість нерухомості
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; }
вартість нерухомості
Methods
CanLoad(стрічка)
Визначити, чи можна завантажити зображення з зазначеного файлового шляху.
public static bool CanLoad(string filePath)
Parameters
filePath
string
Довідка про шлях.
Returns
«правдивий», якщо зображення можна завантажити з зазначеного файлу; в іншому випадку, «фальшивий».
Examples
Цей приклад визначає, чи можна завантажити зображення з файлу.
// Use an absolute path to the file
bool canLoad = Aspose.Imaging.Image.CanLoad(@"c:\temp\sample.gif");
CanLoad(ТОВАРИСТВО З ОБМЕЖЕНОЮ ВІДПОВІДАЛЬНІстю)
Визначити, чи можна завантажити зображення з зазначеного файлового шляху і факультативно використовувати зазначені відкриті варіанти.
public static bool CanLoad(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
Довідка про шлях.
loadOptions
LoadOptions
Вибір опціонів навантаження.
Returns
«правдивий», якщо зображення можна завантажити з зазначеного файлу; в іншому випадку, «фальшивий».
CanLoad(Stream)
Визначити, чи можна завантажити зображення з зазначеного потоку.
public static bool CanLoad(Stream stream)
Parameters
stream
Stream
Потоки для завантаження.
Returns
«правдивий», якщо зображення можна завантажити з зазначеного потоку; в іншому випадку, «фальшивий».
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)
Визначити, чи можна завантажувати зображення з зазначеного потоку і факультативно використовувати зазначену loadOptions'.
public static bool CanLoad(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
Потоки для завантаження.
loadOptions
LoadOptions
Вибір опціонів навантаження.
Returns
«правдивий», якщо зображення можна завантажити з зазначеного потоку; в іншому випадку, «фальшивий».
CanSave(ImageOptionsBase)
Визначає, чи можна зберегти зображення в визначений формат файлу, представлений минулим варіантом збереження.
public bool CanSave(ImageOptionsBase options)
Parameters
options
ImageOptionsBase
Використання варіантів збереження.
Returns
«правдивий», якщо зображення можна зберегти в визначений формат файлу, представлений минулим варіантом збереження; в іншому випадку, «фальсифікований».
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(Історія Історія Історія Історія Історія)
Створення нового зображення за допомогою визначених варіантів створення.
public static Image Create(ImageOptionsBase imageOptions, int width, int height)
Parameters
imageOptions
ImageOptionsBase
Опції зображення.
width
int
Про широту .
height
int
У висоті .
Returns
Нещодавно створений зображення.
Examples
Цей приклад створює новий файл зображення на певній ділянці диска, як зазначено джерело властивості прикладу BmpOptions. Кілька властивостей для припущення Bmoptions встановлюються перед створенням реального знімку.
//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
Зображення як ImultipageImage
Create(MultipageCreateOptions)
Створення визначеного мультисторінки створює варіанти.
public static Image Create(MultipageCreateOptions multipageCreateOptions)
Parameters
multipageCreateOptions
MultipageCreateOptions
Кількість сторінок створює варіанти.
Returns
багатостороннє зображення
Create(стрічка[ ], Болл)
Створює багатосторонню картину, що містить зазначені файли.
public static Image Create(string[] files, bool throwExceptionOnLoadError)
Parameters
files
string
[ ]
і файлів .
throwExceptionOnLoadError
bool
Якщо встановити «правдивий» [викиньте виняток на помилку навантаження].
Returns
багатостороннє зображення
Create(стрічка[])
Створює багатосторонню картину, що містить зазначені файли.
public static Image Create(string[] files)
Parameters
files
string
[ ]
і файлів .
Returns
багатостороннє зображення
Create(Image[ ], Болл)
Створює нову картину, яка визначає зображення як сторінки.
public static Image Create(Image[] images, bool disposeImages)
Parameters
images
Image
[ ]
і зображеннями .
disposeImages
bool
Якщо встановити на «правдивий» [доставити зображення].
Returns
Зображення як ImultipageImage
Crop(Rectangle)
Використання визначеного прямокутника.
public virtual void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
Це праворуч.
Examples
У наступному прикладі з’являється зображення растер. Область вирощування визначається за допомогою 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(ІНТ, ІНТ, ІНТ)
Зображення рослини з переміщеннями.
public virtual void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
int
У лівому зміні.
rightShift
int
Правильний перехід
topShift
int
Верхній перехід
bottomShift
int
Нижнє переміщення .
Examples
Наступний приклад вирощує зображення растер. Площа видобутку визначається за допомогою лівих, верхніх, правих, нижніх маржів.
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)
Знайдіть те, що не може зберегти повідомлення.
protected virtual string GetCanNotSaveMessage(ImageOptionsBase optionsBase)
Parameters
optionsBase
ImageOptionsBase
Опції зображення.
Returns
Вони не можуть зберегти повідомлення.
GetDefaultOptions(Об’єкт[])
Використовуйте стандартні варіанти.
public virtual ImageOptionsBase GetDefaultOptions(object[] args)
Parameters
args
object
[ ]
І аргументи .
Returns
Дефіцитні варіанти
GetFileFormat(стрічка)
Завантажити формат файлу.
public static FileFormat GetFileFormat(string filePath)
Parameters
filePath
string
Довідка про шлях.
Returns
Визначений формат файлу.
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
Визначений формат файлу.
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
Приготований прямокутник
GetFitRectangle(Різдвяна, int[])
Знайдіть прямокутник, який відповідає поточній бітмапі з урахуванням пікселів, які пройшли.
protected Rectangle GetFitRectangle(Rectangle rectangle, int[] pixels)
Parameters
rectangle
Rectangle
Для того, щоб отримати правильний прямокутник.
pixels
int
[ ]
32-розрядний ARGB пікселів.
Returns
Приготований прямокутник.
GetFittingRectangle(Імперія, Імперія, Імперія)
З’являється прямий кут, який відповідає поточному зображенню.
public static Rectangle GetFittingRectangle(Rectangle rectangle, int width, int height)
Parameters
rectangle
Rectangle
Для того, щоб отримати правильний прямокутник.
width
int
Ширина об’єкта
height
int
Висота об’єкта
Returns
Прямий прямий кут або виняток, якщо не можна знайти жодного прямого кута.
GetFittingRectangle(Різдвяна, int[ ], ІТ, ІТ)
З’являється прямий кут, який відповідає поточному зображенню.
public static Rectangle GetFittingRectangle(Rectangle rectangle, int[] pixels, int width, int height)
Parameters
rectangle
Rectangle
Для того, щоб отримати правильний прямокутник.
pixels
int
[ ]
32-бітний ARGB піксель
width
int
Ширина об’єкта
height
int
Висота об’єкта
Returns
Прямий прямий кут або виняток, якщо не можна знайти жодного прямого кута.
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
Зображення для експорту
GetOriginalOptions()
Виберіть варіанти на основі оригінальних налаштувань файлу.Це може бути корисним для збереження дрібної глибини та інших параметрів оригінального зображення без змін.Наприклад, якщо ми завантажуємо чорно-білий PNG зображення з 1 бітом на піксель, а потім збережемо його за допомогоюAspose.Imaging.DataStreamSupporter.Save(System.String) метод, вихід PNG з 8-бітним на піксель буде вироблятися.Щоб уникнути цього і зберегти PNG зображення з 1 бітом на піксель, використовуйте цей метод, щоб отримати відповідні варіанти збереження і пройти їхдо методу Aspose.Imaging.Image.Save(System.String,_Wl17.ImageOptionsBase) як другий параметр.
public virtual ImageOptionsBase GetOriginalOptions()
Returns
Вибір варіантів, заснованих на оригінальних файлових налаштуваннях.
GetProportionalHeight(ІТ, ІТ, ІТ)
Вона має пропорційну висоту.
public static int GetProportionalHeight(int width, int height, int newWidth)
Parameters
width
int
Про широту .
height
int
У висоті .
newWidth
int
Нові ширини .
Returns
Пропорційна висота
GetProportionalWidth(ІТ, ІТ, ІТ)
Вона має пропорційну ширину.
public static int GetProportionalWidth(int width, int height, int newHeight)
Parameters
width
int
Про широту .
height
int
У висоті .
newHeight
int
Нові висоти .
Returns
Пропорційна ширина
GetSerializedStream(ImageOptionsBase, Rectangle, out int)
Перетворюється на абс.
public virtual Stream GetSerializedStream(ImageOptionsBase imageOptions, Rectangle clippingRectangle, out int pageNumber)
Parameters
imageOptions
ImageOptionsBase
Опції зображення.
clippingRectangle
Rectangle
Створення Кліпінг прямокутник.
pageNumber
int
Номер сторінки .
Returns
Серіалізований потік
Load(ТОВАРИСТВО З ОБМЕЖЕНОЮ ВІДПОВІДАЛЬНІстю)
Завантажує новий зображення з зазначеного файлового шляху або URL.Якщо filePath’ є файловим шляхом, то метод просто відчиняє файл.А якщо <code class=paramaFilePat’ - це URL, метод завантажує файл, зберігає його як тимчасовий, і відкриває його.
public static Image Load(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
Шлях файлу або URL для завантаження зображення.
loadOptions
LoadOptions
Вибір опціонів навантаження.
Returns
Завантажений зображення
Load(стрічка)
Завантажує новий зображення з зазначеного файлового шляху або URL.Якщо filePath’ є файловим шляхом, то метод просто відчиняє файл.А якщо <code class=paramaFilePat’ - це URL, метод завантажує файл, зберігає його як тимчасовий, і відкриває його.
public static Image Load(string filePath)
Parameters
filePath
string
Шлях файлу або URL для завантаження зображення.
Returns
Завантажений зображення
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(Завантажити, LoadOptions)
Завантажити новий зображення з зазначеного потоку.
public static Image Load(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
Потік для завантаження зображення з.
loadOptions
LoadOptions
Вибір опціонів навантаження.
Returns
Завантажений зображення
Load(Stream)
Завантажити новий зображення з зазначеного потоку.
public static Image Load(Stream stream)
Parameters
stream
Stream
Потік для завантаження зображення з.
Returns
Завантажений зображення
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(Створення IColorPalette)
Зателефонуйте, коли змінюється палет.
protected virtual void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
Старий палець
newPalette
IColorPalette
Новий палець
OnPaletteChanging(Створення IColorPalette)
Зателефонуйте, коли змінюється палет.
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
Наступний приклад показує, як перемірювати метафіл (WMF і EMF).
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);
}
}
Наступний приклад показує, як перезавантажити зображення SVG і зберегти його в PNG.
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(ІНТ, ІНТ, ІНТ, ІНТ)
Відновлює зображення.
public virtual void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
Нові ширини .
newHeight
int
Нові висоти .
resizeType
ResizeType
Тип рецидиву
Examples
Перезавантажити зображення EPS і експортувати його в форматі PNG.
// Load EPS image
using (var image = Image.Load("AstrixObelix.eps"))
{
// Resize the image using the Mitchell cubic interpolation method
image.Resize(400, 400, ResizeType.Mitchell);
// Export image to PNG format
image.Save("ExportResult.png", new PngOptions());
}
Резюме зображення за допомогою конкретного типу Resize.
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");
}
Цей приклад завантажує зображення WMF і відтворює його за допомогою різних методів рецидиву.
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");
}
Цей приклад завантажує багатосторонній зображення ODG і рецизує його за допомогою різних методів резитування.
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(Іт, Іт, ImageResizeSettings)
Відновлює зображення.
public abstract void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
Нові ширини .
newHeight
int
Нові висоти .
settings
ImageResizeSettings
Реабілітаційні налаштування.
Examples
Резюме зображення за допомогою конкретного типу Resize.
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");
}
Відновлення EPS зображення за допомогою передових налаштувань.
// 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(Створення ImageResizeSettings)
Знизити висоту пропорційно.
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(Створення ImageResizeSettings)
Розрізати ширину пропорційно.
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
Приклад завантажує існуючий файл зображення з певної ділянки диска і виконує операцію ротації на картинці за значенням Enum Aspose.Imaging.RotateFlipType
//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");
}
}
Цей приклад завантажує зображення ODG, обертає його на 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
Наступний приклад показує, як зберегти повний BMP зображення або його частину до файлу або потоку.
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
У наступному прикладі завантажується зображення BMP з файлу, а потім зберігається образ у файл PNG.
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);
}
Для того, щоб продемонструвати цю операцію, ми завантажуємо існуючий файл з певної локації диска, виконуємо роботу обертання на зображенні і зберігаємо образ у форматі PSD за допомогою файлового шляху.
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());
}
Наступний приклад показує, як зберегти повний BMP зображення або його частину до файлу або потоку.
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, Ректанг)
Зберегти дані об’єкта до визначеного розташування файлу в визначеному форматі файлу відповідно до варіантів збереження.
public virtual void Save(string filePath, ImageOptionsBase options, Rectangle boundsRectangle)
Parameters
filePath
string
Довідка про шлях.
options
ImageOptionsBase
І варіанти .
boundsRectangle
Rectangle
Мета зображення обмежує прямокутник. Налаштуйте порожній прямокутник для використання джерел обмежень.
Examples
Наступний приклад завантажує зображення BMP з файлу, а потім зберігає прямокутну частину образу в файл PNG.
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);
}
Наступний приклад показує, як зберегти повний BMP зображення або його частину до файлу або потоку.
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
варіанти
Збереження зображень не вдалося.
Save(Потік, ImageOptionsBase)
Зберегти дані зображення до визначеного потоку в визначеному форматі файлу відповідно до варіантів збереження.
public void Save(Stream stream, ImageOptionsBase optionsBase)
Parameters
stream
Stream
Потік, щоб зберегти дані зображення на.
optionsBase
ImageOptionsBase
Вибір варіантів збереження.
Examples
Наступний приклад завантажує зображення з файлу, а потім зберігає знімки в потоку файлів PNG.
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);
}
}
Для того, щоб продемонструвати цю операцію, приклад завантажує існуючий файл з певної локації диска, виконує обертальний процес на зображенні і зберігає звіт у форматі PSD.
//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());
}
}
Наступний приклад показує, як зберегти повний BMP зображення або його частину до файлу або потоку.
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
опціонів
Не можна зберігати в зазначеному форматі, оскільки в даний час він не підтримується; опції
Експорт зображень провалився.
Save(Потік, ImageOptionsBase, Rectangle)
Зберегти дані зображення до визначеного потоку в визначеному форматі файлу відповідно до варіантів збереження.
public virtual void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Parameters
stream
Stream
Потік, щоб зберегти дані зображення на.
optionsBase
ImageOptionsBase
Вибір варіантів збереження.
boundsRectangle
Rectangle
Мета зображення обмежує прямокутник. Налаштуйте порожній прямокутник для використання джерельних обмежень.
Examples
Наступний приклад завантажує зображення з файлу, а потім зберігає прямокутну частину образу до потоку файлів PNG.
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);
}
}
Наступний приклад показує, як зберегти повний BMP зображення або його частину до файлу або потоку.
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
опціонів
Не можна зберігати в зазначеному форматі, оскільки в даний час він не підтримується; опції
Експорт зображень провалився.
SetPalette(Ікольор Палет, Боол)
Складіть палету зображення.
public abstract void SetPalette(IColorPalette palette, bool updateColors)
Parameters
palette
IColorPalette
Палетка для встановлення.
updateColors
bool
Якщо налаштуватися на «правдиві» кольори будуть оновлені відповідно до нової палети; в іншому випадку кольорові індекси залишаються незмінними.
UpdateContainer(Image)
Оновлення контейнера.
protected void UpdateContainer(Image container)
Parameters
container
Image
Це контейнер.