Class Image
nazivni prostor: Aspose.Imaging Sastav: Aspose.Imaging.dll (25.4.0)
Slika je osnovna klasa za sve vrste slika.
[JsonObject(MemberSerialization.OptIn)]
public abstract class Image : DataStreamSupporter, IDisposable, IObjectWithBounds
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image
Derived
Implements
IDisposable , IObjectWithBounds
naslijeđeni članovi
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
Odredite je li paleta upotrijebljena slikom.
using (var image = Image.Load(folder + "Sample.bmp"))
{
if (image.UsePalette)
{
Console.WriteLine("The palette is used by the image");
}
}
Reciklirajte sliku pomoću određenog tipa recikliranja.
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");
}
Ovaj primjer stvara novu sliku datoteku na nekoj lokaciji diska, kako je navedeno izvornom vlasništvom primjere BmpOptions. Mnoge su svojstva za primjeru Bmpoptions postavljene prije stvaranja stvarne slike.
//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()
Inicijalizira novu primjenu Aspose.Imaging.Image klase.
[JsonConstructor]
protected Image()
Image(ICOLORPALETE)
Inicijalizira novu primjenu Aspose.Imaging.Image klase.
protected Image(IColorPalette colorPalette)
Parameters
colorPalette
IColorPalette
Boja je paleta.
Properties
AutoAdjustPalette
Dobiva ili postavlja vrijednost koja ukazuje na to da li se automatski prilagođava paleta.
public bool AutoAdjustPalette { get; set; }
Vrijednost nekretnina
BackgroundColor
Dobiva ili postavlja vrijednost za boju pozadine.
public virtual Color BackgroundColor { get; set; }
Vrijednost nekretnina
BitsPerPixel
Dobivaju bitove slike po broju piksela.
public abstract int BitsPerPixel { get; }
Vrijednost nekretnina
Bounds
Pronađite granice slike.
public Rectangle Bounds { get; }
Vrijednost nekretnina
BufferSizeHint
Pronađite ili postavite znak veličine buffera koji je definiran maksimalno dopušteno veličine za sve unutarnje buffere.
public int BufferSizeHint { get; set; }
Vrijednost nekretnina
Container
Pronađite Aspose.Imaging.Image kontejner.
public Image Container { get; }
Vrijednost nekretnina
Remarks
Ako ta imovina nije nula, to ukazuje na sliku koja se nalazi u drugoj slici.
FileFormat
Dobiva vrijednost formata datoteke
public virtual FileFormat FileFormat { get; }
Vrijednost nekretnina
HasBackgroundColor
Dobiva ili postavlja vrijednost koja ukazuje na to ima li sliku boju pozadine.
public virtual bool HasBackgroundColor { get; set; }
Vrijednost nekretnina
Height
Dobivaju visinu slike.
public abstract int Height { get; }
Vrijednost nekretnina
InterruptMonitor
Pronađite ili postavite prekidni monitor.
public InterruptMonitor InterruptMonitor { get; set; }
Vrijednost nekretnina
Palette
Pronađite ili postavite paletu boja. paleta boja se ne koristi kada se pikseli prikazuju izravno.
public IColorPalette Palette { get; set; }
Vrijednost nekretnina
Size
Pronađite veličinu slike.
public Size Size { get; }
Vrijednost nekretnina
Examples
Ovaj primjer pokazuje kako preuzeti DJVU sliku iz protok datoteke i tiskanje informacija o stranicama.
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
Dobiva vrijednost koja ukazuje na to je li paleta slike upotrijebljena.
public virtual bool UsePalette { get; }
Vrijednost nekretnina
Examples
Odredite je li paleta upotrijebljena slikom.
using (var image = Image.Load(folder + "Sample.bmp"))
{
if (image.UsePalette)
{
Console.WriteLine("The palette is used by the image");
}
}
Width
Dobivaju širinu slike.
public abstract int Width { get; }
Vrijednost nekretnina
Methods
CanLoad(String)
Određuje može li se sliku preuzeti s određenog putovanja datoteke.
public static bool CanLoad(string filePath)
Parameters
filePath
string
Podaci o dosjeu.
Returns
‘Pravda’ ako se slika može preuzeti iz određenog datoteke; inače, ’lažno’.
Examples
Ovaj primjer određuje može li se slika preuzeti iz datoteke.
// Use an absolute path to the file
bool canLoad = Aspose.Imaging.Image.CanLoad(@"c:\temp\sample.gif");
CanLoad(String, Opcije za preuzimanje)
Određuje može li se slika preuzeti s određenog puta datoteke i opcionalno koristi određene otvorene opcije.
public static bool CanLoad(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
Podaci o dosjeu.
loadOptions
LoadOptions
Opcije za opterećenje.
Returns
‘Pravda’ ako se slika može preuzeti iz određenog datoteke; inače, ’lažno’.
CanLoad(Stream)
Određuje može li se sliku preuzeti iz određenog toka.
public static bool CanLoad(Stream stream)
Parameters
stream
Stream
Strijelac koji se isporučuje.
Returns
‘Pravda’ ako se slika može preuzeti iz određenog toka; inače, ’lažno’.
Examples
Ovaj primjer određuje može li se slika preuzeti iz tokova datoteke.
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(Slijedeći članakStraam, LoadOptions)
Određuje može li se slika preuzeti iz određenog toka i opcionalno koristi određeni loadOptions'.
public static bool CanLoad(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
Strijelac koji se isporučuje.
loadOptions
LoadOptions
Opcije za opterećenje.
Returns
‘Pravda’ ako se slika može preuzeti iz određenog toka; inače, ’lažno’.
CanSave(ImageOptionsBase)
Određuje može li se slika sačuvati u određenom formatu datoteke predstavljenom prethodnim opcijama sačuvanja.
public bool CanSave(ImageOptionsBase options)
Parameters
options
ImageOptionsBase
Smanjite opcije za korištenje.
Returns
‘Pravda’ ako se slika može sačuvati u određenom formatu datoteke predstavljenom prošlom opcijom sačuvanja; inače, ’lažno’.
Examples
Ovaj primjer pokazuje kako odrediti može li se slika sačuvati u određenom formatu datoteke predstavljenom prošlim opcijama za sačuvanje.
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(Prethodni članakBase, int, int)
Stvorite novu sliku pomoću određenih opcija stvaranja.
public static Image Create(ImageOptionsBase imageOptions, int width, int height)
Parameters
imageOptions
ImageOptionsBase
Opcije za sliku.
width
int
Širina je.
height
int
Veličina je.
Returns
Novo stvorena slika.
Examples
Ovaj primjer stvara novu sliku datoteku na nekoj lokaciji diska, kako je navedeno izvornom vlasništvom primjere BmpOptions. Mnoge su svojstva za primjeru Bmpoptions postavljene prije stvaranja stvarne slike.
//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[])
Stvaranje nove slike pomoću određenih slika kao stranica
public static Image Create(Image[] images)
Parameters
images
Image
[]
Na slikama je.
Returns
Fotografija kao ImultipageImage
Create(MultipageCreateOptions)
Stvaranje određenih više stranica stvara opcije.
public static Image Create(MultipageCreateOptions multipageCreateOptions)
Parameters
multipageCreateOptions
MultipageCreateOptions
Mnogobrojna stranica stvara opcije.
Returns
Mnogobrojna slika
Create(String[], Bolić)
Stvara više stranica slike koje sadrže određene datoteke.
public static Image Create(string[] files, bool throwExceptionOnLoadError)
Parameters
files
string
[]
To su datoteke.
throwExceptionOnLoadError
bool
ako je postavljeno na ‘pravda’ [izuzimanje na pogrešku opterećenja].
Returns
Mnogobrojna slika
Create(String[])
Stvara više stranica slike koje sadrže određene datoteke.
public static Image Create(string[] files)
Parameters
files
string
[]
To su datoteke.
Returns
Mnogobrojna slika
Create(Image[], Bolić)
Stvara novu sliku navedene slike kao stranice.
public static Image Create(Image[] images, bool disposeImages)
Parameters
images
Image
[]
Na slikama je.
disposeImages
bool
Ako je riječ o istinitom,
Returns
Fotografija kao ImultipageImage
Crop(Rectangle)
Korištenje određenog rektangula.
public virtual void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
U pravom dijelu.
Examples
Sljedeći primjer uzgaja raster sliku. područje uzgoja određuje se putem 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)
Fotografija biljke s promjenama.
public virtual void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
int
Ljevica je promijenila.
rightShift
int
To je prava promjena.
topShift
int
Vrhovna promjena
bottomShift
int
Spuštanje dolje.
Examples
Sljedeći primjer uzgaja raster sliku. područje uzgoja određuje se putem lijevih, gornjih, desnih, donjih marža.
string dir = @"c:\temp\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
// Crop again. Set a margin of 10% of the image size.
int horizontalMargin = rasterImage.Width / 10;
int verticalMargin = rasterImage.Height / 10;
image.Crop(horizontalMargin, horizontalMargin, verticalMargin, verticalMargin);
// Save the cropped image to PNG.
image.Save(dir + "sample.Crop.png");
}
~Image()
protected ~Image()
GetCanNotSaveMessage(ImageOptionsBase)
Ne može se sačuvati poruka.
protected virtual string GetCanNotSaveMessage(ImageOptionsBase optionsBase)
Parameters
optionsBase
ImageOptionsBase
Opcije za sliku.
Returns
Ne može sačuvati poruku.
GetDefaultOptions(Objekt[])
Dobivaju se default opcije.
public virtual ImageOptionsBase GetDefaultOptions(object[] args)
Parameters
args
object
[]
i argumentima .
Returns
Podrazumevane opcije
GetFileFormat(String)
Pronađite format datoteke.
public static FileFormat GetFileFormat(string filePath)
Parameters
filePath
string
Podaci o dosjeu.
Returns
određeni format datoteke.
Examples
Ovaj primjer pokazuje kako odrediti format slike bez preuzimanja cijele slike iz datoteke.
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
Format određenog datoteke ne znači da se određena slika može preuzeti. koristite jedan od metoda CanLoad preopterećenja kako biste utvrdili može li se datoteka preuzeti.
GetFileFormat(Stream)
Pronađite format datoteke.
public static FileFormat GetFileFormat(Stream stream)
Parameters
stream
Stream
U toku je.
Returns
određeni format datoteke.
Examples
Ovaj primjer pokazuje kako odrediti format slike bez preuzimanja cijele slike iz tokova datoteke.
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
Format određenog datoteke ne znači da se određena slika može preuzeti. Koristite jedan od metoda CanLoad preopterećenja kako biste utvrdili može li se protok preuzeti.
GetFitRectangle(Rectangle)
Dobiva pravokut koji odgovara sadašnjoj slici.
protected Rectangle GetFitRectangle(Rectangle rectangle)
Parameters
rectangle
Rectangle
Slijedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeće →
Returns
Prikladno pravokretno
GetFitRectangle(Sljedeći Članak Int[])
Dostaje pravokut koji odgovara tekućem bitmapu uzimajući u obzir prošli pikseli. Broj prošlih piksela mora biti jednak veličini pravokut koji odgovara.
protected Rectangle GetFitRectangle(Rectangle rectangle, int[] pixels)
Parameters
rectangle
Rectangle
Slijedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeće →
pixels
int
[]
32-bitni ARGB pikseli rasponu.
Returns
U pravom pravcu.
GetFittingRectangle(Rektangle, int, int)
Dobiva pravokut koji odgovara sadašnjoj slici.
public static Rectangle GetFittingRectangle(Rectangle rectangle, int width, int height)
Parameters
rectangle
Rectangle
Slijedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeće →
width
int
Objekt je široki.
height
int
Visina predmeta je.
Returns
Prilagođeni pravokugli ili iznimka ako se ne može naći pravokugli.
GetFittingRectangle(Sljedeći Članak Int[], int , int)
Dobiva pravokut koji odgovara sadašnjoj slici.
public static Rectangle GetFittingRectangle(Rectangle rectangle, int[] pixels, int width, int height)
Parameters
rectangle
Rectangle
Slijedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeći članakSljedeće →
pixels
int
[]
32-bitni ARGB pikseli
width
int
Objekt je široki.
height
int
Visina predmeta je.
Returns
Prilagođeni pravokugli ili iznimka ako se ne može naći pravokugli.
GetImage2Export(ImageOptionsBase, Rectangle, IImageExporter)
Imajte sliku za izvoz.
[Obsolete("Will be changed by method with other signature")]
protected virtual Image GetImage2Export(ImageOptionsBase optionsBase, Rectangle boundsRectangle, IImageExporter exporter)
Parameters
optionsBase
ImageOptionsBase
Na temelju opcija slike.
boundsRectangle
Rectangle
Vrijeme je rektangularno.
exporter
IImageExporter
To je izvoznik.
Returns
Fotografija za izvoz
GetOriginalOptions()
Dobiva opcije na temelju originalnih postavki datoteke.To može biti korisno za održavanje bit-glob i drugih parametara izvorne slike nepromijenjene.Na primjer, ako preuzmemo crno-bijelu sliku PNG s 1 bitom po pikselu, a zatim je sačuvamo pomoćuAspose.Imaging.DataStreamSupporter.Save(System.String) metoda, izlazna PNG slika s 8 bit po pikselu će se proizvesti.Da biste to izbjegli i sačuvali sliku s 1 bitom po pikselu, koristite ovu metodu kako biste dobili odgovarajuće opcije spašavanja i prošli ih.prema metodi Aspose.Imaging.Image.Save(System.String,_Wl17.ImageOptionsBase) kao drugom parametru.
public virtual ImageOptionsBase GetOriginalOptions()
Returns
Opcije temelje se na originalnim postavkama datoteke.
GetProportionalHeight(int, int, int)
Dobivaju proporcionalnu visinu.
public static int GetProportionalHeight(int width, int height, int newWidth)
Parameters
width
int
Širina je.
height
int
Veličina je.
newWidth
int
U novoj širini.
Returns
i proporcionalne visine.
GetProportionalWidth(int, int, int)
Dobivaju proporcionalnu širinu.
public static int GetProportionalWidth(int width, int height, int newHeight)
Parameters
width
int
Širina je.
height
int
Veličina je.
newHeight
int
U novoj visini.
Returns
Proporcionalna širina
GetSerializedStream(ImageOptionsBase, Rectangle, iznutra int)
Konvertira se u APS.
public virtual Stream GetSerializedStream(ImageOptionsBase imageOptions, Rectangle clippingRectangle, out int pageNumber)
Parameters
imageOptions
ImageOptionsBase
Opcije za sliku.
clippingRectangle
Rectangle
Slijedeći članakKlipping rektangle.
pageNumber
int
Broj stranica je.
Returns
Serializirani tokovi
Load(String, Opcije za preuzimanje)
Ako filePath’ je put datoteke, metoda samo otvori dosje.Ako je URL, metode preuzimaju, pohranjuju kao privremeni i otvaraju ga.
public static Image Load(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
Puta datoteke ili URL za preuzimanje slike iz.
loadOptions
LoadOptions
Opcije za opterećenje.
Returns
Istraživanje opterećenog slika.
Load(String)
Ako filePath’ je put datoteke, metoda samo otvori dosje.Ako je URL, metode preuzimaju, pohranjuju kao privremeni i otvaraju ga.
public static Image Load(string filePath)
Parameters
filePath
string
Puta datoteke ili URL za preuzimanje slike iz.
Returns
Istraživanje opterećenog slika.
Examples
Ovaj primjer pokazuje preuzimanje postojećeg datoteke slike u primjer Aspose.Imaging.Image pomoću određenog dosjenog puta
//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(Slijedeći članakStraam, LoadOptions)
Preuzima novu sliku iz određenog toka.
public static Image Load(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
Proljev za preuzimanje slike iz.
loadOptions
LoadOptions
Opcije za opterećenje.
Returns
Istraživanje opterećenog slika.
Load(Stream)
Preuzima novu sliku iz određenog toka.
public static Image Load(Stream stream)
Parameters
stream
Stream
Proljev za preuzimanje slike iz.
Returns
Istraživanje opterećenog slika.
Examples
Ovaj primjer pokazuje korištenje objekata System.IO.Stream za preuzimanje postojećeg datoteke slike
//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(Sljedeći članakSljedeći članakSljedeći članakIcolorPalette)
Naziva se kada se paleta mijenja.
protected virtual void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
Stara je paleta.
newPalette
IColorPalette
Nova je paleta.
OnPaletteChanging(Sljedeći članakSljedeći članakSljedeći članakIcolorPalette)
Naziva se kada se paleta mijenja.
protected virtual void OnPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
Stara je paleta.
newPalette
IColorPalette
Nova je paleta.
ReleaseManagedResources()
Uklonite upravljane resurse. pobrinite se da se ovdje ne otpuštaju nekontrolirani resursi, budući da su možda već otpušteni.
protected override void ReleaseManagedResources()
RemoveMetadata()
Uklanjanje metapodataka.
public virtual void RemoveMetadata()
Resize(u, u)
Podrazumevano Aspose.Imaging.ResizeType.NearestNeighbourResample koristi se.
public void Resize(int newWidth, int newHeight)
Parameters
newWidth
int
U novoj širini.
newHeight
int
U novoj visini.
Examples
Sljedeći primjer pokazuje kako reciklirati metafil (WMF i 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);
}
}
Sljedeći primjer pokazuje kako reciklirati SVG sliku i sačuvati ga na 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)
Obnavljajte sliku.
public virtual void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
U novoj širini.
newHeight
int
U novoj visini.
resizeType
ResizeType
Vrsta povlačenja.
Examples
Preuzmite EPS sliku i izvozite je u PNG format.
// 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());
}
Reciklirajte sliku pomoću određenog tipa recikliranja.
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");
}
Ovaj primjer preuzima sliku WMF-a i reciklira je pomoću različitih metoda recidiva.
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);
}
Ovaj primjer opterećuje sliku i reciklira je pomoću različitih metoda recidiva.
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");
}
Ovaj primjer opterećuje raster sliku i reciklira ga pomoću različitih metoda recidiva.
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");
}
Ovaj primjer preuzima multi-page ODG sliku i reciklira ga pomoću različitih metoda recidiva.
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());
}
Korištenje segmentne maske za ubrzanje procesa segmentacije
// Masking export options
Aspose.Imaging.ImageOptions.PngOptions exportOptions = new Aspose.Imaging.ImageOptions.PngOptions();
exportOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
exportOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
Aspose.Imaging.Masking.Options.MaskingOptions maskingOptions = new Aspose.Imaging.Masking.Options.MaskingOptions();
// Use GraphCut clustering.
maskingOptions.Method = Masking.Options.SegmentationMethod.GraphCut;
maskingOptions.Decompose = false;
maskingOptions.Args = new Aspose.Imaging.Masking.Options.AutoMaskingArgs();
// The backgroung color will be transparent.
maskingOptions.BackgroundReplacementColor = Aspose.Imaging.Color.Transparent;
maskingOptions.ExportOptions = exportOptions;
string dir = "c:\\temp\\";
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
{
Aspose.Imaging.Size imageSize = image.Size;
// Reducing image size to speed up the segmentation process
image.ResizeHeightProportionally(600, Aspose.Imaging.ResizeType.HighQualityResample);
// Create an instance of the ImageMasking class.
Aspose.Imaging.Masking.ImageMasking masking = new Aspose.Imaging.Masking.ImageMasking(image);
// Divide the source image into several clusters (segments).
using (Aspose.Imaging.Masking.Result.MaskingResult maskingResult = masking.Decompose(maskingOptions))
{
// Getting the foreground mask
using (Aspose.Imaging.RasterImage foregroundMask = maskingResult[1].GetMask())
{
// Increase the size of the mask to the size of the original image
foregroundMask.Resize(imageSize.Width, imageSize.Height, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Applying the mask to the original image to obtain a foreground segment
using (Aspose.Imaging.RasterImage originImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
{
Aspose.Imaging.Masking.ImageMasking.ApplyMask(originImage, foregroundMask, maskingOptions);
originImage.Save(dir + "BigImage_foreground.png", exportOptions);
}
}
}
}
Resize(int, int, ImageResizeUredi)
Obnavljajte sliku.
public abstract void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
U novoj širini.
newHeight
int
U novoj visini.
settings
ImageResizeSettings
Određivanje nastavaka.
Examples
Reciklirajte sliku pomoću određenog tipa recikliranja.
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");
}
Obnovite EPS sliku pomoću naprednih postavki.
// 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());
}
Ovaj primjer preuzima sliku i reciklira je pomoću različitih ponovnih postavki.
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)
Koristi se privremeno Aspose.Imaging.ResizeType.NearestNeighbourResample.
public void ResizeHeightProportionally(int newHeight)
Parameters
newHeight
int
U novoj visini.
ResizeHeightProportionally(Sljedeći Članak ResizeType)
Proporcionalno smanjiti visinu.
public virtual void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
int
U novoj visini.
resizeType
ResizeType
Vrsta povraćanja.
Examples
Ovaj primjer opterećuje sliku i proporcionalno je rezira pomoću različitih metoda reziranja. samo se određuje visina, širina se automatski izračunava.
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");
}
Korištenje segmentne maske za ubrzanje procesa segmentacije
// 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(Sljedeći članakImageResizeSettings)
Proporcionalno smanjiti visinu.
public virtual void ResizeHeightProportionally(int newHeight, ImageResizeSettings settings)
Parameters
newHeight
int
U novoj visini.
settings
ImageResizeSettings
Fotografija prikazuje postavke.
ResizeWidthProportionally(int)
Koristi se privremeno Aspose.Imaging.ResizeType.NearestNeighbourResample.
public void ResizeWidthProportionally(int newWidth)
Parameters
newWidth
int
U novoj širini.
ResizeWidthProportionally(Sljedeći Članak ResizeType)
Proporcionalno smanjiti širinu.
public virtual void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
int
U novoj širini.
resizeType
ResizeType
Vrsta povraćanja.
Examples
Ovaj primjer opterećuje sliku i proporcionalno je rezira pomoću različitih metoda reziranja. samo se određuje širina, visina se automatski izračunava.
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(Sljedeći članakImageResizeSettings)
Proporcionalno smanjiti širinu.
public virtual void ResizeWidthProportionally(int newWidth, ImageResizeSettings settings)
Parameters
newWidth
int
U novoj širini.
settings
ImageResizeSettings
Fotografija prikazuje postavke.
Rotate(float)
Rotacija slike oko središta.
public virtual void Rotate(float angle)
Parameters
angle
float
Okretni kut u stupanjima. pozitivne vrijednosti će se okrenuti na sat.
RotateFlip(RotateFlipType)
Vrti, flips, ili vrti i flips sliku.
public abstract void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipType
Vrsta rotirajućeg flip.
Examples
Primjer preuzima postojeće datoteke slike s nekog mjesta na disku i obavlja operaciju rotacije na slici prema vrijednosti 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();
}
Ovaj primjer opterećuje sliku, vrti je 90 stupnjeva na sat i opcionalno flije slikom horizontalno i (ili) vertikalno.
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");
}
}
Ovaj primjer opterećuje sliku ODG-a, vrti je 90 stupnjeva na sat i opcionalno flije slikom horizontalno i (ili) vertikalno.
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()
Sačuvajte podatke o slikama u temeljnom toku.
public override sealed void Save()
Examples
Sljedeći primjer pokazuje kako sačuvati integriranu BMP sliku ili njezin dio u datoteku ili tok.
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(String)
Shrani sliku na određeno mjesto datoteke.
public override void Save(string filePath)
Parameters
filePath
string
Put datoteke za spašavanje slike na.
Save(Sljedeći članakSljedeći članakImageOptionsBase)
Shrani podatke objekta na određeno mjesto datoteke u određenom formatu datoteke prema opcijama spašavanja.
public virtual void Save(string filePath, ImageOptionsBase options)
Parameters
filePath
string
Podaci o dosjeu.
options
ImageOptionsBase
i opcije .
Examples
Sljedeći primjer preuzima BMP sliku iz datoteke, a zatim spašava sliko u PNG dosje.
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);
}
Ovaj primjer prikazuje jednostavne korake kako biste sačuvali sliku. da biste pokazali ovu funkciju, preuzimamo postojeće datoteke s nekog mjesta na disku, obavljamo operaciju Rotacija na slici i sačuvanje slike u PSD formatu pomoću 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());
}
Sljedeći primjer pokazuje kako sačuvati integriranu BMP sliku ili njezin dio u datoteku ili tok.
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(String, ImageOptionsBase, Rectangle)
Shrani podatke objekta na određeno mjesto datoteke u određenom formatu datoteke prema opcijama spašavanja.
public virtual void Save(string filePath, ImageOptionsBase options, Rectangle boundsRectangle)
Parameters
filePath
string
Podaci o dosjeu.
options
ImageOptionsBase
i opcije .
boundsRectangle
Rectangle
Ciljna slika ograničava pravokut. postavite prazan pravokut za korištenje izvornih granica.
Examples
Sljedeći primjer preuzima BMP sliku iz datoteke, a zatim sačuvaju pravokupni dio slike na PNG dosje.
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);
}
Sljedeći primjer pokazuje kako sačuvati integriranu BMP sliku ili njezin dio u datoteku ili tok.
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
Opcije
Fotografija spašavanja nije uspjela.
Save(Slijedeći članakStraam, ImageOptionsBase)
Shrani podatke slike u određenom toku u određenom formatu datoteke prema opcijama spašavanja.
public void Save(Stream stream, ImageOptionsBase optionsBase)
Parameters
stream
Stream
U toku kako bi se sačuvali podaci slike.
optionsBase
ImageOptionsBase
Opcije za spašavanje.
Examples
Sljedeći primjer preuzima sliku iz datoteke, a zatim sačuvaju sliko u PNG protok.
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);
}
}
Ovaj primjer prikazuje proces spašavanja slike na MemoryStream. da bi se pokazala ova operacija, primjer preuzima postojeće datoteke s nekog mjesta na disku, obavlja operaciju Rotacija na slici i sačuvaj sliku u PSD formatu
//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());
}
}
Sljedeći primjer pokazuje kako sačuvati integriranu BMP sliku ili njezin dio u datoteku ili tok.
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
OpcijeBaza
Ne može se sačuvati u određenom formatu jer trenutno nije podržan.;opcijeBase
Izvoz slike nije uspio.
Save(Proljev, ImageOptionsBase, Rectangle)
Shrani podatke slike u određenom toku u određenom formatu datoteke prema opcijama spašavanja.
public virtual void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Parameters
stream
Stream
U toku kako bi se sačuvali podaci slike.
optionsBase
ImageOptionsBase
Opcije za spašavanje.
boundsRectangle
Rectangle
Ciljna slika ograničava pravokut. postavite prazan pravokut za korištenje izvornih granica.
Examples
Sljedeći primjer preuzima sliku iz datoteke, a zatim sačuvaju pravokupni dio slike u PNG protok.
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);
}
}
Sljedeći primjer pokazuje kako sačuvati integriranu BMP sliku ili njezin dio u datoteku ili tok.
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
OpcijeBaza
Ne može se sačuvati u određenom formatu jer trenutno nije podržan.;opcijeBase
Izvoz slike nije uspio.
SetPalette(Sljedeći Članak IcolorPalette, bool)
Sastavite paletu slike.
public abstract void SetPalette(IColorPalette palette, bool updateColors)
Parameters
palette
IColorPalette
Paleta za postavljanje.
updateColors
bool
ako je postavljena na ‘pravedna’ boja će se ažurirati prema novoj paleti; inače boja indeksi ostaju nepromijenjeni.
UpdateContainer(Image)
ažurirati kontejner.
protected void UpdateContainer(Image container)
Parameters
container
Image
To je kontejner.