Class Image
Název místa: Aspose.Imaging Shromáždění: Aspose.Imaging.dll (25.4.0)
Obrázek je základní třída pro všechny typy obrázk.
[JsonObject(MemberSerialization.OptIn)]
public abstract class Image : DataStreamSupporter, IDisposable, IObjectWithBounds
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image
Derived
Implements
IDisposable , IObjectWithBounds
Dědiční členové
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
Určte, zda je paleta použita obrazem.
using (var image = Image.Load(folder + "Sample.bmp"))
{
if (image.UsePalette)
{
Console.WriteLine("The palette is used by the image");
}
}
Resize obrázek pomocí specifického typu 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");
}
Tento příklad vytváří nový soubor snímku na některém místě disku, jak je specifikováno vlastností zdroje příkladu BmpOptions. Některé vlastnosti pro příkladu BmpOptions jsou nastaveny před vytvořením skutečného obrazu.
//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()
Začíná nový příklad třídy Aspose.Imaging.Image.
[JsonConstructor]
protected Image()
Image(Ikolorová paleta)
Začíná nový příklad třídy Aspose.Imaging.Image.
protected Image(IColorPalette colorPalette)
Parameters
colorPalette
IColorPalette
barevná paleta.
Properties
AutoAdjustPalette
Obdrží nebo nastaví hodnotu, která naznačuje, zda je paleta automaticky upravena.
public bool AutoAdjustPalette { get; set; }
Hodnota nemovitosti
BackgroundColor
Obdrží nebo nastaví hodnotu pro barvu pozad.
public virtual Color BackgroundColor { get; set; }
Hodnota nemovitosti
BitsPerPixel
Obdrží obrázek bitů na pixel počítán.
public abstract int BitsPerPixel { get; }
Hodnota nemovitosti
Bounds
Obdržíte limity obrazu.
public Rectangle Bounds { get; }
Hodnota nemovitosti
BufferSizeHint
Obdržíte nebo nastavíte náznak velikosti bufferu, který je definován maximální povolenou velikostí pro všechny vnitřní buffery.
public int BufferSizeHint { get; set; }
Hodnota nemovitosti
Container
Obdržíte konteiner Aspose.Imaging.Image.
public Image Container { get; }
Hodnota nemovitosti
Remarks
Pokud tato vlastnost není nulová, znamená to, že obrázek je obsažen v jiném obrázku.
FileFormat
Obdrží hodnotu formátu souborů
public virtual FileFormat FileFormat { get; }
Hodnota nemovitosti
HasBackgroundColor
Obdrží nebo nastaví hodnotu, která naznačuje, zda obraz má barvu pozad.
public virtual bool HasBackgroundColor { get; set; }
Hodnota nemovitosti
Height
Získejte výšku obrazu.
public abstract int Height { get; }
Hodnota nemovitosti
InterruptMonitor
Obdržíte nebo nastavte přerušený monitor.
public InterruptMonitor InterruptMonitor { get; set; }
Hodnota nemovitosti
Palette
Obdrží nebo nastaví barevnou paletu. barevná paleta se nepoužívá, když jsou pixely přímo reprezentovány.
public IColorPalette Palette { get; set; }
Hodnota nemovitosti
Size
Dostane velikost obrazu.
public Size Size { get; }
Hodnota nemovitosti
Examples
Tento příklad ukazuje, jak nahrát obrázek DJVU z souborového toku a vytisknout informace o stránkách.
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
Obdrží hodnotu, která naznačuje, zda je paleta obrazu používána.
public virtual bool UsePalette { get; }
Hodnota nemovitosti
Examples
Určte, zda je paleta použita obrazem.
using (var image = Image.Load(folder + "Sample.bmp"))
{
if (image.UsePalette)
{
Console.WriteLine("The palette is used by the image");
}
}
Width
Získejte šířku obrazu.
public abstract int Width { get; }
Hodnota nemovitosti
Methods
CanLoad(Stringová)
Určuje, zda lze obrázek stáhnout z určité cesty souboru.
public static bool CanLoad(string filePath)
Parameters
filePath
string
Původní cestou souboru.
Returns
‘pravdivý“, pokud lze obrázek stahovat z uvedeného souboru; jinak „falšovan’.
Examples
Tento příklad určuje, zda lze obrázek stahovat z souboru.
// Use an absolute path to the file
bool canLoad = Aspose.Imaging.Image.CanLoad(@"c:\temp\sample.gif");
CanLoad(String a LoadOptions)
Určuje, zda lze obrázek stáhnout z určité cesty souboru a volitelně pomocí uvedených otevřených možnost.
public static bool CanLoad(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
Původní cestou souboru.
loadOptions
LoadOptions
Možnosti nabíjen.
Returns
‘pravdivý“, pokud lze obrázek stahovat z uvedeného souboru; jinak „falšovan’.
CanLoad(Stream)
Určuje, zda lze obrázek načítat z uvedeného toku.
public static bool CanLoad(Stream stream)
Parameters
stream
Stream
Překrývka na nabit.
Returns
‘pravdivý“, pokud lze obrázek nahrát z uvedeného toku; jinak „falšovan’.
Examples
Tento příklad určuje, zda lze obrázek stáhnout z souborového toku.
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(Přenos, LoadOptions)
Určuje, zda může být obrázek nahrazen ze stanoveného toku a volitelně pomocí stanoveného loadOptions'.
public static bool CanLoad(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
Překrývka na nabit.
loadOptions
LoadOptions
Možnosti nabíjen.
Returns
‘pravdivý“, pokud lze obrázek nahrát z uvedeného toku; jinak „falšovan’.
CanSave(ImageOptionsBase)
Určuje, zda lze obrázek uložit do specifikovaného formátu souboru, který je reprezentován předchozími možnostmi uložit.
public bool CanSave(ImageOptionsBase options)
Parameters
options
ImageOptionsBase
Možnosti úspory k použit.
Returns
‘pravdivý“, pokud lze obrázek uložit ve specifikovaném formátu souboru, který je reprezentován předchozími možnostmi uložení; jinak „falešn’.
Examples
Tento příklad ukazuje, jak zjistit, zda lze obrázek uložit do specifikovaného formátu souboru, který je reprezentován minulými možnostmi uložen.
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(Zdroj: Int, Int, Int)
Vytvořte nový obrázek pomocí specifikovaných možností vytvářen.
public static Image Create(ImageOptionsBase imageOptions, int width, int height)
Parameters
imageOptions
ImageOptionsBase
Možnosti snímk.
width
int
A šířka.
height
int
na výšku.
Returns
Nově vytvořený obraz.
Examples
Tento příklad vytváří nový soubor snímku na některém místě disku, jak je specifikováno vlastností zdroje příkladu BmpOptions. Některé vlastnosti pro příkladu BmpOptions jsou nastaveny před vytvořením skutečného obrazu.
//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[])
Vytváří nový obrázek pomocí specifikovaných obrázků jako stránek
public static Image Create(Image[] images)
Parameters
images
Image
[]a[]
To jsou obrázky.
Returns
Obrázek jako ImultipageImage
Create(MultipageCreateOptions)
Vytvořte specifikovanou multi-stránku vytvářet možnosti.
public static Image Create(MultipageCreateOptions multipageCreateOptions)
Parameters
multipageCreateOptions
MultipageCreateOptions
Mnoho stránek vytváří možnosti.
Returns
Multifunkční obrázek
Create(Stringová[]a[], a bool)
Vytváří vícestránkový obrázek obsahující specifikované soubory.
public static Image Create(string[] files, bool throwExceptionOnLoadError)
Parameters
files
string
[]a[]
a soubory.
throwExceptionOnLoadError
bool
Pokud je nastaven na “pravdivý” [vyjměte výjimku na chybu zatížen].
Returns
Multifunkční obrázek
Create(Stringová[])
Vytváří vícestránkový obrázek obsahující specifikované soubory.
public static Image Create(string[] files)
Parameters
files
string
[]a[]
a soubory.
Returns
Multifunkční obrázek
Create(Image[]a[], a bool)
Vytváří nový obrázek specifikované obrázky jako stránky.
public static Image Create(Image[] images, bool disposeImages)
Parameters
images
Image
[]a[]
To jsou obrázky.
disposeImages
bool
Pokud je nastaven na „pravdivý“ [připravte obrázky].
Returns
Obrázek jako ImultipageImage
Crop(Rectangle)
Zkresluje specifikovaný rektangul.
public virtual void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
V pravém úhlu.
Examples
Následující příklad skládá rasterový obrázek. skládka je specifikována prostřednictvím 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, int)
Obrázek rostliny se změnami.
public virtual void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
int
Vlevo se měn.
rightShift
int
Na správnou změnu.
topShift
int
V horním směru.
bottomShift
int
V dolním směru.
Examples
Následující příklad pěstuje rasterový obrázek. pěstovací oblast je specifikována přes levé, horní, pravé, dolní marže.
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)
Získává to, co nemůže zachránit zprávu.
protected virtual string GetCanNotSaveMessage(ImageOptionsBase optionsBase)
Parameters
optionsBase
ImageOptionsBase
Možnosti snímk.
Returns
Není možné zachránit poselstv.
GetDefaultOptions(Objekt[])
Získejte standardní možnosti.
public virtual ImageOptionsBase GetDefaultOptions(object[] args)
Parameters
args
object
[]a[]
a argumenty.
Returns
Defaultní možnosti
GetFileFormat(Stringová)
Dostane formát souboru.
public static FileFormat GetFileFormat(string filePath)
Parameters
filePath
string
Původní cestou souboru.
Returns
Formát určeného souboru.
Examples
Tento příklad ukazuje, jak určit formát obrazu bez načítání celého obrazu z souboru.
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
Určený formát souboru neznamená, že specifikovaný obrázek může být nahrazen. Použijte jednu z metody CanLoad přetížení, aby se zjistilo, zda soubor může být nahrazen.
GetFileFormat(Stream)
Dostane formát souboru.
public static FileFormat GetFileFormat(Stream stream)
Parameters
stream
Stream
To je proud.
Returns
Formát určeného souboru.
Examples
Tento příklad ukazuje, jak určit formát obrazu bez načítání celého obrazu z souborového toku.
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
Určený formát souboru neznamená, že specifikovaný obrázek může být nahrazen. Použijte jednu z metody CanLoad přetížení, aby se zjistilo, zda může být stream nahrazen.
GetFitRectangle(Rectangle)
Obdrží rektangle, které se hodí k aktuálnímu obrazu.
protected Rectangle GetFitRectangle(Rectangle rectangle)
Parameters
rectangle
Rectangle
Připravte se k tomu, abyste dostali pravý úhel.
Returns
Přizpůsobený rektangle
GetFitRectangle(Vzdálenost, int[])
Obdrží rektangle, které odpovídá aktuální bitmap s přihlédnutím k přeneseným pixelům. Přenesený počet pixelů by měl být stejný jako velikost přeneseného rektanglu.
protected Rectangle GetFitRectangle(Rectangle rectangle, int[] pixels)
Parameters
rectangle
Rectangle
Připravte se k tomu, abyste dostali pravý úhel.
pixels
int
[]a[]
32bitové ARGB pixely.
Returns
Vhodný pravý úhel.
GetFittingRectangle(Vzdělávání, int, int)
Obdrží rektangle, které se hodí k aktuálnímu obrazu.
public static Rectangle GetFittingRectangle(Rectangle rectangle, int width, int height)
Parameters
rectangle
Rectangle
Připravte se k tomu, abyste dostali pravý úhel.
width
int
Objektová šířka.
height
int
Výška objektu.
Returns
Přizpůsobený pravý úhel nebo výjimka, pokud není nalezen žádný přizpůsobený pravý úhel.
GetFittingRectangle(Vzdálenost, int[]a[], int , int)
Obdrží rektangle, které se hodí k aktuálnímu obrazu.
public static Rectangle GetFittingRectangle(Rectangle rectangle, int[] pixels, int width, int height)
Parameters
rectangle
Rectangle
Připravte se k tomu, abyste dostali pravý úhel.
pixels
int
[]a[]
32bitové pixely ARGB.
width
int
Objektová šířka.
height
int
Výška objektu.
Returns
Přizpůsobený pravý úhel nebo výjimka, pokud není nalezen žádný přizpůsobený pravý úhel.
GetImage2Export(ImageOptionsBase, Rectangle, IImageExporter)
Obdrží obraz k vývozu.
[Obsolete("Will be changed by method with other signature")]
protected virtual Image GetImage2Export(ImageOptionsBase optionsBase, Rectangle boundsRectangle, IImageExporter exporter)
Parameters
optionsBase
ImageOptionsBase
Základní možnosti obrázk.
boundsRectangle
Rectangle
Hranice jsou rektangulárn.
exporter
IImageExporter
a vývozce.
Returns
Obrázek na export
GetOriginalOptions()
Získáte možnosti na základě původních nastavení souboru.To může být užitečné pro udržení bitové hloubky a dalších parametrů původního obrazu nezměněných.Například, pokud nahráváme černobílý PNG obrázek s 1 bitem na pixel a pak ho uložíme pomocíMetoda Aspose.Imaging.DataStreamSupporter.Save(System.String) bude produkována výstupní PNG s 8-bitovým obrazem na pixel.Chcete-li se tomu vyhnout a ušetřit PNG obrázek s 1 bitem na pixel, použijte tuto metodu, abyste získali odpovídající možnosti ušetření a projít jedo metody Aspose.Imaging.Image.Save(System.String,Aspose.Imaging.ImageOptionsBase) jako druhý parametr.
public virtual ImageOptionsBase GetOriginalOptions()
Returns
Možnosti založené na původních nastavení soubor.
GetProportionalHeight(Třeba int, int, int)
Dostane přiměřenou výšku.
public static int GetProportionalHeight(int width, int height, int newWidth)
Parameters
width
int
A šířka.
height
int
na výšku.
newWidth
int
A nová šířka.
Returns
a poměrné výšky.
GetProportionalWidth(Třeba int, int, int)
Dostáváme přiměřenou šířku.
public static int GetProportionalWidth(int width, int height, int newHeight)
Parameters
width
int
A šířka.
height
int
na výšku.
newHeight
int
A nová výška.
Returns
Pro proporční šířka.
GetSerializedStream(ImageOptionsBase, Rectangle, out int)
Přeměna na APS.
public virtual Stream GetSerializedStream(ImageOptionsBase imageOptions, Rectangle clippingRectangle, out int pageNumber)
Parameters
imageOptions
ImageOptionsBase
Možnosti snímk.
clippingRectangle
Rectangle
Klipovací pravý úhel.
pageNumber
int
A číslo stránky.
Returns
Serializovaný proud
Load(String a LoadOptions)
Stáhne nový obrázek z určité cesty souboru nebo URL.Jestliže filePath’ je cesta souboru, metoda jen otevře soubor.Jestliže
filePath’ je URL, metoda stáhne soubor, ukládá ho jako dočasný a otevírá ho.
public static Image Load(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
Stránka souboru nebo URL pro načtení obrázku z.
loadOptions
LoadOptions
Možnosti nabíjen.
Returns
Nabízený obrázek.
Load(Stringová)
Stáhne nový obrázek z určité cesty souboru nebo URL.Jestliže filePath’ je cesta souboru, metoda jen otevře soubor.Jestliže
filePath’ je URL, metoda stáhne soubor, ukládá ho jako dočasný a otevírá ho.
public static Image Load(string filePath)
Parameters
filePath
string
Stránka souboru nebo URL pro načtení obrázku z.
Returns
Nabízený obrázek.
Examples
Tento příklad ukazuje načítání stávajícího souboru snímku do příkladu Aspose.Imaging.Image pomocí specifikované cesty souboru.
//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(Přenos, LoadOptions)
Nahraje nový obrázek z specifikovaného toku.
public static Image Load(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
Přechod na nahrávání obrazu z.
loadOptions
LoadOptions
Možnosti nabíjen.
Returns
Nabízený obrázek.
Load(Stream)
Nahraje nový obrázek z specifikovaného toku.
public static Image Load(Stream stream)
Parameters
stream
Stream
Přechod na nahrávání obrazu z.
Returns
Nabízený obrázek.
Examples
Tento příklad ukazuje používání Objektů System.IO.Stream ke stažení stávajícího souboru snímku
//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(Červená paleta, IColorPalette)
Volá se, když se paleta měn.
protected virtual void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
A stará paleta.
newPalette
IColorPalette
A nová paleta.
OnPaletteChanging(Červená paleta, IColorPalette)
Volá se, když se paleta měn.
protected virtual void OnPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
A stará paleta.
newPalette
IColorPalette
A nová paleta.
ReleaseManagedResources()
Ujistěte se, že zde nejsou zveřejněny žádné nezveřejněné zdroje, protože mohou být již zveřejněny.
protected override void ReleaseManagedResources()
RemoveMetadata()
Odstranění metadata.
public virtual void RemoveMetadata()
Resize(a int, int)
Používá se výchozí Aspose.Imaging.ResizeType.NearestNeighbourResample.
public void Resize(int newWidth, int newHeight)
Parameters
newWidth
int
A nová šířka.
newHeight
int
A nová výška.
Examples
Následující příklad ukazuje, jak změnit metafýl (WMF a 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);
}
}
Následující příklad ukazuje, jak přehodnotit SVG obrázek a uložit ho do 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(int, int, resizeType)
Odstraňuje obraz.
public virtual void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
A nová šířka.
newHeight
int
A nová výška.
resizeType
ResizeType
Tyto typy jsou recidivn.
Examples
Obnovte obraz EPS a exportujte ho do formátu 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 obrázek pomocí specifického typu 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");
}
Tento příklad nahrává obrázek WMF a recidivuje ho pomocí různých recidivních metod.
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);
}
Tento příklad nahrává obrázek a recidivuje ho pomocí různých recidivních metod.
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");
}
Tento příklad nahrazuje rasterový obrázek a resizuje ho pomocí různých recidivních metod.
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");
}
Tento příklad nahrává vícestránkový obrázek ODG a recidivuje ho pomocí různých recidivních metod.
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());
}
Použití segmentové masky k urychlení segmentování
// Masking export options
Aspose.Imaging.ImageOptions.PngOptions exportOptions = new Aspose.Imaging.ImageOptions.PngOptions();
exportOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
exportOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
Aspose.Imaging.Masking.Options.MaskingOptions maskingOptions = new Aspose.Imaging.Masking.Options.MaskingOptions();
// Use GraphCut clustering.
maskingOptions.Method = Masking.Options.SegmentationMethod.GraphCut;
maskingOptions.Decompose = false;
maskingOptions.Args = new Aspose.Imaging.Masking.Options.AutoMaskingArgs();
// The backgroung color will be transparent.
maskingOptions.BackgroundReplacementColor = Aspose.Imaging.Color.Transparent;
maskingOptions.ExportOptions = exportOptions;
string dir = "c:\\temp\\";
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
{
Aspose.Imaging.Size imageSize = image.Size;
// Reducing image size to speed up the segmentation process
image.ResizeHeightProportionally(600, Aspose.Imaging.ResizeType.HighQualityResample);
// Create an instance of the ImageMasking class.
Aspose.Imaging.Masking.ImageMasking masking = new Aspose.Imaging.Masking.ImageMasking(image);
// Divide the source image into several clusters (segments).
using (Aspose.Imaging.Masking.Result.MaskingResult maskingResult = masking.Decompose(maskingOptions))
{
// Getting the foreground mask
using (Aspose.Imaging.RasterImage foregroundMask = maskingResult[1].GetMask())
{
// Increase the size of the mask to the size of the original image
foregroundMask.Resize(imageSize.Width, imageSize.Height, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Applying the mask to the original image to obtain a foreground segment
using (Aspose.Imaging.RasterImage originImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
{
Aspose.Imaging.Masking.ImageMasking.ApplyMask(originImage, foregroundMask, maskingOptions);
originImage.Save(dir + "BigImage_foreground.png", exportOptions);
}
}
}
}
Resize(snímky, snímky, snímky)
Odstraňuje obraz.
public abstract void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
A nová šířka.
newHeight
int
A nová výška.
settings
ImageResizeSettings
Zpětné nastaven.
Examples
Resize obrázek pomocí specifického typu 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");
}
Obnovte obraz EPS pomocí pokročilých nastaven.
// 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());
}
Tento příklad nahrává obrázek a recykluje ho pomocí různých nastavení recyklace.
string dir = "c:\\temp\\";
Aspose.Imaging.ImageResizeSettings resizeSettings = new Aspose.Imaging.ImageResizeSettings();
// The adaptive algorithm based on weighted and blended rational function and lanczos3 interpolation.
resizeSettings.Mode = Aspose.Imaging.ResizeType.AdaptiveResample;
// The small rectangular filter
resizeSettings.FilterType = Aspose.Imaging.ImageFilterType.SmallRectangular;
// The number of colors in the palette.
resizeSettings.EntriesCount = 256;
// The color quantization is not used
resizeSettings.ColorQuantizationMethod = ColorQuantizationMethod.None;
// The euclidian method
resizeSettings.ColorCompareMethod = ColorCompareMethod.Euclidian;
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
// Scale down by 2 times using adaptive resampling.
image.Resize(image.Width / 2, image.Height / 2, resizeSettings);
image.Save(dir + "downsample.adaptive.gif");
}
ResizeHeightProportionally(Int)
Používá se výchozí Aspose.Imaging.ResizeType.NearestNeighbourResample.
public void ResizeHeightProportionally(int newHeight)
Parameters
newHeight
int
A nová výška.
ResizeHeightProportionally(Zpět, ResizeType)
Výška je přiměřeně snížena.
public virtual void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
int
A nová výška.
resizeType
ResizeType
Druh odrůdy.
Examples
Tento příklad nahrává obrázek a proporčně ho recidivuje pomocí různých recidivních metod. pouze výška je specifikována, šířka se automaticky vypočít.
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");
}
Použití segmentové masky k urychlení segmentování
// Masking export options
Aspose.Imaging.ImageOptions.PngOptions exportOptions = new Aspose.Imaging.ImageOptions.PngOptions();
exportOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
exportOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
Aspose.Imaging.Masking.Options.MaskingOptions maskingOptions = new Aspose.Imaging.Masking.Options.MaskingOptions();
// Use GraphCut clustering.
maskingOptions.Method = Masking.Options.SegmentationMethod.GraphCut;
maskingOptions.Decompose = false;
maskingOptions.Args = new Aspose.Imaging.Masking.Options.AutoMaskingArgs();
// The backgroung color will be transparent.
maskingOptions.BackgroundReplacementColor = Aspose.Imaging.Color.Transparent;
maskingOptions.ExportOptions = exportOptions;
string dir = "c:\\temp\\";
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
{
Aspose.Imaging.Size imageSize = image.Size;
// Reducing image size to speed up the segmentation process
image.ResizeHeightProportionally(600, Aspose.Imaging.ResizeType.HighQualityResample);
// Create an instance of the ImageMasking class.
Aspose.Imaging.Masking.ImageMasking masking = new Aspose.Imaging.Masking.ImageMasking(image);
// Divide the source image into several clusters (segments).
using (Aspose.Imaging.Masking.Result.MaskingResult maskingResult = masking.Decompose(maskingOptions))
{
// Getting the foreground mask
using (Aspose.Imaging.RasterImage foregroundMask = maskingResult[1].GetMask())
{
// Increase the size of the mask to the size of the original image
foregroundMask.Resize(imageSize.Width, imageSize.Height, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Applying the mask to the original image to obtain a foreground segment
using (Aspose.Imaging.RasterImage originImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
{
Aspose.Imaging.Masking.ImageMasking.ApplyMask(originImage, foregroundMask, maskingOptions);
originImage.Save(dir + "BigImage_foreground.png", exportOptions);
}
}
}
}
ResizeHeightProportionally(snímky, imageresize)
Výška je přiměřeně snížena.
public virtual void ResizeHeightProportionally(int newHeight, ImageResizeSettings settings)
Parameters
newHeight
int
A nová výška.
settings
ImageResizeSettings
Obrázek zobrazuje nastaven.
ResizeWidthProportionally(Int)
Používá se výchozí Aspose.Imaging.ResizeType.NearestNeighbourResample.
public void ResizeWidthProportionally(int newWidth)
Parameters
newWidth
int
A nová šířka.
ResizeWidthProportionally(Zpět, ResizeType)
Rozšířte šířku poměrn.
public virtual void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
int
A nová šířka.
resizeType
ResizeType
Druh odrůdy.
Examples
Tento příklad nahrává obrázek a proporčně ho recidivuje pomocí různých recidivních metod. Pouze šířka je specifikována, výška je automaticky vypočítána.
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(snímky, imageresize)
Rozšířte šířku poměrn.
public virtual void ResizeWidthProportionally(int newWidth, ImageResizeSettings settings)
Parameters
newWidth
int
A nová šířka.
settings
ImageResizeSettings
Obrázek zobrazuje nastaven.
Rotate(flotila)
Obrázek se otáčí kolem centra.
public virtual void Rotate(float angle)
Parameters
angle
float
Otevírací úhel v stupních. pozitivní hodnoty se otáčí po hodin.
RotateFlip(RotateFlipType)
Obrátí, flips, nebo otáčí a flips obrázek.
public abstract void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipType
Typ rotačního flipu.
Examples
Tento příklad ukazuje použití operace Rotate na obrázku. příklad nabírá stávající obrazový soubor z určité polohy disku a provádí operaci Rotate na obrázku podle hodnoty 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();
}
Tento příklad nahrává obrázek, otáčí ho o 90 stupňů hodinově a volitelně flips obraz horizontálně a/nebo vertikáln.
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");
}
}
Tento příklad nabírá obrázek ODG, otáčí ho o 90 stupňů hodinově a volitelně flips obraz horizontálně a/nebo vertikáln.
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()
Uloží obrázkové údaje do podkladového toku.
public override sealed void Save()
Examples
Následující příklad ukazuje, jak uložit kompletní BMP obrázek nebo jeho část do souboru nebo toku.
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(Stringová)
Uloží obrázek na specifikovanou polohu souboru.
public override void Save(string filePath)
Parameters
filePath
string
Přečtěte si mapu, jak zachránit obrázek.
Save(Shrnutí, ImageOptionsBase)
Uloží data objektu na specifikovanou polohu souboru ve specifikovaném formátu souboru podle možností uložen.
public virtual void Save(string filePath, ImageOptionsBase options)
Parameters
filePath
string
Původní cestou souboru.
options
ImageOptionsBase
Tyto možnosti.
Examples
Následující příklad nahrává obrázek BMP z souboru, pak ukládá obrázek do souboru 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);
}
Tento příklad ukazuje jednoduché kroky k uložení obrázku.Pro demonstraci této funkce nahráváme stávající soubor z určité polohy disku, provádíme operaci Rotate na obrázku a uložte obrázek ve formátu PSD pomocí File Path
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());
}
Následující příklad ukazuje, jak uložit kompletní BMP obrázek nebo jeho část do souboru nebo toku.
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(Třída, ImageOptionsBase, Rectangle)
Uloží data objektu na specifikovanou polohu souboru ve specifikovaném formátu souboru podle možností uložen.
public virtual void Save(string filePath, ImageOptionsBase options, Rectangle boundsRectangle)
Parameters
filePath
string
Původní cestou souboru.
options
ImageOptionsBase
Tyto možnosti.
boundsRectangle
Rectangle
Období cílového obrazu omezuje rektangle. nastavte prázdný rektangle pro použití zdrojových hranic.
Examples
Následující příklad nahrává obrázek BMP z souboru, pak ukládá rektangulární část obrázku do souboru 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);
}
Následující příklad ukazuje, jak uložit kompletní BMP obrázek nebo jeho část do souboru nebo toku.
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
Možnosti
spora obrazu selhala.
Save(Prohlídka, ImageOptionsBase)
Uloží data snímku do specifikovaného toku ve specifikovaném formátu souboru podle možností uložen.
public void Save(Stream stream, ImageOptionsBase optionsBase)
Parameters
stream
Stream
Průtok zachraňuje data obrázku na.
optionsBase
ImageOptionsBase
Možnosti ušetřen.
Examples
Následující příklad nahrává obrázek z souboru, pak ukládá obrázek do toku souboru 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);
}
}
Tento příklad ukazuje proces Shromažďování obrazu na MemoryStream. Aby se ukázala tato operace, příklad nahrává stávající soubor z určité diskové polohy, provádí operaci Rotate na obrazu a Shromažďuje obraz ve formátu 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());
}
}
Následující příklad ukazuje, jak uložit kompletní BMP obrázek nebo jeho část do souboru nebo toku.
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
MožnostiBase
Není možné uložit do specifikovaného formátu, protože v současné době není podporován; možnostiBase
Vývoz obrazu selhal.
Save(Stream, ImageOptionsBase, Rectangle)
Uloží data snímku do specifikovaného toku ve specifikovaném formátu souboru podle možností uložen.
public virtual void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Parameters
stream
Stream
Průtok zachraňuje data obrázku na.
optionsBase
ImageOptionsBase
Možnosti ušetřen.
boundsRectangle
Rectangle
Obrázek cíle omezuje pravý úhel. Nastavení prázdného pravého úhlu pro použití zdrojových hranic.
Examples
Následující příklad nahrává obrázek z souboru, pak ukládá rektangulární část obrázku do toku souboru 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);
}
}
Následující příklad ukazuje, jak uložit kompletní BMP obrázek nebo jeho část do souboru nebo toku.
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
MožnostiBase
Není možné uložit do specifikovaného formátu, protože v současné době není podporován; možnostiBase
Vývoz obrazu selhal.
SetPalette(IkolorPalette, Boolová)
Vytvořte paletu obrazu.
public abstract void SetPalette(IColorPalette palette, bool updateColors)
Parameters
palette
IColorPalette
Paleta je na nastaven.
updateColors
bool
pokud je nastaven na “skutečné” barvy budou aktualizovány podle nové palety; jinak barevné indexy zůstávají nezměněny.
UpdateContainer(Image)
Aktualizace kontejneru.
protected void UpdateContainer(Image container)
Parameters
container
Image
a kontejneru.