Class RasterImage
Το όνομα: Aspose.Imaging Συγκέντρωση: Aspose.Imaging.dll (25.4.0)
Αντιπροσωπεύει μια εικόνα raster που υποστηρίζει τις λειτουργίες γραφικών raster.
public abstract class RasterImage : Image, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← RasterImage
Derived
Implements
IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IHasXmpData , IHasMetadata
Κληρονομημένα μέλη
Image.CanLoad(string) , Image.CanLoad(string, LoadOptions) , Image.CanLoad(Stream) , Image.CanLoad(Stream, LoadOptions) , Image.Create(ImageOptionsBase, int, int) , Image.Create(Image[]) , Image.Create(MultipageCreateOptions) , Image.Create(string[], bool) , Image.Create(string[]) , Image.Create(Image[], bool) , Image.GetFileFormat(string) , Image.GetFileFormat(Stream) , Image.GetFittingRectangle(Rectangle, int, int) , Image.GetFittingRectangle(Rectangle, int[], int, int) , Image.Load(string, LoadOptions) , Image.Load(string) , Image.Load(Stream, LoadOptions) , Image.Load(Stream) , Image.GetProportionalWidth(int, int, int) , Image.GetProportionalHeight(int, int, int) , Image.RemoveMetadata() , Image.CanSave(ImageOptionsBase) , Image.Resize(int, int) , Image.Resize(int, int, ResizeType) , Image.Resize(int, int, ImageResizeSettings) , Image.GetDefaultOptions(object[]) , Image.GetOriginalOptions() , Image.ResizeWidthProportionally(int) , Image.ResizeHeightProportionally(int) , Image.ResizeWidthProportionally(int, ResizeType) , Image.ResizeHeightProportionally(int, ResizeType) , Image.ResizeWidthProportionally(int, ImageResizeSettings) , Image.ResizeHeightProportionally(int, ImageResizeSettings) , Image.RotateFlip(RotateFlipType) , Image.Rotate(float) , Image.Crop(Rectangle) , Image.Crop(int, int, int, int) , Image.Save() , Image.Save(string) , Image.Save(string, ImageOptionsBase) , Image.Save(string, ImageOptionsBase, Rectangle) , Image.Save(Stream, ImageOptionsBase) , Image.Save(Stream, ImageOptionsBase, Rectangle) , Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , Image.SetPalette(IColorPalette, bool) , Image.UpdateContainer(Image) , Image.GetCanNotSaveMessage(ImageOptionsBase) , Image.GetFitRectangle(Rectangle) , Image.GetImage2Export(ImageOptionsBase, Rectangle, IImageExporter) , Image.GetFitRectangle(Rectangle, int[]) , Image.OnPaletteChanged(IColorPalette, IColorPalette) , Image.OnPaletteChanging(IColorPalette, IColorPalette) , Image.ReleaseManagedResources() , Image.BitsPerPixel , Image.Bounds , Image.Container , Image.Height , Image.Palette , Image.UsePalette , Image.Size , Image.Width , Image.InterruptMonitor , Image.BufferSizeHint , Image.AutoAdjustPalette , Image.HasBackgroundColor , Image.FileFormat , Image.BackgroundColor , 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
Αυτό το παράδειγμα δείχνει πώς να φορτώσετε πληροφορίες Pixel σε μια σειρά τύπου χρώματος, χειριστεί τη σειρά και να την τοποθετήσετε πίσω στην εικόνα. Για να εκτελέσετε αυτές τις εργασίες, αυτό το παράδειγμα δημιουργεί ένα νέο αρχείο εικόνας (σε μορφή GIF) uisng αντικείμενο MemoryStream.
//Create an instance of MemoryStream
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
//Create an instance of GifOptions and set its various properties including the Source property
Aspose.Imaging.ImageOptions.GifOptions gifOptions = new Aspose.Imaging.ImageOptions.GifOptions();
gifOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);
//Create an instance of Image
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(gifOptions, 500, 500))
{
//Get the pixels of image by specifying the area as image boundary
Aspose.Imaging.Color[] pixels = image.LoadPixels(image.Bounds);
//Loop over the Array and sets color of alrenative indexed pixel
for (int index = 0; index < pixels.Length; index++)
{
if (index % 2 == 0)
{
//Set the indexed pixel color to yellow
pixels[index] = Aspose.Imaging.Color.Yellow;
}
else
{
//Set the indexed pixel color to blue
pixels[index] = Aspose.Imaging.Color.Blue;
}
}
//Apply the pixel changes to the image
image.SavePixels(image.Bounds, pixels);
// save all changes.
image.Save();
}
// Write MemoryStream to File
using (System.IO.FileStream fileStream = new System.IO.FileStream(@"C:\temp\output.gif", System.IO.FileMode.Create))
{
stream.WriteTo(fileStream);
}
}
Constructors
RasterImage()
Αρχίζει μια νέα περίπτωση της κατηγορίας Aspose.Imaging.RasterImage.
[JsonConstructor]
protected RasterImage()
RasterImage(ΙΚΟΛΟΡΦΙΑ)
Αρχίζει μια νέα περίπτωση της κατηγορίας Aspose.Imaging.RasterImage.
protected RasterImage(IColorPalette colorPalette)
Parameters
colorPalette
IColorPalette
Το χρώμα της παλέτας.
Fields
xmpΠροσωπικά
Τα μεταδεδομένα του XMP
[JsonProperty]
protected XmpPacketWrapper xmpData
Αξία πεδίου
Properties
DataLoader
Αποκτά ή τοποθετεί το φορτιστή δεδομένων.
[JsonProperty]
protected IRasterImageArgb32PixelLoader DataLoader { get; set; }
Αξία ιδιοκτησίας
HasAlpha
Αποκτά μια τιμή που υποδεικνύει εάν αυτή η περίπτωση έχει alpha.
public virtual bool HasAlpha { get; }
Αξία ιδιοκτησίας
Examples
Το παρακάτω παράδειγμα φορτώνει εικόνες raster και εκτυπώνει πληροφορίες σχετικά με τη μορφή πρώτων δεδομένων και το αλφα κανάλι.
// The image files to load.
string[] fileNames = new string[]
{
@"c:\temp\sample.bmp",
@"c:\temp\alpha.png",
};
foreach (string fileName in fileNames)
{
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
System.Console.WriteLine("ImageFile={0}, FileFormat={1}, HasAlpha={2}", fileName, rasterImage.RawDataFormat, rasterImage.HasAlpha);
}
}
// The output may look like this:
// ImageFile=c:\temp\sample.bmp, FileFormat=Rgb24Bpp, used channels: 8,8,8, HasAlpha=False
// ImageFile=c:\temp\alpha.png, FileFormat=RGBA32Bpp, used channels: 8,8,8,8, HasAlpha=True
Το παρακάτω παράδειγμα δείχνει πώς να εξαγάγετε πληροφορίες σχετικά με τη μορφή πρώτων δεδομένων και το αλφα κανάλι από μια εικόνα BMP.
// Create a 32-bpp BMP image of 100 x 100 px.
using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 32, null))
{
System.Console.WriteLine("FileFormat={0}, RawDataFormat={1}, HasAlpha={2}", bmpImage.FileFormat, bmpImage.RawDataFormat, bmpImage.HasAlpha);
};
// Create a 24-bpp BMP image of 100 x 100 px.
using (Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = new Aspose.Imaging.FileFormats.Bmp.BmpImage(100, 100, 24, null))
{
System.Console.WriteLine("FileFormat={0}, RawDataFormat={1}, HasAlpha={2}", bmpImage.FileFormat, bmpImage.RawDataFormat, bmpImage.HasAlpha);
};
// Generally, BMP doesn't support alpha channel so the output will look like this:
// FileFormat = Bmp, RawDataFormat = Rgb32Bpp, used channels: 8,8,8,8, HasAlpha = False
// FileFormat = Bmp, RawDataFormat = Rgb24Bpp, used channels: 8,8,8, HasAlpha = False
HasTransparentColor
Αποκτά μια τιμή που υποδεικνύει αν η εικόνα έχει διαφανές χρώμα.
public virtual bool HasTransparentColor { get; set; }
Αξία ιδιοκτησίας
HorizontalResolution
Αποκτά ή ρυθμίζει την οριζόντια ανάλυση, σε pixels ανά δισκίο, αυτού του Aspose.Imaging.RasterImage.
public virtual double HorizontalResolution { get; set; }
Αξία ιδιοκτησίας
Examples
Το παρακάτω παράδειγμα δείχνει πώς να ρυθμίσετε την οριζόντια / κάθετη ανάλυση μιας εικόνας ράστερ.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Get horizontal and vertical resolution of the image
double horizontalResolution = rasterImage.HorizontalResolution;
double verticalResolution = rasterImage.VerticalResolution;
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);
if (horizontalResolution != 96.0 || verticalResolution != 96.0)
{
// Use the SetResolution method for updating both resolution values in a single call.
System.Console.WriteLine("Set resolution values to 96 dpi");
rasterImage.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", rasterImage.HorizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", rasterImage.VerticalResolution);
}
// The output may look like this:
// The horizontal resolution, in pixels per inch: 300
// The vertical resolution, in pixels per inch: 300
// Set resolution values to 96 dpi
// The horizontal resolution, in pixels per inch: 96
// The vertical resolution, in pixels per inch: 96
}
Remarks
Σημειώστε προεπιλογή αυτή η τιμή είναι πάντα 96 καθώς διαφορετικές πλατφόρμες δεν μπορούν να επιστρέψουν την ανάλυση οθόνης. Μπορείτε να εξετάσετε τη χρήση της μεθόδου SetResolution για την ενημέρωση και των δύο τιμών ανάλυση σε μία κλήση.
ImageOpacity
Αποκτά την απρόσμενη εικόνα αυτής της εικόνας.
public virtual float ImageOpacity { get; }
Αξία ιδιοκτησίας
IsRawDataAvailable
Παίρνει μια τιμή που υποδεικνύει αν η φόρτωση πρώτων δεδομένων είναι διαθέσιμη.
public bool IsRawDataAvailable { get; }
Αξία ιδιοκτησίας
PremultiplyComponents
Αποκτά ή καθορίζει μια τιμή που υποδεικνύει εάν τα στοιχεία της εικόνας πρέπει να προεπαναλαμβάνονται.
public virtual bool PremultiplyComponents { get; set; }
Αξία ιδιοκτησίας
Examples
Το παρακάτω παράδειγμα δημιουργεί μια νέα εικόνα ράστερ, αποθηκεύει τα καθορισμένα ημι-διαφανή pixels, στη συνέχεια φορτώνει αυτά τα pixels και παίρνει τα τελικά χρώματα στην προκαταρκτική μορφή.
int imageWidth = 3;
int imageHeight = 2;
Aspose.Imaging.Color[] colors = new Aspose.Imaging.Color[]
{
Aspose.Imaging.Color.FromArgb(127, 255, 0, 0),
Aspose.Imaging.Color.FromArgb(127, 0, 255, 0),
Aspose.Imaging.Color.FromArgb(127, 0, 0, 255),
Aspose.Imaging.Color.FromArgb(127, 255, 255, 0),
Aspose.Imaging.Color.FromArgb(127, 255, 0, 255),
Aspose.Imaging.Color.FromArgb(127, 0, 255, 255),
};
Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
createOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
createOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Create(createOptions, imageWidth, imageHeight))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Save pixels for the whole image.
rasterImage.SavePixels(rasterImage.Bounds, colors);
// The pixels are stored in the original image in the non-premultiplied form.
// Need to specify the corresponding option explicitly to obtain premultiplied color components.
// The premultiplied color components are calculated by the formulas:
// red = original_red * alpha / 255;
// green = original_green * alpha / 255;
// blue = original_blue * alpha / 255;
rasterImage.PremultiplyComponents = true;
Aspose.Imaging.Color[] premultipliedColors = rasterImage.LoadPixels(rasterImage.Bounds);
for (int i = 0; i < colors.Length; i++)
{
System.Console.WriteLine("Original color: {0}", colors[i].ToString());
System.Console.WriteLine("Premultiplied color: {0}", premultipliedColors[i].ToString());
}
}
RawCustomColorConverter
Αποκτά ή ρυθμίζει τον προσαρμοσμένο μετατροπέα χρώματος
public IColorConverter RawCustomColorConverter { get; set; }
Αξία ιδιοκτησίας
RawDataFormat
Αποκτά τη μορφή των πρώτων δεδομένων.
public virtual PixelDataFormat RawDataFormat { get; }
Αξία ιδιοκτησίας
Examples
Το παρακάτω παράδειγμα φορτώνει εικόνες raster και εκτυπώνει πληροφορίες σχετικά με τη μορφή πρώτων δεδομένων και το αλφα κανάλι.
// The image files to load.
string[] fileNames = new string[]
{
@"c:\temp\sample.bmp",
@"c:\temp\alpha.png",
};
foreach (string fileName in fileNames)
{
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
System.Console.WriteLine("ImageFile={0}, FileFormat={1}, HasAlpha={2}", fileName, rasterImage.RawDataFormat, rasterImage.HasAlpha);
}
}
// The output may look like this:
// ImageFile=c:\temp\sample.bmp, FileFormat=Rgb24Bpp, used channels: 8,8,8, HasAlpha=False
// ImageFile=c:\temp\alpha.png, FileFormat=RGBA32Bpp, used channels: 8,8,8,8, HasAlpha=True
Αυτό το παράδειγμα δείχνει πώς να φορτώσετε μια εικόνα DJVU από μια ροή αρχείων και να εκτυπώσετε πληροφορίες σχετικά με τις σελίδες.
string dir = "c:\\temp\\";
// Load a DJVU image from a file stream.
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "sample.djvu"))
{
using (Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = new Aspose.Imaging.FileFormats.Djvu.DjvuImage(stream))
{
System.Console.WriteLine("The total number of pages: {0}", djvuImage.Pages.Length);
System.Console.WriteLine("The active page number: {0}", djvuImage.ActivePage.PageNumber);
System.Console.WriteLine("The first page number: {0}", djvuImage.FirstPage.PageNumber);
System.Console.WriteLine("The last page number: {0}", djvuImage.LastPage.PageNumber);
foreach (Aspose.Imaging.FileFormats.Djvu.DjvuPage djvuPage in djvuImage.Pages)
{
System.Console.WriteLine("--------------------------------------------------");
System.Console.WriteLine("Page number: {0}", djvuPage.PageNumber);
System.Console.WriteLine("Page size: {0}", djvuPage.Size);
System.Console.WriteLine("Page raw format: {0}", djvuPage.RawDataFormat);
}
}
}
//The output may look like this:
//The total number of pages: 2
//The active page number: 1
//The first page number: 1
//The last page number: 2
//--------------------------------------------------
//Page number: 1
//Page size: { Width = 2481, Height = 3508}
//Page raw format: RgbIndexed1Bpp, used channels: 1
//--------------------------------------------------
//Page number: 2
//Page size: { Width = 2481, Height = 3508}
//Page raw format: RgbIndexed1Bpp, used channels: 1
RawDataSettings
Λάβετε υπόψη ότι όταν χρησιμοποιείτε αυτές τις ρυθμίσεις, τα δεδομένα φορτώνται χωρίς μετατροπή.
[JsonIgnore]
public RawDataSettings RawDataSettings { get; }
Αξία ιδιοκτησίας
RawFallbackIndex
Αποκτά ή τοποθετεί τον δείκτη πτώσης για να χρησιμοποιηθεί όταν ο δείκτης παλέτας είναι εκτός ορίων
public int RawFallbackIndex { get; set; }
Αξία ιδιοκτησίας
RawIndexedColorConverter
Αποκτά ή ρυθμίζει τον δείκτη μετατροπής χρώματος
public IIndexedColorConverter RawIndexedColorConverter { get; set; }
Αξία ιδιοκτησίας
RawLineSize
Αποκτά το μέγεθος της πρώτης γραμμής σε bytes.
public virtual int RawLineSize { get; }
Αξία ιδιοκτησίας
TransparentColor
Αποκτά την εικόνα με διαφανή χρώμα.
public virtual Color TransparentColor { get; set; }
Αξία ιδιοκτησίας
UpdateXmpData
Αποκτά ή καθορίζει μια τιμή που υποδεικνύει αν πρέπει να ενημερώσετε τα μεταδεδομένα του XMP.
public virtual bool UpdateXmpData { get; set; }
Αξία ιδιοκτησίας
UsePalette
Αποκτά μια τιμή που υποδεικνύει εάν χρησιμοποιείται η παλέτα εικόνας.
public override bool UsePalette { get; }
Αξία ιδιοκτησίας
UseRawData
Αποκτά ή καθορίζει μια τιμή που υποδεικνύει αν πρέπει να χρησιμοποιηθεί η φόρτωση πρώτων δεδομένων όταν η φόρτωση πρώτων δεδομένων είναι διαθέσιμη.
public virtual bool UseRawData { get; set; }
Αξία ιδιοκτησίας
VerticalResolution
Αποκτά ή ρυθμίζει την κάθετη ανάλυση, σε pixels ανά ιντσάκι, αυτού του Aspose.Imaging.RasterImage.
public virtual double VerticalResolution { get; set; }
Αξία ιδιοκτησίας
Examples
Το παρακάτω παράδειγμα δείχνει πώς να ρυθμίσετε την οριζόντια / κάθετη ανάλυση μιας εικόνας ράστερ.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Get horizontal and vertical resolution of the image
double horizontalResolution = rasterImage.HorizontalResolution;
double verticalResolution = rasterImage.VerticalResolution;
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);
if (horizontalResolution != 96.0 || verticalResolution != 96.0)
{
// Use the SetResolution method for updating both resolution values in a single call.
System.Console.WriteLine("Set resolution values to 96 dpi");
rasterImage.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", rasterImage.HorizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", rasterImage.VerticalResolution);
}
// The output may look like this:
// The horizontal resolution, in pixels per inch: 300
// The vertical resolution, in pixels per inch: 300
// Set resolution values to 96 dpi
// The horizontal resolution, in pixels per inch: 96
// The vertical resolution, in pixels per inch: 96
}
Remarks
Σημειώστε προεπιλογή αυτή η τιμή είναι πάντα 96 καθώς διαφορετικές πλατφόρμες δεν μπορούν να επιστρέψουν την ανάλυση οθόνης. Μπορείτε να εξετάσετε τη χρήση της μεθόδου SetResolution για την ενημέρωση και των δύο τιμών ανάλυση σε μία κλήση.
XmpData
Αποκτήστε ή τοποθετήστε τα μεταδεδομένα XMP.
public virtual XmpPacketWrapper XmpData { get; set; }
Αξία ιδιοκτησίας
Methods
AdjustBrightness(ΕΝΤ)
Προσαρμογή φωτεινότητας για την εικόνα.
public virtual void AdjustBrightness(int brightness)
Parameters
brightness
int
Η αξία της φωτεινότητας.
Examples
Το παρακάτω παράδειγμα εκτελεί τη διόρθωση φωτεινότητας μιας εικόνας.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Set the brightness value. The accepted values of brightness are in the range [-255, 255].
rasterImage.AdjustBrightness(50);
rasterImage.Save(dir + "sample.AdjustBrightness.png");
}
AdjustContrast(Πλοία)
Φωτογραφία συγκρούσεις
public virtual void AdjustContrast(float contrast)
Parameters
contrast
float
Αξία σύγκρουσης (σε εύρος [-100· 100])
Examples
Το παρακάτω παράδειγμα εκτελεί διόρθωση αντίθεσης μιας εικόνας.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
rasterImage.AdjustContrast(50);
rasterImage.Save(dir + "sample.AdjustContrast.png");
}
AdjustGamma(Πλοία, Πλοία, Πλοία)
Γκάμα-διόρθωση μιας εικόνας.
public virtual void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
float
Γκάμα για τον συντελεστή κόκκινου καναλιού
gammaGreen
float
Γκάμα για τον συντελεστή πράσινου καναλιού
gammaBlue
float
Γκάμα για τον συντελεστή μπλε κανάλι
Examples
Το παρακάτω παράδειγμα εκτελεί γκάμα-διόρθωση μιας εικόνας που εφαρμόζει διαφορετικούς συντελεστές για τα συστατικά χρωμάτων.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Set individual gamma coefficients for red, green and blue channels.
rasterImage.AdjustGamma(1.5f, 2.5f, 3.5f);
rasterImage.Save(dir + "sample.AdjustGamma.png");
}
AdjustGamma(Πλοία)
Γκάμα-διόρθωση μιας εικόνας.
public virtual void AdjustGamma(float gamma)
Parameters
gamma
float
Gamma για κόκκινα, πράσινα και μπλε κανάλια συντελεστή
Examples
Το παρακάτω παράδειγμα εκτελεί διόρθωση γκάμα μιας εικόνας.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Set gamma coefficient for red, green and blue channels.
rasterImage.AdjustGamma(2.5f);
rasterImage.Save(dir + "sample.AdjustGamma.png");
}
BinarizeBradley(διπλό)
Βιανοποίηση μιας εικόνας χρησιμοποιώντας το αλγόριθμο προσαρμοστικής οριοθέτησης του Bradley χρησιμοποιώντας την ολοκληρωμένη οριοθέτηση εικόνας
public virtual void BinarizeBradley(double brightnessDifference)
Parameters
brightnessDifference
double
Η διαφορά φωτεινότητας μεταξύ του pixel και του μέσου ενός s x s παράθυρο των pixel που επικεντρώνονται γύρω από αυτό το pixel.
BinarizeBradley(ΔΥΟ, ΔΥΟ)
Βιανοποίηση μιας εικόνας χρησιμοποιώντας το αλγόριθμο προσαρμοστικής οριοθέτησης του Bradley χρησιμοποιώντας την ολοκληρωμένη οριοθέτηση εικόνας
public virtual void BinarizeBradley(double brightnessDifference, int windowSize)
Parameters
brightnessDifference
double
Η διαφορά φωτεινότητας μεταξύ του pixel και του μέσου ενός s x s παράθυρο των pixel που επικεντρώνονται γύρω από αυτό το pixel.
windowSize
int
Το μέγεθος του παραθύρου s x s των pixels που επικεντρώνονται γύρω από αυτό το pixel
Examples
Το παρακάτω παράδειγμα δυαδικοποιεί μια εικόνα ράστερ με το προσαρμοστικό αλγόριθμο οριοθέτησης του Bradley με το καθορισμένο μέγεθος παραθύρου.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Binarize the image with a brightness difference of 5. The brightness is a difference between a pixel and the average of an 10 x 10 window of pixels centered around this pixel.
rasterImage.BinarizeBradley(5, 10);
rasterImage.Save(dir + "sample.BinarizeBradley5_10x10.png");
}
BinarizeFixed(Μπίτι)
Βιναριοποίηση μιας εικόνας με προκαθορισμένο όριο
public virtual void BinarizeFixed(byte threshold)
Parameters
threshold
byte
Εάν η αντίστοιχη γκρίζα αξία ενός pixel είναι μεγαλύτερη από το όριο, η αξία του 255 θα ανατεθεί σε αυτό, 0 διαφορετικά.
Examples
Το παρακάτω παράδειγμα δυαδικοποιεί μια εικόνα ράστερ με το προκαθορισμένο όριο. οι δυαδικές εικόνες περιέχουν μόνο 2 χρώματα - μαύρο και λευκό.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Binarize the image with a threshold value of 127.
// If a corresponding gray value of a pixel is greater than 127, a value of 255 will be assigned to it, 0 otherwise.
rasterImage.BinarizeFixed(127);
rasterImage.Save(dir + "sample.BinarizeFixed.png");
}
BinarizeOtsu()
Βιναριοποίηση μιας εικόνας με το όριο Otsu
public virtual void BinarizeOtsu()
Examples
Το παρακάτω παράδειγμα δυαδικοποιεί μια εικόνα ράστερ με το όριο Otsu. οι δυαδικές εικόνες περιέχουν μόνο 2 χρώματα - μαύρο και λευκό.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Binarize the image with Otsu thresholding.
rasterImage.BinarizeOtsu();
rasterImage.Save(dir + "sample.BinarizeOtsu.png");
}
Blend(Σημείο, RasterImage, Rectangle, byte)
Συνδυάστε αυτή την εικόνα με την εικόνα overlay".
public virtual void Blend(Point origin, RasterImage overlay, Rectangle overlayArea, byte overlayAlpha = 255)
Parameters
origin
Point
Η οπτική εικόνα ανακατεύει την προέλευση.
overlay
RasterImage
Η υπερβολική εικόνα.
overlayArea
Rectangle
Η περιοχή του Overlay.
overlayAlpha
byte
Το υπερβολικό άλφα.
Blend(Σημείο, RasterImage, byte)
Συνδυάστε αυτή την εικόνα με την εικόνα overlay".
public void Blend(Point origin, RasterImage overlay, byte overlayAlpha = 255)
Parameters
origin
Point
Η οπτική εικόνα ανακατεύει την προέλευση.
overlay
RasterImage
Η υπερβολική εικόνα.
overlayAlpha
byte
Το υπερβολικό άλφα.
Dither(Η μέθοδος, int)
Εμφανίζεται στην τρέχουσα εικόνα.
public void Dither(DitheringMethod ditheringMethod, int bitsCount)
Parameters
ditheringMethod
DitheringMethod
Η μεθοδολογία της διαιτησίας.
bitsCount
int
Οι τελευταίες μπάτσες μετράνε για διτρισμό.
Examples
Το παρακάτω παράδειγμα φορτώνει μια εικόνα ράστερ και εκτελεί το όριο και το κολύμπι dithering χρησιμοποιώντας διαφορετική βάθος παλέτας.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Perform threshold dithering using 4-bit color palette which contains 16 colors.
// The more bits specified the higher quality and the bigger size of the output image.
// Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
rasterImage.Dither(Aspose.Imaging.DitheringMethod.ThresholdDithering, 4);
rasterImage.Save(dir + "sample.ThresholdDithering4.png");
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Perform floyd dithering using 1-bit color palette which contains only 2 colors - black and white.
// The more bits specified the higher quality and the bigger size of the output image.
// Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
rasterImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1);
rasterImage.Save(dir + "sample.FloydSteinbergDithering1.png");
}
Dither(ΔΙΤΥΡΙΑΣΜΟΔΟΣ, INT, IColorPalette)
Εμφανίζεται στην τρέχουσα εικόνα.
public abstract void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethod
Η μεθοδολογία της διαιτησίας.
bitsCount
int
Οι τελευταίες μπάτσες μετράνε για διτρισμό.
customPalette
IColorPalette
Η συνηθισμένη παλέτα για διτρισμό.
Filter(Πλαίσιο, FilterOptionsBase)
Φιλτράει την καθορισμένη ορθογώνια.
public virtual void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
Rectangle
Η Ορθόδοξη.
options
FilterOptionsBase
Οι επιλογές .
Examples
Το παρακάτω παράδειγμα εφαρμόζει διάφορους τύπους φίλτρων σε μια εικόνα ράστερ.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Apply a median filter with a rectangle size of 5 to the entire image.
rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MedianFilterOptions(5));
rasterImage.Save(dir + "sample.MedianFilter.png");
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Apply a bilateral smoothing filter with a kernel size of 5 to the entire image.
rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.BilateralSmoothingFilterOptions(5));
rasterImage.Save(dir + "sample.BilateralSmoothingFilter.png");
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image.
rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
rasterImage.Save(dir + "sample.GaussianBlurFilter.png");
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image.
rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
rasterImage.Save(dir + "sample.GaussWienerFilter.png");
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Apply a motion wiener filter with a length of 5, a smooth value of 4.0 and an angle of 90.0 degrees to the entire image.
rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MotionWienerFilterOptions(10, 1.0, 90.0));
rasterImage.Save(dir + "sample.MotionWienerFilter.png");
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image.
rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
rasterImage.Save(dir + "sample.SharpenFilter.png");
}
GetArgb32Pixel(ΕΝΤ, ΕΝΤ)
Αποκτά μια εικόνα 32-bit ARGB pixel.
public int GetArgb32Pixel(int x, int y)
Parameters
x
int
Η θέση του pixels x.
y
int
Το pixel και η θέση.
Returns
Το 32-bit ARGB pixel για την καθορισμένη τοποθεσία.
Examples
Το παρακάτω παράδειγμα φορτώνει μια εικόνα ράστερ και λαμβάνει το χρώμα ενός αυθαίρετου pixel που αντιπροσωπεύεται ως 32-bit συνολική αξία.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Get an integer representation of the color of the top-left pixel of the image.
int color = rasterImage.GetArgb32Pixel(0, 0);
// To obtain the values of the individual color components, shift the color value by a corresponding number of bits
int alpha = (color >> 24) & 0xff;
int red = (color >> 16) & 0xff;
int green = (color >> 8) & 0xff;
int blue = (color >> 0) & 0xff;
System.Console.WriteLine("The color of the pixel(0,0) is A={0},R={1},G={2},B={3}", alpha, red, green, blue);
}
Το παρακάτω παράδειγμα δείχνει πώς το caching εικόνας επηρεάζει την απόδοση.Σε γενικές γραμμές, η ανάγνωση των δεδομένων cached εκτελείται γρηγορότερα από ό, τι η ανάγνωση των μη cached δεδομένων.
string dir = "c:\\temp\\";
// Load an image from a PNG file.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
// Cache all pixel data so that no additional data loading will be performed from the underlying data stream
image.CacheData();
System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();
// Reading all pixels is pretty fast.
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
for (int y = 0; y < image.Height; y++)
{
for (int x = 0; x < image.Width; x++)
{
int color = rasterImage.GetArgb32Pixel(x, y);
}
}
stopwatch.Stop();
System.Console.WriteLine("Reading all cached pixels took {0} ms.", stopwatch.ElapsedMilliseconds);
}
// Load an image from a PNG file
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();
// Reading all pixels is not as fast as when caching
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
for (int y = 0; y < image.Height; y++)
{
for (int x = 0; x < image.Width; x++)
{
int color = rasterImage.GetArgb32Pixel(x, y);
}
}
stopwatch.Stop();
System.Console.WriteLine("Reading all pixels without preliminary caching took {0} ms.", stopwatch.ElapsedMilliseconds);
}
// The output may look like this:
// Reading all cached pixels took 1500 ms.
// Reading all pixels without preliminary caching took 150000 ms.
GetDefaultArgb32Pixels(Rectangle)
Αποκτά την προεπιλεγμένη σειρά 32-bit ARGB pixel.
public int[] GetDefaultArgb32Pixels(Rectangle rectangle)
Parameters
rectangle
Rectangle
Η ορθογώνια για να πάρει pixels για.
Returns
int [ ]
Τα προεπιλεγμένα pixels array.
GetDefaultPixels(Ετικέτες ARGB32PixelLoader)
Αποκτά τα προεπιλεγμένα pixels με χρήση μερικής φόρτωσης pixel.
public void GetDefaultPixels(Rectangle rectangle, IPartialArgb32PixelLoader partialPixelLoader)
Parameters
rectangle
Rectangle
Η ορθογώνια για να πάρει pixels για.
partialPixelLoader
IPartialArgb32PixelLoader
Το μερικό φορτιστή pixel.
GetDefaultRawData(Ετικέτες Rectangle, IPartialRawDataLoader, RawDataSettings)
Αποκτά την προεπιλεγμένη σειρά πρώτων δεδομένων χρησιμοποιώντας ένα μερικό φορτιστή pixel.
public void GetDefaultRawData(Rectangle rectangle, IPartialRawDataLoader partialRawDataLoader, RawDataSettings rawDataSettings)
Parameters
rectangle
Rectangle
Η ορθογώνια για να πάρει pixels για.
partialRawDataLoader
IPartialRawDataLoader
Ο μερικός φορτιστής πρώτων δεδομένων.
rawDataSettings
RawDataSettings
Οι ρυθμίσεις των πρώτων δεδομένων.
GetDefaultRawData(Ετικέτες: RawDataSettings)
Αποκτά την προεπιλεγμένη σειρά πρώτων δεδομένων.
public byte[] GetDefaultRawData(Rectangle rectangle, RawDataSettings rawDataSettings)
Parameters
rectangle
Rectangle
Η άκρη για να πάρει τα πρώτα δεδομένα για.
rawDataSettings
RawDataSettings
Οι ρυθμίσεις των πρώτων δεδομένων.
Returns
byte [ ]
Το default raw data array.
GetModifyDate(Μπόλ)
Λαμβάνει την ημερομηνία και την ώρα που η εικόνα του πόρου τροποποιήθηκε τελευταία.
public virtual DateTime GetModifyDate(bool useDefault)
Parameters
useDefault
bool
εάν ορίσετε στο “πραγματικό”, χρησιμοποιήστε τις πληροφορίες από το FileInfo ως προεπιλεγμένη τιμή.
Returns
Η ημερομηνία και η ώρα της εικόνας πόρων τροποποιήθηκε τελευταία.
GetPixel(ΕΝΤ, ΕΝΤ)
Έχουμε ένα pixel εικόνας.
public Color GetPixel(int x, int y)
Parameters
x
int
Η θέση του pixels x.
y
int
Το pixel και η θέση.
Returns
Το χρώμα του pixel για την καθορισμένη τοποθεσία.
Examples
Το παρακάτω παράδειγμα φορτώνει μια εικόνα ράστερ και παίρνει το χρώμα ενός αυθαίρετου pixel.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Get the color of the top-left pixel of the image.
Color color = rasterImage.GetPixel(0, 0);
// Obtain the values of the individual color components
byte alpha = color.A;
byte red = color.R;
int green = color.G;
int blue = color.B;
System.Console.WriteLine("The color of the pixel(0,0) is A={0},R={1},G={2},B={3}", alpha, red, green, blue);
}
GetSkewAngle()
Πάρτε την γωνία του σκάφους.Αυτή η μέθοδος εφαρμόζεται σε σάρωση εγγράφων κειμένου, για να προσδιοριστεί η γωνία σάρωσης κατά τη σάρωση.
public float GetSkewAngle()
Returns
Η γωνία του σκάφους, σε βαθμούς.
Grayscale()
Μετασχηματισμός μιας εικόνας στην γκρίζα εκπροσώπηση της
public virtual void Grayscale()
Examples
Το παρακάτω παράδειγμα μετατρέπει μια πολύχρωμη εικόνα ράστερ στην γκρίζα εκπροσώπηση της. οι εικόνες γκρίζας αποτελούνται αποκλειστικά από σκιές γκρι και φέρουν μόνο πληροφορίες έντασης.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
rasterImage.Grayscale();
rasterImage.Save(dir + "sample.Grayscale.png");
}
LoadArgb32Pixels(Rectangle)
Κατεβάζει 32-bit ARGB pixels.
public int[] LoadArgb32Pixels(Rectangle rectangle)
Parameters
rectangle
Rectangle
Η ορθογώνια για να φορτίσει pixels από.
Returns
int [ ]
Το φορτισμένο 32-bit ARGB pixels array.
Examples
Το παρακάτω παράδειγμα δείχνει πώς να φορτώσετε και να επεξεργαστείτε τα pixels μιας εικόνας raster. Τα pixels αντιπροσωπεύονται ως 32-bit ολοκληρωμένες τιμές. Για παράδειγμα, εξετάστε ένα πρόβλημα με τον υπολογισμό των πλήρως διαφανών pixels μιας εικόνας.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\alpha.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Load pixels for the whole image. Any rectangular part of the image can be specified as a parameter of the Aspose.Imaging.RasterImage.LoadArgb32Pixels method.
int[] pixels = rasterImage.LoadArgb32Pixels(rasterImage.Bounds);
int count = 0;
foreach (int pixel in pixels)
{
int alpha = (pixel >> 24) & 0xff;
if (alpha == 0)
{
count++;
}
}
System.Console.WriteLine("The number of fully transparent pixels is {0}", count);
System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
}
LoadArgb64Pixels(Rectangle)
Κατεβάζει 64-bit ARGB pixels.
public long[] LoadArgb64Pixels(Rectangle rectangle)
Parameters
rectangle
Rectangle
Η ορθογώνια για να φορτίσει pixels από.
Returns
long [ ]
Το φορτισμένο 64-bit ARGB pixels array.
Examples
Το παρακάτω παράδειγμα δείχνει πώς να φορτώσετε και να επεξεργαστείτε τα pixels μιας εικόνας raster. Τα pixels αντιπροσωπεύονται ως 64-bit ολοκληρωμένες τιμές. Για παράδειγμα, εξετάστε ένα πρόβλημα με τον υπολογισμό των πλήρως διαφανών pixels μιας εικόνας.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\16rgba.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Load pixels for the whole image. Any rectangular part of the image can be specified as a parameter of the Aspose.Imaging.RasterImage.LoadArgb64Pixels method.
// Note that the image itself must have 16 bits per sample, because Aspose.Imaging.RasterImage.LoadArgb64Pixels doesn't work with 8 bit per sample.
// In order to work with 8 bits per sample please use the good old Aspose.Imaging.RasterImage.LoadArgb32Pixels method.
long[] pixels = rasterImage.LoadArgb64Pixels(rasterImage.Bounds);
int count = 0;
foreach (int pixel in pixels)
{
// Note that all color components including alpha are represented by 16-bit values, so their allowed values are in the range [0, 63535].
int alpha = (pixel >> 48) & 0xffff;
if (alpha == 0)
{
count++;
}
}
System.Console.WriteLine("The number of fully transparent pixels is {0}", count);
System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
}
LoadCmyk32Pixels(Rectangle)
Κατεβάστε pixels σε μορφή CMYK.
public int[] LoadCmyk32Pixels(Rectangle rectangle)
Parameters
rectangle
Rectangle
Η ορθογώνια για να φορτίσει pixels από.
Returns
int [ ]
Τα φορτωμένα pixels CMYK παρουσιάζονται ως 32-bit inateger τιμές.
LoadCmykPixels(Rectangle)
Κατεβάστε pixels σε μορφή CMYK.Παρακαλούμε χρησιμοποιήστε πιο αποτελεσματικά τη μέθοδο Aspose.Imaging.RasterImage.LoadCmyk32Pixels(Aspose.Imaging.Rectangle).
[Obsolete("Method is obsolete")]
public CmykColor[] LoadCmykPixels(Rectangle rectangle)
Parameters
rectangle
Rectangle
Η ορθογώνια για να φορτίσει pixels από.
Returns
CmykColor [ ]
Το φορτισμένο CMYK pixels array.
LoadPartialArgb32Pixels(Ετικέτες ARGB32PixelLoader)
Κατεβάζει 32-bit ARGB pixels μερικώς με πακέτα.
public void LoadPartialArgb32Pixels(Rectangle rectangle, IPartialArgb32PixelLoader partialPixelLoader)
Parameters
rectangle
Rectangle
Η επιθυμητή άκρη.
partialPixelLoader
IPartialArgb32PixelLoader
Ο 32-bit ARGB pixel φορτιστής.
Examples
Το παρακάτω παράδειγμα δείχνει πώς να φορτώσετε και να επεξεργαστείτε pixels μιας εικόνας raster χρησιμοποιώντας το δικό σας μερική επεξεργαστή. Για παράδειγμα, εξετάστε ένα πρόβλημα με τον υπολογισμό των πλήρως διαφανών pixels μιας εικόνας. Για να μετρήσετε διαφανείς pixels χρησιμοποιώντας τον μηχανισμό μερικής φόρτωσης, εισάγεται μια ξεχωριστή κατηγορία TransparentArgb32PixelCounter που εφαρμόζει Aspose.Imaging.IPartialArgb32PixelLoader.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\alpha.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Create an instance of the Aspose.Imaging.IPartialArgb32PixelLoader and pass it to the Aspose.Imaging.RasterImage.LoadPartialArgb32Pixels
TransparentArgb32PixelCounter counter = new TransparentArgb32PixelCounter();
// Load pixels for the whole image. Any rectangular part of the image can be specified as the first parameter of the Aspose.Imaging.RasterImage.LoadPartialArgb32Pixels method.
rasterImage.LoadPartialArgb32Pixels(rasterImage.Bounds, counter);
System.Console.WriteLine("The number of fully transparent pixels is {0}", counter.Count);
System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
}
// The counter may look like this:
/// <summary>
/// Counts the number of fully transparent pixels with alpha channel value of 0.
/// </summary>
private class TransparentArgb32PixelCounter : IPartialArgb32PixelLoader
{
/// <summary>
/// The number of fully transparent pixels.
/// </summary>
private int count;
/// <summary>
/// Gets the number of fully transparent pixels.
/// </summary>
public int Count
{
get { return this.count; }
}
/// <summary>
/// Processes the loaded pixels. This method is called back every time when a new portion of pixels is loaded.
/// </summary>
/// <param name="pixelsRectangle"/>The pixels rectangle.
/// <param name="pixels"/>The 32-bit ARGB pixels.
/// <param name="start"/>The start pixels point.
/// <param name="end"/>The end pixels point.
public void Process(Aspose.Imaging.Rectangle pixelsRectangle, int[] pixels, Aspose.Imaging.Point start, Aspose.Imaging.Point end)
{
foreach (int pixel in pixels)
{
int alpha = (pixel >> 24) & 0xff;
if (alpha == 0)
{
this.count++;
}
}
}
}
LoadPartialArgb64Pixels(Πλαίσιο, IPartialArgb64PixelLoader)
Κατεβάζει 64-bit ARGB pixels μερικώς με πακέτα.
public void LoadPartialArgb64Pixels(Rectangle rectangle, IPartialArgb64PixelLoader partialPixelLoader)
Parameters
rectangle
Rectangle
Η επιθυμητή άκρη.
partialPixelLoader
IPartialArgb64PixelLoader
Το 64-bit ARGB Pixel Loader.
LoadPartialPixels(Ετικέτες IPartialPixelLoader)
Κατεβάστε μερικά pixels με πακέτα.
public void LoadPartialPixels(Rectangle desiredRectangle, IPartialPixelLoader pixelLoader)
Parameters
desiredRectangle
Rectangle
Η επιθυμητή άκρη.
pixelLoader
IPartialPixelLoader
Το Pixel Loader.
Examples
Το παρακάτω παράδειγμα δείχνει πώς να φορτώσετε και να επεξεργαστείτε τα pixels μιας εικόνας raster χρησιμοποιώντας το δικό σας μερική επεξεργαστή. Για παράδειγμα, εξετάστε ένα πρόβλημα με τον υπολογισμό των πλήρως διαφανών pixels μιας εικόνας. Για να υπολογίσετε διαφανώς χρησιμοποιώντας τον μηχανισμό μερικής φόρτωσης, εισάγεται μια ξεχωριστή κατηγορία TransparentPixelCounter που εφαρμόζει Aspose.Imaging.IPartialPixelLoader.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\alpha.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Create an instance of the Aspose.Imaging.IPartialPixelLoader and pass it to the Aspose.Imaging.RasterImage.LoadPartialPixels
TransparentPixelCounter counter = new TransparentPixelCounter();
// Load pixels for the whole image. Any rectangular part of the image can be specified as the first parameter of the Aspose.Imaging.RasterImage.LoadPartialPixels method.
rasterImage.LoadPartialPixels(rasterImage.Bounds, counter);
System.Console.WriteLine("The number of fully transparent pixels is {0}", counter.Count);
System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
}
// The counter may look like this:
/// <summary>
/// Counts the number of fully transparent pixels with alpha channel value of 0.
/// </summary>
private class TransparentPixelCounter : IPartialPixelLoader
{
/// <summary>
/// The number of fully transparent pixels.
/// </summary>
private int count;
/// <summary>
/// Gets the number of fully transparent pixels.
/// </summary>
public int Count
{
get { return this.count; }
}
/// <summary>
/// Processes the loaded pixels. This method is called back every time when a new portion of pixels is loaded.
/// </summary>
/// <param name="pixelsRectangle"/>The pixels rectangle.
/// <param name="pixels"/>The 32-bit ARGB pixels.
/// <param name="start"/>The start pixels point.
/// <param name="end"/>The end pixels point.
public void Process(Aspose.Imaging.Rectangle pixelsRectangle, Aspose.Imaging.Color[] pixels, Aspose.Imaging.Point start, Aspose.Imaging.Point end)
{
foreach (Color pixel in pixels)
{
if (pixel.A == 0)
{
this.count++;
}
}
}
}
LoadPixels(Rectangle)
Κατεβάστε τα pixels.
public Color[] LoadPixels(Rectangle rectangle)
Parameters
rectangle
Rectangle
Η ορθογώνια για να φορτίσει pixels από.
Returns
Color [ ]
Τα φορτισμένα pixels συλλέγονται.
Examples
Το παρακάτω παράδειγμα δείχνει πώς να φορτώσετε και να επεξεργαστείτε pixels μιας εικόνας raster. Για παράδειγμα, εξετάστε ένα πρόβλημα με τον υπολογισμό των πλήρως διαφανών pixels μιας εικόνας.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\alpha.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Load pixels for the whole image. Any rectangular part of the image can be specified as a parameter of the Aspose.Imaging.RasterImage.LoadPixels method.
Color[] pixels = rasterImage.LoadPixels(rasterImage.Bounds);
int count = 0;
foreach (Color pixel in pixels)
{
if (pixel.A == 0)
{
count++;
}
}
System.Console.WriteLine("The number of fully transparent pixels is {0}", count);
System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
}
Αυτό το παράδειγμα δείχνει πώς να φορτώσετε πληροφορίες Pixel σε μια σειρά τύπου χρώματος, χειριστεί τη σειρά και να την τοποθετήσετε πίσω στην εικόνα. Για να εκτελέσετε αυτές τις εργασίες, αυτό το παράδειγμα δημιουργεί ένα νέο αρχείο εικόνας (σε μορφή GIF) uisng αντικείμενο MemoryStream.
//Create an instance of MemoryStream
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
//Create an instance of GifOptions and set its various properties including the Source property
Aspose.Imaging.ImageOptions.GifOptions gifOptions = new Aspose.Imaging.ImageOptions.GifOptions();
gifOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);
//Create an instance of Image
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(gifOptions, 500, 500))
{
//Get the pixels of image by specifying the area as image boundary
Aspose.Imaging.Color[] pixels = image.LoadPixels(image.Bounds);
//Loop over the Array and sets color of alrenative indexed pixel
for (int index = 0; index < pixels.Length; index++)
{
if (index % 2 == 0)
{
//Set the indexed pixel color to yellow
pixels[index] = Aspose.Imaging.Color.Yellow;
}
else
{
//Set the indexed pixel color to blue
pixels[index] = Aspose.Imaging.Color.Blue;
}
}
//Apply the pixel changes to the image
image.SavePixels(image.Bounds, pixels);
// save all changes.
image.Save();
}
// Write MemoryStream to File
using (System.IO.FileStream fileStream = new System.IO.FileStream(@"C:\temp\output.gif", System.IO.FileMode.Create))
{
stream.WriteTo(fileStream);
}
}
LoadRawData(Ετικέτες: Rectangle, RawDataSettings, IPartialRawDataLoader)
Κατεβάστε τα πρώτα δεδομένα.
public void LoadRawData(Rectangle rectangle, RawDataSettings rawDataSettings, IPartialRawDataLoader rawDataLoader)
Parameters
rectangle
Rectangle
Η άκρη για να φορτώσει τα πρώτα δεδομένα από.
rawDataSettings
RawDataSettings
Οι ρυθμίσεις πρώτων δεδομένων που πρέπει να χρησιμοποιηθούν για φορτωμένα δεδομένα. σημειώστε ότι εάν τα δεδομένα δεν είναι στη μορφή που καθορίζεται τότε η μετατροπή δεδομένων θα πραγματοποιηθεί.
rawDataLoader
IPartialRawDataLoader
Το βασικό φορτιστή δεδομένων.
Examples
Το παρακάτω παράδειγμα δείχνει πώς να εξάγετε pixels από τα δεδομένα πρώτης εικόνας χρησιμοποιώντας RawDataSettings. Για παράδειγμα, εξετάστε ένα πρόβλημα με τον υπολογισμό των πλήρως διαφανών pixels μιας εικόνας.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\GrayscaleWithAlpha.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
Aspose.Imaging.RawDataSettings settings = rasterImage.RawDataSettings;
TransparentPixelRawDataCounter rawDataLoader = new TransparentPixelRawDataCounter(settings);
// Load pixels for the whole image. Any rectangular part of the image can be specified as a parameter of the Aspose.Imaging.RasterImage.LoadRawData method.
rasterImage.LoadRawData(rasterImage.Bounds, settings, rawDataLoader);
System.Console.WriteLine("The number of fully transparent pixels is {0}", rawDataLoader.Count);
System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
}
// In case of raw data, the counter may look like this:
/// <summary>
/// Counts the number of fully transparent pixels with alpha channel value of 0.
/// </summary>
private class TransparentPixelRawDataCounter : IPartialRawDataLoader
{
/// <summary>
/// The number of fully transparent pixels.
/// </summary>
private int count;
/// <summary>
/// The raw data settings of the loaded image.
/// </summary>
private Aspose.Imaging.RawDataSettings rawDataSettings;
/// <summary>
/// Gets the number of fully transparent pixels.
/// </summary>
public int Count
{
get { return this.count; }
}
/// <summary>
/// Initializes a new instance of the <see transparentpixelrawdatacounter=""></see> class.
/// </summary>
/// <param name="settings"/>The raw data settings allow to extract color components from raw data.
public TransparentPixelRawDataCounter(Aspose.Imaging.RawDataSettings settings)
{
this.rawDataSettings = settings;
this.count = 0;
}
/// <summary>
/// Processes the loaded raw data. This method is called back every time when a new portion of raw data is loaded.
/// </summary>
/// <param name="dataRectangle"/>The raw data rectangle.
/// <param name="data"/>The raw data.
/// <param name="start"/>The start data point.
/// <param name="end"/>The end data point.
public void Process(Aspose.Imaging.Rectangle dataRectangle, byte[] data, Aspose.Imaging.Point start, Aspose.Imaging.Point end)
{
int[] channelBits = this.rawDataSettings.PixelDataFormat.ChannelBits;
// Only simple formats are consdired here to simplify the code.
// Let's consider only images with 8 bits per sample.
for (int i = 0; i < channelBits.Length; i++)
{
if (channelBits[i] != 8)
{
throw new System.NotSupportedException();
}
}
switch (this.rawDataSettings.PixelDataFormat.PixelFormat)
{
case PixelFormat.Rgb:
case PixelFormat.Bgr:
{
if (channelBits.Length == 4)
{
// ARGB
for (int i = 0; i < data.Length; i += 4)
{
// The alpha channel is stored last, after the color components.
if (data[i + 3] == 0)
{
this.count++;
}
}
}
}
break;
case PixelFormat.Grayscale:
{
if (channelBits.Length == 2)
{
// Grayscale Alpha
for (int i = 0; i < data.Length; i += 2)
{
// The alpha channel is stored last, after the color components.
if (data[i + 1] == 0)
{
this.count++;
}
}
}
}
break;
default:
throw new System.ArgumentOutOfRangeException("PixelFormat");
}
}
/// <summary>
/// Processes the loaded raw data. This method is called back every time when a new portion of raw data is loaded.
/// </summary>
/// <param name="dataRectangle"/>The raw data rectangle.
/// <param name="data"/>The raw data.
/// <param name="start"/>The start data point.
/// <param name="end"/>The end data point.
/// <param name="loadOptions"/>The load options.
public void Process(Aspose.Imaging.Rectangle dataRectangle, byte[] data, Aspose.Imaging.Point start, Aspose.Imaging.Point end, Aspose.Imaging.LoadOptions loadOptions)
{
this.Process(dataRectangle, data, start, end);
}
}
LoadRawData(Ετικέτες Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader)
Κατεβάστε τα πρώτα δεδομένα.
public void LoadRawData(Rectangle rectangle, Rectangle destImageBounds, RawDataSettings rawDataSettings, IPartialRawDataLoader rawDataLoader)
Parameters
rectangle
Rectangle
Η άκρη για να φορτώσει τα πρώτα δεδομένα από.
destImageBounds
Rectangle
Τα όρια της εικόνας.
rawDataSettings
RawDataSettings
Οι ρυθμίσεις πρώτων δεδομένων που πρέπει να χρησιμοποιηθούν για φορτωμένα δεδομένα. σημειώστε ότι εάν τα δεδομένα δεν είναι στη μορφή που καθορίζεται τότε η μετατροπή δεδομένων θα πραγματοποιηθεί.
rawDataLoader
IPartialRawDataLoader
Το βασικό φορτιστή δεδομένων.
NormalizeAngle()
Ομαλοποιεί την γωνία.Αυτή η μέθοδος εφαρμόζεται σε σάρωση εγγράφων κειμένου για να απαλλαγούμε από την σάρωση.Αυτή η μέθοδος χρησιμοποιεί τις μεθόδους Aspose.Imaging.RasterImage.GetSkewAngle και Aspose.Imaging.RasterImage.Rotate(System.Single).
public void NormalizeAngle()
NormalizeAngle(Χρώμα, Χρώμα)
Ομαλοποιεί την γωνία.Αυτή η μέθοδος εφαρμόζεται σε σάρωση εγγράφων κειμένου για να απαλλαγούμε από την σάρωση.Αυτή η μέθοδος χρησιμοποιεί τις μεθόδους Aspose.Imaging.RasterImage.GetSkewAngle και Aspose.Imaging.RasterImage.Rotate(System.Single,System.Boolean,Aspose.Imaging.Color).
public virtual void NormalizeAngle(bool resizeProportionally, Color backgroundColor)
Parameters
resizeProportionally
bool
εάν ορίσετε στο “πραγματικό” θα έχετε το μέγεθος της εικόνας σας αλλάξει ανάλογα με τα περιστρεφόμενα ορθογώνια (κενά σημεία) προβολές σε άλλη περίπτωση που αφήνει τις διαστάσεις αγγίξει και μόνο το εσωτερικό περιεχόμενο της εικόνας περιστρέφεται.
backgroundColor
Color
Το χρώμα του φόντου.
Examples
Το Skew είναι ένα αντικείμενο που μπορεί να εμφανιστεί κατά τη διάρκεια της διαδικασίας σάρωσης εγγράφων όταν το κείμενο / εικόνες του εγγράφου περιστρέφονται σε μια ελαφρά γωνία. Μπορεί να έχει διάφορες αιτίες, αλλά το πιο συνηθισμένο είναι ότι το χαρτί λαμβάνει λάθος θέση κατά τη διάρκεια μιας σάρωσης. Ως εκ τούτου, το Deskew είναι η διαδικασία ανίχνευσης και διόρθωσης αυτού του προβλήματος στα σάρωση αρχεία (δηλ. bitmap) έτσι τα απελευθερωμένα έγγραφα θα έχουν το κείμενο / εικόνες σωστά και οριζόντια προσαρμοσμένα.
string dir = "c:\\aspose.imaging\\issues\\net\\3567\\";
string inputFilePath = dir + "skewed.png";
string outputFilePath = dir + "skewed.out.png";
// Get rid of the skewed scan with default parameters
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(inputFilePath))
{
// Deskew
image.NormalizeAngle(false /*do not resize*/, Aspose.Imaging.Color.LightGray /*background color*/);
image.Save(outputFilePath);
}
NormalizeHistogram()
Κανονικοποιεί το ιστογράφο εικόνας – προσαρμόζει τις τιμές των pixel για να χρησιμοποιεί όλες τις διαθέσιμες περιόδους.
public virtual void NormalizeHistogram()
ReadArgb32ScanLine(ΕΝΤ)
Διαβάστε ολόκληρη τη γραμμή σάρωσης με τον καθορισμένο δείκτη γραμμής σάρωσης.
public int[] ReadArgb32ScanLine(int scanLineIndex)
Parameters
scanLineIndex
int
Δείκτης με βάση το μηδέν της γραμμής σάρωσης.
Returns
int [ ]
Η γραμμή σάρωσης 32-bit ARGB χρωστικές τιμές σειρά.
ReadScanLine(ΕΝΤ)
Διαβάστε ολόκληρη τη γραμμή σάρωσης με τον καθορισμένο δείκτη γραμμής σάρωσης.
public Color[] ReadScanLine(int scanLineIndex)
Parameters
scanLineIndex
int
Δείκτης με βάση το μηδέν της γραμμής σάρωσης.
Returns
Color [ ]
Η γραμμή σάρωσης pixel χρωστικές τιμές σειρά.
ReleaseManagedResources()
Απελευθερώστε τους διαχειριζόμενους πόρους. Βεβαιωθείτε ότι δεν απελευθερώνονται εδώ μη διαχειριζόμενοι πόροι, καθώς μπορεί να έχουν ήδη απελευθερωθεί.
protected override void ReleaseManagedResources()
RemoveMetadata()
Απομακρύνει αυτά τα μεταδεδομένα παραδείγματος εικόνας ρυθμίζοντας αυτή την τιμή Aspose.Imaging.Xmp.IHasXMPData. μηδέν.
public override void RemoveMetadata()
ReplaceColor(Χρώμα, byte, χρώμα)
Αντικαθιστά το ένα χρώμα στο άλλο με την επιτρεπόμενη διαφορά και διατηρεί την αρχική τιμή alpha για να εξοικονομήσει ομαλές άκρες.
public void ReplaceColor(Color oldColor, byte oldColorDiff, Color newColor)
Parameters
oldColor
Color
Το παλιό χρώμα θα αντικατασταθεί.
oldColorDiff
byte
Επιτρέπεται η διαφορά στο παλιό χρώμα για να είναι σε θέση να επεκτείνει τον αντικατασταμένο τόνο χρώματος.
newColor
Color
Νέο χρώμα για να αντικαταστήσει το παλιό χρώμα.
ReplaceColor(Μύθος, Μύθος, Μύθος)
Αντικαθιστά το ένα χρώμα στο άλλο με την επιτρεπόμενη διαφορά και διατηρεί την αρχική τιμή alpha για να εξοικονομήσει ομαλές άκρες.
public virtual void ReplaceColor(int oldColorArgb, byte oldColorDiff, int newColorArgb)
Parameters
oldColorArgb
int
Το παλιό χρώμα ARGB θα αντικατασταθεί.
oldColorDiff
byte
Επιτρέπεται η διαφορά στο παλιό χρώμα για να είναι σε θέση να επεκτείνει τον αντικατασταμένο τόνο χρώματος.
newColorArgb
int
Νέα τιμή χρώματος ARGB να αντικαταστήσει το παλιό χρώμα με.
ReplaceNonTransparentColors(Color)
Αντικαθιστά όλα τα μη διαφανή χρώματα με νέο χρώμα και διατηρεί την αρχική τιμή alpha για να εξοικονομήσει ομαλές άκρες.Σημείωση: Εάν το χρησιμοποιείτε σε εικόνες χωρίς διαφάνεια, όλα τα χρώματα θα αντικατασταθούν με ένα μόνο.
public void ReplaceNonTransparentColors(Color newColor)
Parameters
newColor
Color
Νέο χρώμα για να αντικαταστήσει μη διαφανή χρώματα με.
ReplaceNonTransparentColors(ΕΝΤ)
Αντικαθιστά όλα τα μη διαφανή χρώματα με νέο χρώμα και διατηρεί την αρχική τιμή alpha για να εξοικονομήσει ομαλές άκρες.Σημείωση: Εάν το χρησιμοποιείτε σε εικόνες χωρίς διαφάνεια, όλα τα χρώματα θα αντικατασταθούν με ένα μόνο.
public virtual void ReplaceNonTransparentColors(int newColorArgb)
Parameters
newColorArgb
int
Νέα τιμή χρώματος ARGB για να αντικαταστήσει μη διαφανή χρώματα με.
Resize(int, int, ImageResizeΕπεξεργασία)
Αναζωογονεί την εικόνα με εκτεταμένες επιλογές.
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
Το νέο πλάτος.
newHeight
int
Το νέο ύψος.
settings
ImageResizeSettings
Η αναδιάρθρωση των ρυθμίσεων.
Examples
Αυτό το παράδειγμα φορτώνει μια εικόνα ράστερ και την αναζωογονεί χρησιμοποιώντας διάφορες ρυθμίσεις αναζωογόνησης.
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");
}
Rotate(Φλωτ, μπολ, χρώμα)
Ρυθμίστε την εικόνα γύρω από το κέντρο.
public virtual void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
float
Η γωνία περιστροφής σε βαθμούς. θετικές τιμές θα περιστρέφονται με το ρολόι.
resizeProportionally
bool
εάν ορίσετε στο “πραγματικό” θα έχετε το μέγεθος της εικόνας σας αλλάξει ανάλογα με τα περιστρεφόμενα ορθογώνια (κενά σημεία) προβολές σε άλλη περίπτωση που αφήνει τις διαστάσεις αγγίξει και μόνο το εσωτερικό περιεχόμενο της εικόνας περιστρέφεται.
backgroundColor
Color
Το χρώμα του φόντου.
Exceptions
Δεν υλοποιήθηκε εξαίρεση
Rotate(Πλοία)
Ρυθμίστε την εικόνα γύρω από το κέντρο.
public override void Rotate(float angle)
Parameters
angle
float
Η γωνία περιστροφής σε βαθμούς. θετικές τιμές θα περιστρέφονται με το ρολόι.
Save(Σύνδεση, ImageOptionsBase, Rectangle)
Αποθηκεύει τα δεδομένα της εικόνας στην καθορισμένη ροή στην καθορισμένη μορφή αρχείου σύμφωνα με τις επιλογές αποθήκευσης.
public override void Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Parameters
stream
Stream
Η ροή για να αποθηκεύσετε τα δεδομένα της εικόνας σε.
optionsBase
ImageOptionsBase
Οι επιλογές αποθήκευσης.
boundsRectangle
Rectangle
Η εικόνα προορισμού περιορίζει την ορθογώνια. Ρυθμίστε την κενή ορθογώνια για τη χρήση των ορίων πηγής.
SaveArgb32Pixels(ΠΕΡΙΣΣΣΟΤΕΡΑ, INT[])
Αποθηκεύει τα 32-bit ARGB pixels.
public void SaveArgb32Pixels(Rectangle rectangle, int[] pixels)
Parameters
rectangle
Rectangle
Η ορθογώνια για να αποθηκεύσετε pixels σε.
pixels
int
[ ]
Τα 32-bit ARGB pixels είναι διαθέσιμα.
Examples
Το παρακάτω παράδειγμα γεμίζει την κεντρική περιοχή μιας εικόνας ράστερ με μαύρα pixels χρησιμοποιώντας τη μέθοδο Aspose.Imaging.RasterImage.SaveArgb32Pixels.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// The black square
int[] pixels = new int[(rasterImage.Width / 2) * (rasterImage.Height / 2)];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Color.Black.ToArgb();
}
// Draw the black square at the center of the image.
Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(rasterImage.Width / 4, rasterImage.Height / 4, rasterImage.Width / 2, rasterImage.Height / 2);
rasterImage.SaveArgb32Pixels(area, pixels);
rasterImage.Save(dir + "sample.SaveArgb32Pixels.png");
}
SaveCmyk32Pixels(ΠΕΡΙΣΣΣΟΤΕΡΑ, INT[])
Σώστε τα pixels.
public void SaveCmyk32Pixels(Rectangle rectangle, int[] pixels)
Parameters
rectangle
Rectangle
Η ορθογώνια για να αποθηκεύσετε pixels σε.
pixels
int
[ ]
Τα pixels CMYK παρουσιάζονται ως οι 32-bit ολοκληρωμένες τιμές.
Examples
Το παρακάτω παράδειγμα γεμίζει την κεντρική περιοχή μιας εικόνας ράστερ με μαύρα pixels χρησιμοποιώντας τη μέθοδο Aspose.Imaging.RasterImage.SaveCmyk32Pixels.
string dir = @"c:\temp\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Get an integer representation of black in the CMYK color space.
int blackCmyk = Aspose.Imaging.CmykColorHelper.ToCmyk(Color.Black);
// The black square.
int[] pixels = new int[(rasterImage.Width / 2) * (rasterImage.Height / 2)];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = blackCmyk;
}
// Draw the black square at the center of the image.
Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(rasterImage.Width / 4, rasterImage.Height / 4, rasterImage.Width / 2, rasterImage.Height / 2);
rasterImage.SaveCmyk32Pixels(area, pixels);
rasterImage.Save(dir + "sample.SaveCmyk32Pixels.png");
}
SaveCmykPixels(Πλαίσιο, CmykColor[])
Σώστε τα pixels.Παρακαλούμε χρησιμοποιήστε πιο αποτελεσματικά τη μέθοδο Aspose.Imaging.RasterImage.SaveCmyk32Pixels(Aspose.Imaging.Rectangle,System.Int32[]).
[Obsolete("Method is obsolete")]
public void SaveCmykPixels(Rectangle rectangle, CmykColor[] pixels)
Parameters
rectangle
Rectangle
Η ορθογώνια για να αποθηκεύσετε pixels σε.
pixels
CmykColor
[ ]
Το CMYK pixels array.
SavePixels(Ορθογώνιο, Χρώμα[])
Σώστε τα pixels.
public void SavePixels(Rectangle rectangle, Color[] pixels)
Parameters
rectangle
Rectangle
Η ορθογώνια για να αποθηκεύσετε pixels σε.
pixels
Color
[ ]
Τα pixels ανοίγουν.
Examples
Το παρακάτω παράδειγμα γεμίζει την κεντρική περιοχή μιας εικόνας ράστερ με μαύρα pixels χρησιμοποιώντας τη μέθοδο Aspose.Imaging.RasterImage.SavePixels.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// The black square
Color[] pixels = new Color[(rasterImage.Width / 2) * (rasterImage.Height / 2)];
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = Color.Black;
}
// Draw the black square at the center of the image.
Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(rasterImage.Width / 4, rasterImage.Height / 4, rasterImage.Width / 2, rasterImage.Height / 2);
rasterImage.SavePixels(area, pixels);
rasterImage.Save(dir + "sample.SavePixels.png");
}
Αυτό το παράδειγμα δείχνει πώς να φορτώσετε πληροφορίες Pixel σε μια σειρά τύπου χρώματος, χειριστεί τη σειρά και να την τοποθετήσετε πίσω στην εικόνα. Για να εκτελέσετε αυτές τις εργασίες, αυτό το παράδειγμα δημιουργεί ένα νέο αρχείο εικόνας (σε μορφή GIF) uisng αντικείμενο MemoryStream.
//Create an instance of MemoryStream
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
//Create an instance of GifOptions and set its various properties including the Source property
Aspose.Imaging.ImageOptions.GifOptions gifOptions = new Aspose.Imaging.ImageOptions.GifOptions();
gifOptions.Source = new Aspose.Imaging.Sources.StreamSource(stream);
//Create an instance of Image
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(gifOptions, 500, 500))
{
//Get the pixels of image by specifying the area as image boundary
Aspose.Imaging.Color[] pixels = image.LoadPixels(image.Bounds);
//Loop over the Array and sets color of alrenative indexed pixel
for (int index = 0; index < pixels.Length; index++)
{
if (index % 2 == 0)
{
//Set the indexed pixel color to yellow
pixels[index] = Aspose.Imaging.Color.Yellow;
}
else
{
//Set the indexed pixel color to blue
pixels[index] = Aspose.Imaging.Color.Blue;
}
}
//Apply the pixel changes to the image
image.SavePixels(image.Bounds, pixels);
// save all changes.
image.Save();
}
// Write MemoryStream to File
using (System.IO.FileStream fileStream = new System.IO.FileStream(@"C:\temp\output.gif", System.IO.FileMode.Create))
{
stream.WriteTo(fileStream);
}
}
SaveRawData(Μπίτι[ ], int, Rectangle, RawDataSettings)
Αποθηκεύει τα πρώτα δεδομένα.
public void SaveRawData(byte[] data, int dataOffset, Rectangle rectangle, RawDataSettings rawDataSettings)
Parameters
data
byte
[ ]
Τα πρώτα δεδομένα.
dataOffset
int
Τα πρώτα δεδομένα αποζημιώνονται.
rectangle
Rectangle
Τα πρώτα δεδομένα είναι κατευθείαν.
rawDataSettings
RawDataSettings
Τα πρώτα δεδομένα ρυθμίζουν τα δεδομένα που βρίσκονται.
SetArgb32Pixel(Ιντ, Ιντ, Ιντ)
Καθορίστε ένα 32-bit ARGB pixel εικόνας για την καθορισμένη θέση.
public void SetArgb32Pixel(int x, int y, int argb32Color)
Parameters
x
int
Η θέση του pixels x.
y
int
Το pixel και η θέση.
argb32Color
int
Το 32-bit ARGB pixel για την καθορισμένη θέση.
Examples
Το παρακάτω παράδειγμα φορτώνει μια εικόνα ράστερ και καθορίζει το χρώμα ενός αυθαίρετου pixel.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Sets the color of the top-left pixel.
rasterImage.SetArgb32Pixel(0, 0, Aspose.Imaging.Color.Aqua.ToArgb());
// Another way is to pass an instance of the Aspose.Imaging.Color directly
rasterImage.SetPixel(0, 0, Aspose.Imaging.Color.Aqua);
}
SetPalette(Πλατφόρμα, Bool)
Δημιουργήστε την παλέτα εικόνας.
public override void SetPalette(IColorPalette palette, bool updateColors)
Parameters
palette
IColorPalette
Η παλέτα να καθοριστεί.
updateColors
bool
εάν ρυθμιστεί σε “πραγματικά” χρώματα θα ενημερωθεί σύμφωνα με τη νέα παλέτα. διαφορετικά, οι δείκτες χρωμάτων παραμένουν αμετάβλητοι. σημειώστε ότι οι αμετάβλητοι δείκτες μπορεί να σπάσει την εικόνα στο φορτίο εάν ορισμένοι δείκτες δεν έχουν αντίστοιχες εισαγωγές παλέτας.
SetPixel(Κύριε, Κύριε, χρώμα)
Καθορίστε ένα pixel εικόνας για την καθορισμένη θέση.
public void SetPixel(int x, int y, Color color)
Parameters
x
int
Η θέση του pixels x.
y
int
Το pixel και η θέση.
color
Color
Το χρώμα του pixel για την καθορισμένη θέση.
Examples
Το παρακάτω παράδειγμα φορτώνει μια εικόνα ράστερ και καθορίζει το χρώμα ενός αυθαίρετου pixel.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Sets the color of the top-left pixel.
rasterImage.SetArgb32Pixel(0, 0, Aspose.Imaging.Color.Aqua.ToArgb());
// Another way is to pass an instance of the Aspose.Imaging.Color directly
rasterImage.SetPixel(0, 0, Aspose.Imaging.Color.Aqua);
}
SetResolution(ΔΥΟ, ΔΥΟ)
Ρυθμίστε την ανάλυση για αυτό το Aspose.Imaging.RasterImage.
public virtual void SetResolution(double dpiX, double dpiY)
Parameters
dpiX
double
Η οριζόντια ανάλυση, σε σημεία ανά ίντσα, του Aspose.Imaging.RasterImage.
dpiY
double
Η κάθετη ανάλυση, σε σημεία ανά ίντσα, του Aspose.Imaging.RasterImage.
Examples
Το παρακάτω παράδειγμα δείχνει πώς να ρυθμίσετε την οριζόντια / κάθετη ανάλυση μιας εικόνας ράστερ.
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.jpg"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Get horizontal and vertical resolution of the image
double horizontalResolution = rasterImage.HorizontalResolution;
double verticalResolution = rasterImage.VerticalResolution;
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", horizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", verticalResolution);
if (horizontalResolution != 96.0 || verticalResolution != 96.0)
{
// Use the SetResolution method for updating both resolution values in a single call.
System.Console.WriteLine("Set resolution values to 96 dpi");
rasterImage.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", rasterImage.HorizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", rasterImage.VerticalResolution);
}
// The output may look like this:
// The horizontal resolution, in pixels per inch: 300
// The vertical resolution, in pixels per inch: 300
// Set resolution values to 96 dpi
// The horizontal resolution, in pixels per inch: 96
// The vertical resolution, in pixels per inch: 96
}
ToBitmap()
Μετατρέψτε την εικόνα του raster σε bitmap.Αυτή η μέθοδος δεν υποστηρίζεται σε εκδόσεις από .Net7.0 και υψηλότερες
public virtual Bitmap ToBitmap()
Returns
Το bitmap
UpdateDimensions(ΕΝΤ, ΕΝΤ)
Αναβαθμίζει τις διαστάσεις της εικόνας.
protected abstract void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
Το νέο πλάτος της εικόνας.
newHeight
int
Το νέο ύψος της εικόνας.
UpdateMetadata()
Αναβαθμίζει τα μεταδεδομένα εικόνας.
protected virtual void UpdateMetadata()
WriteArgb32ScanLine(ΕΝΤ, ΕΝΤ[])
Γράφει ολόκληρη τη γραμμή σάρωσης στον καθορισμένο δείκτη γραμμής σάρωσης.
public void WriteArgb32ScanLine(int scanLineIndex, int[] argb32Pixels)
Parameters
scanLineIndex
int
Δείκτης με βάση το μηδέν της γραμμής σάρωσης.
argb32Pixels
int
[ ]
Τα 32-bit ARGB χρώματα επιλέγουν να γράφουν.
WriteScanLine(Χρώμα, χρώμα[])
Γράφει ολόκληρη τη γραμμή σάρωσης στον καθορισμένο δείκτη γραμμής σάρωσης.
public void WriteScanLine(int scanLineIndex, Color[] pixels)
Parameters
scanLineIndex
int
Δείκτης με βάση το μηδέν της γραμμής σάρωσης.
pixels
Color
[ ]
Τα χρώματα των pixel μπορούν να γράψουν.