Class Image
A név: Aspose.Imaging Összefoglaló: Aspose.Imaging.dll (25.4.0)
A kép az alaposztály minden típusú képek számára.
[JsonObject(MemberSerialization.OptIn)]
public abstract class Image : DataStreamSupporter, IDisposable, IObjectWithBounds
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image
Derived
Implements
IDisposable , IObjectWithBounds
Örökletes tagok
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
Határozza meg, hogy a palettát a kép használja-e.
using (var image = Image.Load(folder + "Sample.bmp"))
{
if (image.UsePalette)
{
Console.WriteLine("The palette is used by the image");
}
}
Ismételje meg a képet egy adott Resize típus használatával.
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");
}
Ez a példa létrehoz egy új kép fájl valamilyen lemez helyén, ahogyan azt a forrás tulajdonsága a BmpOptions példányban. Számos jellemzőt a BMP Options mintában állítanak be, mielőtt a valós képet.
//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()
Kezdődik egy új példány a Aspose.Imaging.Image osztály.
[JsonConstructor]
protected Image()
Image(Színes paletták)
Kezdődik egy új példány a Aspose.Imaging.Image osztály.
protected Image(IColorPalette colorPalette)
Parameters
colorPalette
IColorPalette
A szín palettája.
Properties
AutoAdjustPalette
Megkap egy értéket vagy beállítást, amely azt jelzi, hogy automatikusan módosítja-e a palettát.
public bool AutoAdjustPalette { get; set; }
ingatlan értéke
BackgroundColor
Megkapja vagy értéket állít be a háttérszínre.
public virtual Color BackgroundColor { get; set; }
ingatlan értéke
BitsPerPixel
Megkapja a kép bits per pixel számlálás.
public abstract int BitsPerPixel { get; }
ingatlan értéke
Bounds
Megkapja a kép határait.
public Rectangle Bounds { get; }
ingatlan értéke
BufferSizeHint
Megkapja vagy beállítja a buffer méret utat, amely meghatározza a maximális megengedett méret minden belső buffer számára.
public int BufferSizeHint { get; set; }
ingatlan értéke
Container
Megkapja a Aspose.Imaging.A kép tartályát.
public Image Container { get; }
ingatlan értéke
Remarks
Ha ez a tulajdonság nem nulla, azt jelzi, hogy a kép egy másik képben található.
FileFormat
A fájlformátum értékét kapja
public virtual FileFormat FileFormat { get; }
ingatlan értéke
HasBackgroundColor
Megkapja vagy beállítja azt a értéket, amely azt jelzi, hogy a kép háttér színű-e.
public virtual bool HasBackgroundColor { get; set; }
ingatlan értéke
Height
Megkapja a kép magasságát.
public abstract int Height { get; }
ingatlan értéke
InterruptMonitor
Megkapja vagy beállítja a megszakított monitorot.
public InterruptMonitor InterruptMonitor { get; set; }
ingatlan értéke
Palette
A színpalettát nem használják, amikor a pixeleket közvetlenül képviselik.
public IColorPalette Palette { get; set; }
ingatlan értéke
Size
Megkapja a kép méretét.
public Size Size { get; }
ingatlan értéke
Examples
Ez a példa azt mutatja, hogyan kell feltölteni egy DJVU képet egy fájl áramlásától és nyomtatni az oldalakról szóló információkat.
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
Megkap egy értéket, amely jelzi, hogy a képpalettát használják-e.
public virtual bool UsePalette { get; }
ingatlan értéke
Examples
Határozza meg, hogy a palettát a kép használja-e.
using (var image = Image.Load(folder + "Sample.bmp"))
{
if (image.UsePalette)
{
Console.WriteLine("The palette is used by the image");
}
}
Width
Megkapja a kép szélességét.
public abstract int Width { get; }
ingatlan értéke
Methods
CanLoad(A string)
Határozza meg, hogy a kép feltölthető-e a megadott fájlútból.
public static bool CanLoad(string filePath)
Parameters
filePath
string
A fájl útvonal.
Returns
„valódi”, ha a képet a megadott fájlból lehet feltölteni; máskülönben „valódi”.
Examples
Ez a példa meghatározza, hogy a képet fájlból lehet-e feltölteni.
// Use an absolute path to the file
bool canLoad = Aspose.Imaging.Image.CanLoad(@"c:\temp\sample.gif");
CanLoad(Térkép, LoadOptions)
Határozza meg, hogy a kép feltölthető-e a megadott fájlútból, és opcionálisan a megadott nyitott opciókat használja.
public static bool CanLoad(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
A fájl útvonal.
loadOptions
LoadOptions
A terhelési lehetőségek.
Returns
„valódi”, ha a képet a megadott fájlból lehet feltölteni; máskülönben „valódi”.
CanLoad(Stream)
Meghatározza, hogy a kép feltölthető-e az adott áramból.
public static bool CanLoad(Stream stream)
Parameters
stream
Stream
Az áramlást el kell tölteni.
Returns
„valódi”, ha a képet a megadott áramlatból lehet feltölteni; máskülönben „valódi”.
Examples
Ez a példa meghatározza, hogy a kép letölthető-e egy fájl áramlásától.
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(Áramlat, LoadOptions)
Meghatározza, hogy a kép feltölthető-e az adott áramból, és opcionálisan használja a loadOptions".
public static bool CanLoad(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
Az áramlást el kell tölteni.
loadOptions
LoadOptions
A terhelési lehetőségek.
Returns
„valódi”, ha a képet a megadott áramlatból lehet feltölteni; máskülönben „valódi”.
CanSave(ImageOptionsBase)
Határozza meg, hogy a kép menthető-e a leírt fájlformátumra, amelyet az átadott mentési lehetőségek képviselnek.
public bool CanSave(ImageOptionsBase options)
Parameters
options
ImageOptionsBase
Megtakarítási lehetőségek használata.
Returns
“igaz”, ha a kép menthető a leírt fájlformátumban, amelyet az átadott mentési lehetőségek képviselnek; máskülönben, “hamis”.
Examples
Ez a példa azt mutatja, hogyan lehet meghatározni, hogy a kép menthető-e a leírt fájlformátumra, amelyet az átadott mentési lehetőségek képviselnek.
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(KépekBázis, int, int)
Hozzon létre egy új képet a megadott létrehozási lehetőségek használatával.
public static Image Create(ImageOptionsBase imageOptions, int width, int height)
Parameters
imageOptions
ImageOptionsBase
A kép opciói.
width
int
A szélesség.
height
int
A magasság.
Returns
Az újonnan létrehozott kép.
Examples
Ez a példa létrehoz egy új kép fájl valamilyen lemez helyén, ahogyan azt a forrás tulajdonsága a BmpOptions példányban. Számos jellemzőt a BMP Options mintában állítanak be, mielőtt a valós képet.
//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[])
Új képet hoz létre a megadott képek használatával, mint oldalak
public static Image Create(Image[] images)
Parameters
images
Image
[]
A képekről.
Returns
A kép mint ImultipageImage
Create(MultipageCreateOptions)
Hozza létre a meghatározott többoldal létrehozási lehetőségeket.
public static Image Create(MultipageCreateOptions multipageCreateOptions)
Parameters
multipageCreateOptions
MultipageCreateOptions
A többoldal lehetőségeket hoz létre.
Returns
Többoldalú kép
Create(A string[], és bool)
Hozza létre a többoldalú képet, amely tartalmazza a meghatározott fájlokat.
public static Image Create(string[] files, bool throwExceptionOnLoadError)
Parameters
files
string
[]
A fájlokat.
throwExceptionOnLoadError
bool
Ha az „igaz” [távolítsa el a terhelési hiba kivételét].
Returns
Többoldalú kép
Create(A string[])
Hozza létre a többoldalú képet, amely tartalmazza a meghatározott fájlokat.
public static Image Create(string[] files)
Parameters
files
string
[]
A fájlokat.
Returns
Többoldalú kép
Create(Image[], és bool)
Új képet hoz létre a kijelölt képek oldalaként.
public static Image Create(Image[] images, bool disposeImages)
Parameters
images
Image
[]
A képekről.
disposeImages
bool
Ha az „igaz” [szerkesztés képek].
Returns
A kép mint ImultipageImage
Crop(Rectangle)
A meghatározott rektangulát szorítsa.
public virtual void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
A rektangulát.
Examples
A következő példa növeli a raster képet. A növényterületet a Aspose.Imaging.Rectangle segítségével határozzák meg.
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 és int)
A növényi kép a változásokkal.
public virtual void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
int
A baloldali változás.
rightShift
int
A helyes változás.
topShift
int
A legfelső változás.
bottomShift
int
Az alsó változás.
Examples
A következő példa növeli a raster képet. A növényterület a bal, felső, jobb, alsó marginokon keresztül van meghatározva.
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)
Megkapja, hogy nem tudja menteni az üzenetet.
protected virtual string GetCanNotSaveMessage(ImageOptionsBase optionsBase)
Parameters
optionsBase
ImageOptionsBase
A kép opciói.
Returns
Ez nem mentheti az üzenetet.
GetDefaultOptions(objektum[])
Megkapja az alapértelmezett lehetőségeket.
public virtual ImageOptionsBase GetDefaultOptions(object[] args)
Parameters
args
object
[]
Az érvek.
Returns
Default opciók
GetFileFormat(A string)
Kapja meg a fájlformátumot.
public static FileFormat GetFileFormat(string filePath)
Parameters
filePath
string
A fájl útvonal.
Returns
A meghatározott fájlformátum.
Examples
Ez a példa azt mutatja, hogyan kell meghatározni a kép formátumát anélkül, hogy az egész képet fájlból töltse le.
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
A meghatározott fájlformátum nem jelenti azt, hogy a meghatározott kép feltölthető. Használja az egyik CanLoad módszer feltöltés, hogy meghatározzák, hogy a fájl feltölthető.
GetFileFormat(Stream)
Kapja meg a fájlformátumot.
public static FileFormat GetFileFormat(Stream stream)
Parameters
stream
Stream
Az áramlás.
Returns
A meghatározott fájlformátum.
Examples
Ez a példa azt mutatja, hogyan kell meghatározni a kép formátumát anélkül, hogy az egész képet egy fájl áramlását.
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
A meghatározott fájlformátum nem jelenti azt, hogy a meghatározott kép feltölthető. Használja az egyik CanLoad módszer feltöltését, hogy meghatározzák, hogy az áramlat feltölthető-e.
GetFitRectangle(Rectangle)
Megkap egy rektangul, amely megfelel a jelenlegi képnek.
protected Rectangle GetFitRectangle(Rectangle rectangle)
Parameters
rectangle
Rectangle
A rektangul, hogy megfeleljen a rektangul.
Returns
A megfelelő rektangul
GetFitRectangle(Székesfehérvár, int[])
Megkapja a rectangle, amely illeszkedik a jelenlegi bitmappát figyelembe véve az átadott pixeleket. Az átadott pixelek sorszámának egyenlőnek kell lennie a megfelelő rectangle méretével.
protected Rectangle GetFitRectangle(Rectangle rectangle, int[] pixels)
Parameters
rectangle
Rectangle
A rektangul, hogy megfeleljen a rektangul.
pixels
int
[]
A 32 bites ARGB pixel.
Returns
A megfelelő rektangulát.
GetFittingRectangle(Részletesebben int, int)
Megkap egy rektangul, amely megfelel a jelenlegi képnek.
public static Rectangle GetFittingRectangle(Rectangle rectangle, int width, int height)
Parameters
rectangle
Rectangle
A rektangul, hogy megfeleljen a rektangul.
width
int
Az objektum szélessége.
height
int
Az objektum magassága.
Returns
A megfelelő rektangul vagy kivétel, ha nincs megfelelő rektangul megtalálható.
GetFittingRectangle(Székesfehérvár, int[], Az int, int)
Megkap egy rektangul, amely megfelel a jelenlegi képnek.
public static Rectangle GetFittingRectangle(Rectangle rectangle, int[] pixels, int width, int height)
Parameters
rectangle
Rectangle
A rektangul, hogy megfeleljen a rektangul.
pixels
int
[]
A 32 bites ARGB pixel.
width
int
Az objektum szélessége.
height
int
Az objektum magassága.
Returns
A megfelelő rektangul vagy kivétel, ha nincs megfelelő rektangul megtalálható.
GetImage2Export(ImageOptionsBase, Rectangle, IImageExporter)
A képet exportálni kell.
[Obsolete("Will be changed by method with other signature")]
protected virtual Image GetImage2Export(ImageOptionsBase optionsBase, Rectangle boundsRectangle, IImageExporter exporter)
Parameters
optionsBase
ImageOptionsBase
A kép opciók bázisa.
boundsRectangle
Rectangle
A határok rektangulálnak.
exporter
IImageExporter
Az exportőr.
Returns
A kép exportálása
GetOriginalOptions()
Megkapja a lehetőségeket az eredeti fájl beállítások alapján.Ez segíthet abban, hogy az eredeti kép bit mélysége és egyéb paraméterei változatlanok maradjanak.Például, ha egy fekete-fehér PNG képet 1 bit per pixelrel töltünk fel, majd aAspose.Imaging.DataStreamSupporter.Save(System.String) módszer, a kimeneti PNG kép 8 bit per pixel lesz előállítva.Ahhoz, hogy elkerüljék és mentse a PNG képet 1 bit per pixel, használja ezt a módszert, hogy megkapja a megfelelő mentési lehetőségeket, és adja át őketa Aspose.Imaging.Image.Save(System.String,_Wl17. ImageOptionsBase) módszer a második paraméter.
public virtual ImageOptionsBase GetOriginalOptions()
Returns
Az eredeti fájl beállításokon alapuló lehetőségek.
GetProportionalHeight(Az int, int, int)
arányos magasságot kap.
public static int GetProportionalHeight(int width, int height, int newWidth)
Parameters
width
int
A szélesség.
height
int
A magasság.
newWidth
int
Az új szélesség.
Returns
Az arányos magasság.
GetProportionalWidth(Az int, int, int)
arányos szélességet kap.
public static int GetProportionalWidth(int width, int height, int newHeight)
Parameters
width
int
A szélesség.
height
int
A magasság.
newHeight
int
Az új magasság.
Returns
Az arányos szélesség.
GetSerializedStream(ImageOptionsBase, Rectangle, Out int)
Átalakítás az APS.
public virtual Stream GetSerializedStream(ImageOptionsBase imageOptions, Rectangle clippingRectangle, out int pageNumber)
Parameters
imageOptions
ImageOptionsBase
A kép opciói.
clippingRectangle
Rectangle
A csúszás rektangulája.
pageNumber
int
Az oldal száma.
Returns
A serializált áramlás
Load(Térkép, LoadOptions)
Ha a filePath" egy fájlút, akkor a módszer csak megnyitja a Fájlt.Ha az
file Path egy URL-t, az módszert letöltjük, tároljuk ideiglenesként, és kinyitjuk.
public static Image Load(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
A fájl útvonal vagy URL, hogy töltse le a képet.
loadOptions
LoadOptions
A terhelési lehetőségek.
Returns
A feltöltött kép.
Load(A string)
Ha a filePath" egy fájlút, akkor a módszer csak megnyitja a Fájlt.Ha az
file Path egy URL-t, az módszert letöltjük, tároljuk ideiglenesként, és kinyitjuk.
public static Image Load(string filePath)
Parameters
filePath
string
A fájl útvonal vagy URL, hogy töltse le a képet.
Returns
A feltöltött kép.
Examples
Ez a példa azt mutatja, hogy egy meglévő képfájlt egy Aspose.Imaging.A kép példájába töltötték le a megadott fájlút segítségével.
//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(Áramlat, LoadOptions)
Új képet tölt be a meghatározott áramlatból.
public static Image Load(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
Az áram a kép feltöltése.
loadOptions
LoadOptions
A terhelési lehetőségek.
Returns
A feltöltött kép.
Load(Stream)
Új képet tölt be a meghatározott áramlatból.
public static Image Load(Stream stream)
Parameters
stream
Stream
Az áram a kép feltöltése.
Returns
A feltöltött kép.
Examples
Ez a példa azt mutatja, hogy a System.IO.Stream objektumok használata a meglévő képfájl feltöltéséhez
//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(Az IColorPalette, az IColorPalette)
Amikor a palettát megváltoztatják.
protected virtual void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
A régi paletta.
newPalette
IColorPalette
Az új paletta.
OnPaletteChanging(Az IColorPalette, az IColorPalette)
Amikor a paletta megváltozik.
protected virtual void OnPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)
Parameters
oldPalette
IColorPalette
A régi paletta.
newPalette
IColorPalette
Az új paletta.
ReleaseManagedResources()
Győződjön meg róla, hogy a kezelt erőforrások nem kerülnek kiadásra itt, mivel lehet, hogy már kiadásra kerültek.
protected override void ReleaseManagedResources()
RemoveMetadata()
A metadata eltávolítása.
public virtual void RemoveMetadata()
Resize(Az int, int)
Az alapértelmezett Aspose.Imaging.ResizeType.NearestNeighbourResample használatos.
public void Resize(int newWidth, int newHeight)
Parameters
newWidth
int
Az új szélesség.
newHeight
int
Az új magasság.
Examples
Az alábbi példa azt mutatja, hogyan kell átalakítani a metafilét (WMF és 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);
}
}
Az alábbi példa azt mutatja, hogyan kell átalakítani a SVG képet és menteni PNG-re.
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(Az int, int, resizeType)
visszaállítja a képet.
public virtual void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
Az új szélesség.
newHeight
int
Az új magasság.
resizeType
ResizeType
A visszavágó típus.
Examples
Az EPS kép újraindítása és exportálása PNG formátumban.
// 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());
}
Ismételje meg a képet egy adott Resize típus használatával.
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");
}
Ez a példa feltölti a WMF képet, és különböző reszizációs módszerekkel újrahasznosítja.
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);
}
Ez a példa feltölti a képet, és különböző reszizációs módszerekkel újrahasznosítja.
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");
}
Ez a példa feltölti a raster képet, és különböző reszizációs módszerekkel újrahasznosítja.
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");
}
Ez a példa többoldalú ODG képet tölt be, és különböző reszizációs módszerekkel újrahasznosítja.
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());
}
Segmentes maszk használata a segmentációs folyamat felgyorsításához
// Masking export options
Aspose.Imaging.ImageOptions.PngOptions exportOptions = new Aspose.Imaging.ImageOptions.PngOptions();
exportOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
exportOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
Aspose.Imaging.Masking.Options.MaskingOptions maskingOptions = new Aspose.Imaging.Masking.Options.MaskingOptions();
// Use GraphCut clustering.
maskingOptions.Method = Masking.Options.SegmentationMethod.GraphCut;
maskingOptions.Decompose = false;
maskingOptions.Args = new Aspose.Imaging.Masking.Options.AutoMaskingArgs();
// The backgroung color will be transparent.
maskingOptions.BackgroundReplacementColor = Aspose.Imaging.Color.Transparent;
maskingOptions.ExportOptions = exportOptions;
string dir = "c:\\temp\\";
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
{
Aspose.Imaging.Size imageSize = image.Size;
// Reducing image size to speed up the segmentation process
image.ResizeHeightProportionally(600, Aspose.Imaging.ResizeType.HighQualityResample);
// Create an instance of the ImageMasking class.
Aspose.Imaging.Masking.ImageMasking masking = new Aspose.Imaging.Masking.ImageMasking(image);
// Divide the source image into several clusters (segments).
using (Aspose.Imaging.Masking.Result.MaskingResult maskingResult = masking.Decompose(maskingOptions))
{
// Getting the foreground mask
using (Aspose.Imaging.RasterImage foregroundMask = maskingResult[1].GetMask())
{
// Increase the size of the mask to the size of the original image
foregroundMask.Resize(imageSize.Width, imageSize.Height, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Applying the mask to the original image to obtain a foreground segment
using (Aspose.Imaging.RasterImage originImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "BigImage.jpg"))
{
Aspose.Imaging.Masking.ImageMasking.ApplyMask(originImage, foregroundMask, maskingOptions);
originImage.Save(dir + "BigImage_foreground.png", exportOptions);
}
}
}
}
Resize(int, int, ImageResizeSettings)
visszaállítja a képet.
public abstract void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
Az új szélesség.
newHeight
int
Az új magasság.
settings
ImageResizeSettings
A helyreállítási beállítások.
Examples
Ismételje meg a képet egy adott Resize típus használatával.
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");
}
Az EPS kép visszanyerése a fejlett beállításokkal.
// 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());
}
Ez a példa feltölti a képet, és különböző újratelepítési beállításokkal újrahasznosítja.
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)
Az alapértelmezett Aspose.Imaging.ResizeType.NearestNeighbourResample használatos.
public void ResizeHeightProportionally(int newHeight)
Parameters
newHeight
int
Az új magasság.
ResizeHeightProportionally(Részletesebben ResizeType)
Arányosan csökkenti a magasságot.
public virtual void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
int
Az új magasság.
resizeType
ResizeType
A visszahúzódás típusa.
Examples
Ez a példa terhel egy képet, és arányosan átirányítja a különböző resizing módszerek használatával. Csak a magasságot határozzák meg, a szélességet automatikusan számítják ki.
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");
}
Segmentes maszk használata a segmentációs folyamat felgyorsításához
// 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(Képek, képekSettings)
Arányosan csökkenti a magasságot.
public virtual void ResizeHeightProportionally(int newHeight, ImageResizeSettings settings)
Parameters
newHeight
int
Az új magasság.
settings
ImageResizeSettings
A kép újra beállítja a beállításokat.
ResizeWidthProportionally(int)
Az alapértelmezett Aspose.Imaging.ResizeType.NearestNeighbourResample használatos.
public void ResizeWidthProportionally(int newWidth)
Parameters
newWidth
int
Az új szélesség.
ResizeWidthProportionally(Részletesebben ResizeType)
Arányosan csökkenti a szélességet.
public virtual void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
int
Az új szélesség.
resizeType
ResizeType
A visszahúzódás típusa.
Examples
Ez a példa áramlik egy képet, és arányosan átirányítja a különböző átalakítási módszerek használatával. Csak a szélességet jelölik meg, a magasságot automatikusan kiszámítják.
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(Képek, képekSettings)
Arányosan csökkenti a szélességet.
public virtual void ResizeWidthProportionally(int newWidth, ImageResizeSettings settings)
Parameters
newWidth
int
Az új szélesség.
settings
ImageResizeSettings
A kép újra beállítja a beállításokat.
Rotate(Flotta)
Kerülje a képet a központ körül.
public virtual void Rotate(float angle)
Parameters
angle
float
A fordulati szög fokban. pozitív értékek fordulnak órásan.
RotateFlip(RotateFlipType)
Flips, flips vagy flips a képet.
public abstract void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipType
A rotatott flip típusa.
Examples
A példa a meglévő képfájlt valamilyen lemezhelyről tölti fel, és a képen az Enum Aspose.Imaging.RotateFlipType értékének megfelelően végzi a Rotate műveletet.
//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();
}
Ez a példa feltölti a képet, 90 fokos órásan forgatja, és opcionálisan horizontáltan és/vagy függőlegesen csúszik.
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");
}
}
Ez a példa egy ODG képet tölti fel, 90 fokos órásan forgatja, és opcionálisan vízszintes és (vagy) függőleges módon csúszik.
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()
A képadatok mentése az alatti áramláshoz.
public override sealed void Save()
Examples
Az alábbi példa azt mutatja, hogyan lehet menteni egy teljes BMP képet vagy annak egy részét egy fájlra vagy áramlásra.
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(A string)
Mentse a képet a megadott fájl helyére.
public override void Save(string filePath)
Parameters
filePath
string
A fájl útvonal menteni a képet.
Save(Térkép, ImageOptionsBase)
Megtakarítja az objektum adatait a megadott fájl helyére a megadott fájlformátumban a megtakarítási lehetőségek szerint.
public virtual void Save(string filePath, ImageOptionsBase options)
Parameters
filePath
string
A fájl útvonal.
options
ImageOptionsBase
Az opciók.
Examples
A következő példa feltölti a BMP képet a fájlból, majd mentse meg a képt egy PNG-fájlt.
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);
}
Ez a példa megmutatja a kép mentésének egyszerű lépéseit.Ez a művelet demonstrálása érdekében a meglévő fájlt valamilyen lemezhelyről töltjük fel, a képen forgatjuk a munkát, és a PSD formátumban mentjük meg a fényképet a File Path használatával.
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());
}
Az alábbi példa azt mutatja, hogyan lehet menteni egy teljes BMP képet vagy annak egy részét egy fájlra vagy áramlásra.
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(szalag, ImageOptionsBase, Rectangle)
Megtakarítja az objektum adatait a megadott fájl helyére a megadott fájlformátumban a megtakarítási lehetőségek szerint.
public virtual void Save(string filePath, ImageOptionsBase options, Rectangle boundsRectangle)
Parameters
filePath
string
A fájl útvonal.
options
ImageOptionsBase
Az opciók.
boundsRectangle
Rectangle
A célkép korlátozza a rektangulát. Állítsa be az üres rektangulát a forrás határainak használatához.
Examples
A következő példa feltölti a BMP képet a fájlból, majd ment egy rektanguláris részét a kép egy PNG-fájlt.
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);
}
Az alábbi példa azt mutatja, hogyan lehet menteni egy teljes BMP képet vagy annak egy részét egy fájlra vagy áramlásra.
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
Opciók
A képmegtakarítás nem sikerült.
Save(Áramlat, ImageOptionsBase)
Megtakarítja a kép adatait a megadott áramlásra a megadott fájlformátumban a megtakarítási lehetőségek szerint.
public void Save(Stream stream, ImageOptionsBase optionsBase)
Parameters
stream
Stream
Az áram, hogy mentse a kép adatait.
optionsBase
ImageOptionsBase
A megtakarítási lehetőségek.
Examples
A következő példa feltölti a képet a fájlból, majd mentse meg a fényképet egy PNG-fájlok áramlására.
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);
}
}
Ez a példa megmutatja a MemoryStream kép mentésének folyamatát.Ez a művelet demonstrálása érdekében a példában egy meglévő fájlt töltenek be bizonyos lemezhelyről, a képen a Rotate-műveletet hajtják végre, és a kép PSD formátumban menthető meg.
//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());
}
}
Az alábbi példa azt mutatja, hogyan lehet menteni egy teljes BMP képet vagy annak egy részét egy fájlra vagy áramlásra.
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
Opciók
Nem menthető a megadott formátumra, mivel jelenleg nem támogatott; opciókBázis
A képek exportja sikertelen.
Save(Áramlat, ImageOptionsBase, Rectangle)
Megtakarítja a kép adatait a megadott áramlásra a megadott fájlformátumban a megtakarítási lehetőségek szerint.
public virtual void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Parameters
stream
Stream
Az áram, hogy mentse a kép adatait.
optionsBase
ImageOptionsBase
A megtakarítási lehetőségek.
boundsRectangle
Rectangle
A célkép korlátozza a jobboldalt. Állítsa be az üres jobboldalt a forrás határainak használatához.
Examples
A következő példa feltölti a képet egy fájlból, majd ment egy rektanguláris részét a képernyő egy PNG file stream.
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);
}
}
Az alábbi példa azt mutatja, hogyan lehet menteni egy teljes BMP képet vagy annak egy részét egy fájlra vagy áramlásra.
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
Opciók
Nem menthető a megadott formátumra, mivel jelenleg nem támogatott; opciókBázis
A képek exportja sikertelen.
SetPalette(Székesfehérvár, Bool)
Állítsa be a kép palettáját.
public abstract void SetPalette(IColorPalette palette, bool updateColors)
Parameters
palette
IColorPalette
A palettát be kell állítani.
updateColors
bool
ha a “valódi” színekre van beállítva, az új palettával összhangban frissül; különben a színindexek változatlanok maradnak.
UpdateContainer(Image)
A kontejner frissítése.
protected void UpdateContainer(Image container)
Parameters
container
Image
és a kontejner.