Class TiffImage
名称: Aspose.Imaging.FileFormats.Tiff 收藏: Aspose.Imaging.dll (25.4.0)
处理标签图像文件格式(TIFF)与我们的API,提供全面支持各种解决方案和先进编辑能力如EXIF数据操纵和阿尔法频道. 正常化扫描图像的角度,重定向,转换为灰色,并应用过滤器,伽马纠正和图像参数调整方便 无缝处理多框 TIFF 文件,创建图形路径,添加格式,并轻松地将图像存储到不同的格式。
[JsonObject(MemberSerialization.OptIn)]
public class TiffImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IMultipageImageExt, IMultipageImage, IHasExifData, IHasXmpData, IHasMetadata
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← RasterImage ← RasterCachedImage ← RasterCachedMultipageImage ← TiffImage
Derived
Implements
IDisposable , IObjectWithBounds , IRasterImageArgb32PixelLoader , IRasterImageRawDataLoader , IMultipageImageExt , IMultipageImage , IHasExifData , IHasXmpData , IHasMetadata
继承人
RasterCachedMultipageImage.AdjustBrightness(int) , RasterCachedMultipageImage.AdjustContrast(float) , RasterCachedMultipageImage.AdjustGamma(float, float, float) , RasterCachedMultipageImage.AdjustGamma(float) , RasterCachedMultipageImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedMultipageImage.BinarizeFixed(byte) , RasterCachedMultipageImage.BinarizeBradley(double, int) , RasterCachedMultipageImage.BinarizeBradley(double) , RasterCachedMultipageImage.BinarizeOtsu() , RasterCachedMultipageImage.Crop(Rectangle) , RasterCachedMultipageImage.Crop(int, int, int, int) , RasterCachedMultipageImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedMultipageImage.Grayscale() , RasterCachedMultipageImage.NormalizeHistogram() , RasterCachedMultipageImage.Rotate(float, bool, Color) , RasterCachedMultipageImage.RotateFlip(RotateFlipType) , RasterCachedMultipageImage.RotateFlipAll(RotateFlipType) , RasterCachedMultipageImage.Resize(int, int, ResizeType) , RasterCachedMultipageImage.Resize(int, int, ImageResizeSettings) , RasterCachedMultipageImage.ResizeWidthProportionally(int, ResizeType) , RasterCachedMultipageImage.ResizeHeightProportionally(int, ResizeType) , RasterCachedMultipageImage.ReplaceColor(int, byte, int) , RasterCachedMultipageImage.ReplaceNonTransparentColors(int) , RasterCachedMultipageImage.Filter(Rectangle, FilterOptionsBase) , RasterCachedMultipageImage.NormalizeAngle(bool, Color) , RasterCachedMultipageImage.CacheData() , RasterCachedMultipageImage.ReleaseManagedResources() , RasterCachedMultipageImage.ResizeMain(int, int, ResizeType) , RasterCachedMultipageImage.RotateFlipMain(RotateFlipType) , RasterCachedMultipageImage.CropMain(int, int, int, int) , RasterCachedMultipageImage.SavePixelsInternalMain(Rectangle, int[]) , RasterCachedMultipageImage.CanDoAdjustments() , RasterCachedMultipageImage.GetPagesAsEnumerable() , RasterCachedMultipageImage.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , RasterCachedMultipageImage.Height , RasterCachedMultipageImage.Width , RasterCachedMultipageImage.BitsPerPixel , RasterCachedMultipageImage.IsCached , RasterCachedMultipageImage.PageCount , RasterCachedMultipageImage.Pages , RasterCachedMultipageImage.HasAlpha , RasterCachedMultipageImage.HasTransparentColor , RasterCachedMultipageImage.ImageOpacity , RasterCachedMultipageImage.BackgroundColor , RasterCachedMultipageImage.XmpData , RasterCachedMultipageImage.PageExportingAction , RasterCachedImage.CacheData() , RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte) , RasterCachedImage.Resize(int, int, ResizeType) , RasterCachedImage.Resize(int, int, ImageResizeSettings) , RasterCachedImage.RotateFlip(RotateFlipType) , RasterCachedImage.Rotate(float, bool, Color) , RasterCachedImage.Crop(Rectangle) , RasterCachedImage.Dither(DitheringMethod, int, IColorPalette) , RasterCachedImage.Grayscale() , RasterCachedImage.NormalizeHistogram() , RasterCachedImage.BinarizeFixed(byte) , RasterCachedImage.BinarizeOtsu() , RasterCachedImage.BinarizeBradley(double, int) , RasterCachedImage.BinarizeBradley(double) , RasterCachedImage.AdjustBrightness(int) , RasterCachedImage.AdjustContrast(float) , RasterCachedImage.AdjustGamma(float, float, float) , RasterCachedImage.AdjustGamma(float) , RasterCachedImage.OnCached() , RasterCachedImage.OnPaletteChanged(IColorPalette, IColorPalette) , RasterCachedImage.IsCached , RasterImage.xmpData , RasterImage.RemoveMetadata() , RasterImage.Save(Stream, ImageOptionsBase, Rectangle) , RasterImage.GetModifyDate(bool) , RasterImage.Dither(DitheringMethod, int) , RasterImage.Dither(DitheringMethod, int, IColorPalette) , RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) , RasterImage.GetDefaultArgb32Pixels(Rectangle) , RasterImage.GetDefaultRawData(Rectangle, RawDataSettings) , RasterImage.GetArgb32Pixel(int, int) , RasterImage.GetPixel(int, int) , RasterImage.SetArgb32Pixel(int, int, int) , RasterImage.SetPixel(int, int, Color) , RasterImage.ReadScanLine(int) , RasterImage.ReadArgb32ScanLine(int) , RasterImage.WriteScanLine(int, Color[]) , RasterImage.WriteArgb32ScanLine(int, int[]) , RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) , RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader) , RasterImage.LoadArgb32Pixels(Rectangle) , RasterImage.LoadArgb64Pixels(Rectangle) , RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader) , RasterImage.LoadPixels(Rectangle) , RasterImage.LoadCmykPixels(Rectangle) , RasterImage.LoadCmyk32Pixels(Rectangle) , RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) , RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings) , RasterImage.SaveArgb32Pixels(Rectangle, int[]) , RasterImage.SavePixels(Rectangle, Color[]) , RasterImage.SaveCmykPixels(Rectangle, CmykColor[]) , RasterImage.SaveCmyk32Pixels(Rectangle, int[]) , RasterImage.SetResolution(double, double) , RasterImage.SetPalette(IColorPalette, bool) , RasterImage.Resize(int, int, ImageResizeSettings) , RasterImage.Rotate(float, bool, Color) , RasterImage.Rotate(float) , RasterImage.BinarizeFixed(byte) , RasterImage.BinarizeOtsu() , RasterImage.BinarizeBradley(double) , RasterImage.BinarizeBradley(double, int) , RasterImage.Blend(Point, RasterImage, Rectangle, byte) , RasterImage.Blend(Point, RasterImage, byte) , RasterImage.Grayscale() , RasterImage.NormalizeHistogram() , RasterImage.AdjustBrightness(int) , RasterImage.AdjustContrast(float) , RasterImage.AdjustGamma(float, float, float) , RasterImage.AdjustGamma(float) , RasterImage.GetSkewAngle() , RasterImage.NormalizeAngle() , RasterImage.NormalizeAngle(bool, Color) , RasterImage.Filter(Rectangle, FilterOptionsBase) , RasterImage.ReplaceColor(Color, byte, Color) , RasterImage.ReplaceColor(int, byte, int) , RasterImage.ReplaceNonTransparentColors(Color) , RasterImage.ReplaceNonTransparentColors(int) , RasterImage.ToBitmap() , RasterImage.ReleaseManagedResources() , RasterImage.UpdateMetadata() , RasterImage.UpdateDimensions(int, int) , RasterImage.PremultiplyComponents , RasterImage.UseRawData , RasterImage.UpdateXmpData , RasterImage.XmpData , RasterImage.RawIndexedColorConverter , RasterImage.RawCustomColorConverter , RasterImage.RawFallbackIndex , RasterImage.RawDataSettings , RasterImage.UsePalette , RasterImage.RawDataFormat , RasterImage.RawLineSize , RasterImage.IsRawDataAvailable , RasterImage.HorizontalResolution , RasterImage.VerticalResolution , RasterImage.HasTransparentColor , RasterImage.HasAlpha , RasterImage.TransparentColor , RasterImage.ImageOpacity , RasterImage.DataLoader , 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
在 TIFF 图像中创建图形路径从路径资源。
using (var image = (TiffImage)Image.Load("Bottle.tif"))
{
// Create the GraphicsPath using PathResources from TIFF image
var graphicsPath = PathResourceConverter.ToGraphicsPath(image.ActiveFrame.PathResources.ToArray(), image.ActiveFrame.Size);
var graphics = new Graphics(image);
// Draw red line and save the image
graphics.DrawPath(new Pen(Color.Red, 10), graphicsPath);
image.Save("BottleWithRedBorder.tif");
}
使用图形路径创建路径资源。
static void Main(string[] args)
{
using (var image = (TiffImage)Image.Load("Bottle.tif"))
{
// Create rectangular Figure for GraphicsPath
var figure = new Figure();
figure.AddShape(CreateBezierShape(100f, 100f, 500f, 100f, 500f, 1000f, 100f, 1000f));
// Create GraphicsPath using our Figure
var graphicsPath = new GraphicsPath();
graphicsPath.AddFigure(figure);
// Set PathResources using GraphicsPath
var pathResouze = PathResourceConverter.FromGraphicsPath(graphicsPath, image.Size);
image.ActiveFrame.PathResources = new List<pathresource>(pathResouze);
// Save the image
image.Save("BottleWithRectanglePath.tif");
}
}
private static BezierShape CreateBezierShape(params float[] coordinates)
{
var bezierPoints = CoordinatesToBezierPoints(coordinates).ToArray();
return new BezierShape(bezierPoints, true);
}
private static IEnumerable<pointf> CoordinatesToBezierPoints(float[] coordinates)
{
for (var coordinateIndex = 0; coordinateIndex < coordinates.Length; coordinateIndex += 2)
for (var index = 0; index < 3; index++)
yield return new PointF(coordinates[coordinateIndex], coordinates[coordinateIndex + 1]);
}</pointf></pathresource>
Constructors
TiffImage(TiffFrame)
启动 Aspose.Imaging.FileFormats.Tiff.TiffImage 类的新对象,指定框参数. 此构建器方便创建一个 TiffImage例如,允许开发人员指定要加载或处理的框架,简化 Tiff 图像处理任务在其应用程序中。
public TiffImage(TiffFrame frame)
Parameters
frame
TiffFrame
模具框,以启动图像。
Examples
此示例显示如何从扫描中创建 TIFF 图像并将其保存到文件中。
string dir = "c:\\temp\\";
Aspose.Imaging.ImageOptions.TiffOptions createOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Set 8 bits for each color component.
createOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
// Set the Big Endian byte order (Motorola)
createOptions.ByteOrder = Aspose.Imaging.FileFormats.Tiff.Enums.TiffByteOrder.BigEndian;
// Set the LZW compression.
createOptions.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.Lzw;
// Set the RGB color model.
createOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
// All color components will be stored within a single plane.
createOptions.PlanarConfiguration = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPlanarConfigs.Contiguous;
// Create a TIFF Frame of 100x100 px.
// Note that you don't have to dispose a frame explicitly if it is included into TiffImage.
// When the container is disposed all frames will be disposed automatically.
Aspose.Imaging.FileFormats.Tiff.TiffFrame firstFrame = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(createOptions, 100, 100);
// Fill the entire frame with the blue-yellow gradient.
Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
new Aspose.Imaging.Point(0, 0),
new Aspose.Imaging.Point(firstFrame.Width, firstFrame.Height),
Aspose.Imaging.Color.Blue,
Aspose.Imaging.Color.Yellow);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(firstFrame);
graphics.FillRectangle(gradientBrush, firstFrame.Bounds);
// Create a TIFF image.
using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = new Aspose.Imaging.FileFormats.Tiff.TiffImage(firstFrame))
{
tiffImage.Save(dir + "output.tif");
}
Exceptions
Tiff frame’ 不能是空的。
TiffImage(TiffFrame[])
创建 Aspose.Imaging.FileFormats.Tiff.TiffImage 类的新例子,提供列表框架作为参数. 此构建器允许启动 TiffImage具有多个框架的对象,方便有效处理和处理TIFF 图像序列在软件应用中。
public TiffImage(TiffFrame[] frames)
Parameters
frames
TiffFrame
( )
是框架。
Examples
此示例显示如何创建 2 个框架的 TIFF 图像,并将其保存到文件中。
string dir = "c:\\temp\\";
// Options for the first frame
Aspose.Imaging.ImageOptions.TiffOptions createOptions1 = new Aspose.Imaging.ImageOptions.TiffOptions(Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Set 8 bits for each color component.
createOptions1.BitsPerSample = new ushort[] { 8, 8, 8 };
// Set the Big Endian byte order (Motorola)
createOptions1.ByteOrder = Aspose.Imaging.FileFormats.Tiff.Enums.TiffByteOrder.BigEndian;
// Set the LZW compression.
createOptions1.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.Lzw;
// Set the RGB color model.
createOptions1.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
// All color components will be stored within a single plane.
createOptions1.PlanarConfiguration = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPlanarConfigs.Contiguous;
// Create the first TIFF frame of 100x100 px.
// Note that you don't have to dispose frames explicitly if they are included into TiffImage.
// When the container is disposed all frames will be disposed automatically.
Aspose.Imaging.FileFormats.Tiff.TiffFrame frame1 = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(createOptions1, 100, 100);
// Fill the first frame with the blue-yellow gradient.
Aspose.Imaging.Brushes.LinearGradientBrush gradientBrush = new Aspose.Imaging.Brushes.LinearGradientBrush(
new Aspose.Imaging.Point(0, 0),
new Aspose.Imaging.Point(frame1.Width, frame1.Height),
Aspose.Imaging.Color.Blue,
Aspose.Imaging.Color.Yellow);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(frame1);
graphics.FillRectangle(gradientBrush, frame1.Bounds);
// Options for the first frame
Aspose.Imaging.ImageOptions.TiffOptions createOptions2 = new Aspose.Imaging.ImageOptions.TiffOptions(Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Set 1 bit per pixel for a B/W image.
createOptions2.BitsPerSample = new ushort[] { 1 };
// Set the Little Endian byte order (Intel)
createOptions2.ByteOrder = Aspose.Imaging.FileFormats.Tiff.Enums.TiffByteOrder.LittleEndian;
// Set the CCITT Group 3 Fax compression.
createOptions2.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.CcittFax3;
// Set the B/W color model where 0 is black, 1 is white.
createOptions2.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.MinIsBlack;
// Create the second TIFF frame of 200x200px.
Aspose.Imaging.FileFormats.Tiff.TiffFrame frame2 = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(createOptions2, 200, 200);
// Fill the second frame with the blue-yellow gradient.
// It will be automatically converted to the B/W format due to the corresponding settings of the frame.
Aspose.Imaging.Graphics graphics2 = new Aspose.Imaging.Graphics(frame2);
graphics2.FillRectangle(gradientBrush, frame2.Bounds);
// Create a TIFF image.
using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = new Aspose.Imaging.FileFormats.Tiff.TiffImage(
new Aspose.Imaging.FileFormats.Tiff.TiffFrame[] { frame1, frame2 }))
{
tiffImage.Save(dir + "output.mutliframe.tif");
}
Exceptions
框架
Properties
ActiveFrame
无缝管理活跃框架,促进动态导航和在指定的背景下进行操纵. 允许您的应用程序互动有效地使用多媒体内容,提高用户参与和生产力。
public TiffFrame ActiveFrame { get; set; }
财产价值
Examples
下面的例子表明如何从个别的拉斯特图像中组成一个混合式TIFF。
Aspose.Imaging.ImageOptions.TiffOptions createTiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
createTiffOptions.Source = new Aspose.Imaging.Sources.FileCreateSource("c:\\temp\\multipage.tif", false);
createTiffOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
createTiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Create(createTiffOptions, 100, 100))
{
// This is Font and Brush for drawing text on individual frames.
Aspose.Imaging.Font font = new Aspose.Imaging.Font("Arial", 64);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White);
// Create 5 frames
for (int i = 1; i <= 5; i++)
{
Aspose.Imaging.ImageOptions.PngOptions createPngOptions = new Aspose.Imaging.ImageOptions.PngOptions();
createPngOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
// Create a PNG image and draw the number of page on it.
Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)Image.Create(createPngOptions, 100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(pngImage);
gr.DrawString(i.ToString(), font, brush, 10, 10);
// Create a frame based on the PNG image.
Aspose.Imaging.FileFormats.Tiff.TiffFrame frame = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(pngImage);
// Add the frame to the TIFF image.
tiffImage.AddFrame(frame);
}
// The image was created with a single default frame. Let's remove it.
Aspose.Imaging.FileFormats.Tiff.TiffFrame activeFrame = tiffImage.ActiveFrame;
tiffImage.ActiveFrame = tiffImage.Frames[1];
tiffImage.RemoveFrame(0);
// Don't forget to dispose the frame if you won't add it to some other TiffImage
activeFrame.Dispose();
tiffImage.Save();
}
ByteOrder
将 TIFF 文件的 byte 命令无缝结合起来,确保准确的控制数据解释:让您的应用程序有灵活性适应多种文件规格,提高数据处理的兼容性和效率。
public TiffByteOrder ByteOrder { get; set; }
财产价值
ExifData
无缝访问或修改与活跃框架相关的 EXIF 数据,授权对图像的准确控制 增强应用程序的能力 通过整合此功能,确保准确的保存和定制必需的图像信息
public ExifData ExifData { get; set; }
财产价值
FileFormat
恢复与图像相关的文件格式值. 此属性为图像集成数据的关键方面,允许软件应用程序有效地识别和解释图像数据的格式。
public override FileFormat FileFormat { get; }
财产价值
Frames
恢复一系列的 Aspose.Imaging.FileFormats.Tiff.TiffFrame 例子,允许全面的在 TIFF 图像中访问和操纵个人框架。该序列的功率,以简化图像处理工作流,确保准确性控制和优化视觉内容。
public TiffFrame[] Frames { get; }
财产价值
TiffFrame ( )
Examples
下面的例子表明如何从个别的拉斯特图像中组成一个混合式TIFF。
Aspose.Imaging.ImageOptions.TiffOptions createTiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
createTiffOptions.Source = new Aspose.Imaging.Sources.FileCreateSource("c:\\temp\\multipage.tif", false);
createTiffOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
createTiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Create(createTiffOptions, 100, 100))
{
// This is Font and Brush for drawing text on individual frames.
Aspose.Imaging.Font font = new Aspose.Imaging.Font("Arial", 64);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White);
// Create 5 frames
for (int i = 1; i <= 5; i++)
{
Aspose.Imaging.ImageOptions.PngOptions createPngOptions = new Aspose.Imaging.ImageOptions.PngOptions();
createPngOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
// Create a PNG image and draw the number of page on it.
Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)Image.Create(createPngOptions, 100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(pngImage);
gr.DrawString(i.ToString(), font, brush, 10, 10);
// Create a frame based on the PNG image.
Aspose.Imaging.FileFormats.Tiff.TiffFrame frame = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(pngImage);
// Add the frame to the TIFF image.
tiffImage.AddFrame(frame);
}
// The image was created with a single default frame. Let's remove it.
Aspose.Imaging.FileFormats.Tiff.TiffFrame activeFrame = tiffImage.ActiveFrame;
tiffImage.ActiveFrame = tiffImage.Frames[1];
tiffImage.RemoveFrame(0);
// Don't forget to dispose the frame if you won't add it to some other TiffImage
activeFrame.Dispose();
tiffImage.Save();
}
HasAlpha
确定图像是否有阿尔法频道,提供关键信息用于 rendering 和 compositing 操作. 集成此功能以优化视觉处理工作流,确保准确的代表和操纵透明元素。
public override bool HasAlpha { get; }
财产价值
Examples
下面的示例上传了TIFF图像,并打印了关于原始数据格式和阿尔法频道的信息。
string dir = "c:\\temp\\";
string fileName = dir + "sample.tif";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// If the active TIFF frame has alpha channel, then the entire TIFF image is considered to have alpha channel.
System.Console.WriteLine("ImageFile={0}, FileFormat={1}, HasAlpha={2}", fileName, tiffImage.RawDataFormat, tiffImage.HasAlpha);
int i = 0;
foreach (Aspose.Imaging.FileFormats.Tiff.TiffFrame frame in tiffImage.Frames)
{
System.Console.WriteLine("Frame={0}, FileFormat={1}, HasAlpha={2}", ++i, frame.RawDataFormat, frame.HasAlpha);
}
}
// The output may look like this:
// ImageFile=c:\temp\sample.tif, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
// Frame=1, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
// Frame=2, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
HorizontalResolution
恢复指定的 Aspose.Imaging.Image 的水平分辨率在像素中每英寸,方便精确调整和实现能力。不可或缺的图像代数据无力,赋予灵活的图像处理工作流向增强用户体验。
public override double HorizontalResolution { get; set; }
财产价值
Examples
下面的示例显示如何设置 TIFF 图像的水平/垂直分辨率。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Get horizontal and vertical resolution of the TiffImage.
double horizontalResolution = tiffImage.HorizontalResolution;
double verticalResolution = tiffImage.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");
tiffImage.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", tiffImage.HorizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", tiffImage.VerticalResolution);
}
}
Remarks
默认情况下,这个值总是 96 因为不同的平台无法返回屏幕分辨率. 您可以考虑使用 SetResolution 方法在单个通话中更新两个分辨率值。
PageCount
恢复所指定的文件中的页面总数,方便有效的导航和管理多页内容。功能性,以提高用户体验,允许无缝访问全面的文件结构。
public override int PageCount { get; }
财产价值
Pages
无缝访问文档的页面,允许动态导航和内容结构中的操纵 强化应用程序的有效性访问单个页面,促进简化文档处理和增强用户互动。
public override Image[] Pages { get; }
财产价值
Image ( )
PremultiplyComponents
指示是否需要组件提前复制,确保有效处理视觉元素. 通过将此属性推翻,改进 rendering 过程,简化图形工作流,以优化性能。
public override bool PremultiplyComponents { get; set; }
财产价值
Examples
下面的例子创建了一个新的TIFF图像,保存了指定的半透明像素,然后加载了这些像素,并在预复制的形式中获得最终颜色。
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.TiffOptions createOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffDeflateRgba);
createOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), true);
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Create(createOptions, imageWidth, imageHeight))
{
// Save pixels for the whole image.
image.SavePixels(image.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;
image.PremultiplyComponents = true;
Aspose.Imaging.Color[] premultipliedColors = image.LoadPixels(image.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());
}
}
//The output will look like this:
//Original color: Color [A=127, R=255, G=0, B=0]
//Premultiplied color: Color [A=127, R=127, G=0, B=0]
//Original color: Color [A=127, R=0, G=255, B=0]
//Premultiplied color: Color [A=127, R=0, G=127, B=0]
//Original color: Color [A=127, R=0, G=0, B=255]
//Premultiplied color: Color [A=127, R=0, G=0, B=127]
//Original color: Color [A=127, R=255, G=255, B=0]
//Premultiplied color: Color [A=127, R=127, G=127, B=0]
//Original color: Color [A=127, R=255, G=0, B=255]
//Premultiplied color: Color [A=127, R=127, G=0, B=127]
//Original color: Color [A=127, R=0, G=255, B=255]
//Premultiplied color: Color [A=127, R=0, G=127, B=127]
VerticalResolution
可访问指定的 Aspose.Imaging.Image 的垂直分辨率,以像素为分。英寸,允许准确的调整和实现优化。图像数据无力地简化图像处理工作流,确保在您的应用中,优质和性能。
public override double VerticalResolution { get; set; }
财产价值
Examples
下面的示例显示如何设置 TIFF 图像的水平/垂直分辨率。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Get horizontal and vertical resolution of the TiffImage.
double horizontalResolution = tiffImage.HorizontalResolution;
double verticalResolution = tiffImage.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");
tiffImage.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", tiffImage.HorizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", tiffImage.VerticalResolution);
}
}
Remarks
默认情况下,这个值总是 96 因为不同的平台无法返回屏幕分辨率. 您可以考虑使用 SetResolution 方法在单个通话中更新两个分辨率值。
Methods
Add(TiffImage)
将指定的图像中的框架无缝添加到当前框架中,巩固其内容,提高组成灵活性。这个方法,以简化框架管理和操纵在您的内部应用,促进多框图像的有效处理。
public void Add(TiffImage image)
Parameters
image
TiffImage
源图像。
AddFrame(TiffFrame)
将指定的框架无缝插入图像,扩展其内容使用这种方法来改善图像组成和管理,能够在您的应用程序中有效处理多框图像。
public void AddFrame(TiffFrame frame)
Parameters
frame
TiffFrame
添加的框架。
Examples
下面的例子表明如何从个别的拉斯特图像中组成一个混合式TIFF。
Aspose.Imaging.ImageOptions.TiffOptions createTiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
createTiffOptions.Source = new Aspose.Imaging.Sources.FileCreateSource("c:\\temp\\multipage.tif", false);
createTiffOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
createTiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Create(createTiffOptions, 100, 100))
{
// This is Font and Brush for drawing text on individual frames.
Aspose.Imaging.Font font = new Aspose.Imaging.Font("Arial", 64);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White);
// Create 5 frames
for (int i = 1; i <= 5; i++)
{
Aspose.Imaging.ImageOptions.PngOptions createPngOptions = new Aspose.Imaging.ImageOptions.PngOptions();
createPngOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
// Create a PNG image and draw the number of page on it.
Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)Image.Create(createPngOptions, 100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(pngImage);
gr.DrawString(i.ToString(), font, brush, 10, 10);
// Create a frame based on the PNG image.
Aspose.Imaging.FileFormats.Tiff.TiffFrame frame = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(pngImage);
// Add the frame to the TIFF image.
tiffImage.AddFrame(frame);
}
// The image was created with a single default frame. Let's remove it.
Aspose.Imaging.FileFormats.Tiff.TiffFrame activeFrame = tiffImage.ActiveFrame;
tiffImage.ActiveFrame = tiffImage.Frames[1];
tiffImage.RemoveFrame(0);
// Don't forget to dispose the frame if you won't add it to some other TiffImage
activeFrame.Dispose();
tiffImage.Save();
}
AddFrames(TiffFrame[])
将框架的序列无缝地集成到图像中,丰富其内容和多样性:使用这种方法来改善图像组成和管理,可在您的应用程序中有效处理多框图像。
public void AddFrames(TiffFrame[] frames)
Parameters
frames
TiffFrame
( )
图为添加
AddPage(RasterImage)
在现有图像中无缝插入新页面,扩展其内容使用此方法来改善文档组成和管理,能够在您的应用程序中有效处理多页图像。
public virtual void AddPage(RasterImage page)
Parameters
page
RasterImage
添加的页面。
Exceptions
page’ is null.
AdjustBrightness(因特)
对图像进行 brightness’ 调整,允许对整体光度水平进行 themodification. 将此方法纳入图像处理工作流中,以提高可见性,并在应用程序中提高视觉质量的图像。
public override void AdjustBrightness(int brightness)
Parameters
brightness
int
光的价值。
Examples
下面的例子对 TIFF 图像进行亮度纠正。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Set the brightness value. The accepted values of brightness are in the range [-255, 255].
tiffImage.AdjustBrightness(50);
tiffImage.Save(dir + "sample.AdjustBrightness.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustContrast(航海)
增强 Aspose.Imaging.Image 例的对比,增加其光和黑暗区域之间的差异。功能性提高视觉清晰度和图像的整体质量在您的申请中。
public override void AdjustContrast(float contrast)
Parameters
contrast
float
对比值(在范围内(100;100)
Examples
下面的例子是对 TIFF 图像进行对比纠正。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
tiffImage.AdjustContrast(50f);
tiffImage.Save(dir + "sample.AdjustContrast.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustGamma(航海)
应用 Gamma 纠正到图像,调整像素强度到实现想要的颜色平衡. 将此方法纳入您的图像处理工作流提高视觉质量,提高后续的准确性分析或显示在您的应用程序中的任务。
public override void AdjustGamma(float gamma)
Parameters
gamma
float
红色、绿色和蓝色频道的Gamma
Examples
下面的例子是对 TIFF 图像进行 gamma 纠正。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Set gamma coefficient for red, green and blue channels.
tiffImage.AdjustGamma(2.5f);
tiffImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AdjustGamma(航海、航海、航海)
在图像上进行伽马纠正,使用单独的红色指数,绿色和蓝色频道,允许精细调整颜色平衡将此方法集成到您的图像处理管道中确保对颜色呈现的准确控制,并提高内部视觉忠诚度你的申请。
public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)
Parameters
gammaRed
float
红频率的Gamma
gammaGreen
float
绿色频道的Gamma
gammaBlue
float
蓝色频道的Gamma
Examples
下面的例子进行一张TIFF图像的伽马修复,适用于颜色组件的不同坐标。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Set individual gamma coefficients for red, green and blue channels.
tiffImage.AdjustGamma(1.5f, 2.5f, 3.5f);
tiffImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
AlignResolutions()
实施 AlignResolutions 助理方法,以同步水平和垂直分辨率,确保图像尺寸的统一性。通过协调分辨率,简化图像处理工作流参数,在各种平台上优化视觉质量和一致性,以及设备。
public void AlignResolutions()
BinarizeBradley(双重, int)
在使用布拉德利的适应边界的图像上实施二进制化具有综合图像边界的算法. 这种方法动态计算基于图像附近的本地边界,提高适应性不同照明条件,并确保可靠的分区。在您的申请中处理任务。
public override void BinarizeBradley(double brightnessDifference, int windowSize)
Parameters
brightnessDifference
double
像素之间的亮度差异和像素的平均窗口 s x s 的差异聚集在这个像素周围。
windowSize
int
这个像素周围集中的像素的 x s 窗口的尺寸
Examples
下面的例子将TIFF图像与布拉德利的适应边界算法与指定的窗口大小进行双重化,双重图像只包含2种颜色 - 黑色和白色。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)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.
tiffImage.BinarizeBradley(5, 10);
tiffImage.Save(dir + "sample.BinarizeBradley5_10x10.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeFixed(比特)
将二元化应用到图像,使用预定的边界,将其转换为二进制图像与分开的前沿和背景区域。方法进入您的图像处理工作流,以便方便分区和功能提取任务,提高图像分析的准确性和效率你的申请。
public override void BinarizeFixed(byte threshold)
Parameters
threshold
byte
如果一个像素的相应灰色值超过边界值,则255 将被分配给它, 0 否则。
Examples
下面的例子将 TIFF 图像与预先定义的边界二元化,二元化图像只包含 2 种颜色 - 黑色和白色。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)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.
tiffImage.BinarizeFixed(127);
tiffImage.Save(dir + "sample.BinarizeFixed.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
BinarizeOtsu()
使用 Otsu 边界以在图像上进行二进制,自动确定基于图像的历史图的最佳边界值。将此方法插入您的图像处理工作流,以实现有效的分区功能提取,提高图像分析的准确性和可靠性您申请中的任务。
public override void BinarizeOtsu()
Examples
下面的例子二元化了一个TIFF图像与Otsu边界。二元化图像只包含2种颜色 - 黑色和白色。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Binarize the image with Otsu thresholding.
tiffImage.BinarizeOtsu();
tiffImage.Save(dir + "sample.BinarizeOtsu.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Crop(Rectangle)
使用指定直角区域种植图像,允许精确选择将此方法集成到您的图像处理工作流中有效地消除不需要的区域,并专注于基本细节,提高图像的整体清晰度和组成。
public override void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
直角。
Examples
下面的例子是种植 TIFF 图像. 种植区域通过 Aspose.Imaging.Rectangle 指定。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Crop the image. The cropping area is the rectangular central area of the image.
Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(tiffImage.Width / 4, tiffImage.Height / 4, tiffImage.Width / 2, tiffImage.Height / 2);
tiffImage.Crop(area);
// Save the cropped image to PNG
tiffImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Crop(int , int , int , int , int)
在图像上进行挖掘,指定左,右,顶部和底部方向. 此方法允许精确选择所需的部分图像,以便有效地移除不需要的区域,并专注于基本内容:将此功能集成到您的图像处理中管道,以提高在您的应用中所需的清晰度和组成。
public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
Parameters
leftShift
int
左转。
rightShift
int
正确的转换。
topShift
int
顶级转换。
bottomShift
int
底部交换。
Examples
下面的例子是种植 TIFF 图像. 种植区域通过左、上、右、底边标定。
string dir = @"c:\temp\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Crop again. Set a margin of 10% of the image size.
int horizontalMargin = tiffImage.Width / 10;
int verticalMargin = tiffImage.Height / 10;
tiffImage.Crop(horizontalMargin, horizontalMargin, verticalMargin, verticalMargin);
// Save the cropped image to PNG.
tiffImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Dither(DitheringMethod, int,IColorPalette)
在当前图像上进行直播,以提高其视觉质量,并减少色彩连接物品. 将此方法集成到您的图像处理工作流确保颜色之间的过渡顺利,从而改善整体图像。外观和清晰度。
public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)
Parameters
ditheringMethod
DitheringMethod
定位方法。
bitsCount
int
最后的比特数为Ditering。
customPalette
IColorPalette
可用于Ditering的配件。
Examples
下面的例子加载了 TIFF 图像,并使用不同的板块深度进行边界和流动直径。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)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.
tiffImage.Dither(Aspose.Imaging.DitheringMethod.ThresholdDithering, 4, null);
tiffImage.Save(dir + "sample.ThresholdDithering4.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)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.
tiffImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1, null);
tiffImage.Save(dir + "sample.FloydSteinbergDithering1.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Filter(Rectangle, FilterOptions 基于)
在指定的直角内过滤内容,应用指定的图像处理过滤器以增强或修改所选择的区域。在您的图像操作工作流,以实现目标改进或在您的应用中进行转型。
public override void Filter(Rectangle rectangle, FilterOptionsBase options)
Parameters
rectangle
Rectangle
直角。
options
FilterOptionsBase
选项的。
Examples
下面的例子适用于TIFF图像的各种类型的过滤器。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Apply a median filter with a rectangle size of 5 to the entire image.
tiffImage.Filter(tiffImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MedianFilterOptions(5));
tiffImage.Save(dir + "sample.MedianFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Apply a bilateral smoothing filter with a kernel size of 5 to the entire image.
tiffImage.Filter(tiffImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.BilateralSmoothingFilterOptions(5));
tiffImage.Save(dir + "sample.BilateralSmoothingFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image.
tiffImage.Filter(tiffImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
tiffImage.Save(dir + "sample.GaussianBlurFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image.
tiffImage.Filter(tiffImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
tiffImage.Save(dir + "sample.GaussWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)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.
tiffImage.Filter(tiffImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MotionWienerFilterOptions(10, 1.0, 90.0));
tiffImage.Save(dir + "sample.MotionWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image.
tiffImage.Filter(tiffImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
tiffImage.Save(dir + "sample.SharpenFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
GetOriginalOptions()
恢复从原始文件设置中产生的选项,方便无缝保存关键参数,如比特深度和其他基本属性使用此方法保持忠诚和一致性图像处理任务,确保最佳结果,无需不必要的变化。例如,如果我们加载一张黑白的PNG图像,每像素1比特,然后使用Aspose.Imaging.DataStreamSupporter.Save(System.String)方法,输出PNG图像,每像素将产生8位。要避免它,并以每像素1比特保存PNG图像,使用此方法获得相应的储蓄选项并通过它们。在 Aspose.Imaging.Image.Save(System.String,Aspose.Imaging.ImageOptionsBase)方法作为第二个参数。
public override ImageOptionsBase GetOriginalOptions()
Returns
基于原始文件设置的选项。
Exceptions
没有原始选项可以从图像中提取
Grayscale()
将图像转化为其灰层代表性,将其转化为一个单频道图像,每个像素代表强度。在您的图像处理管道中简化分析和改进与基于格里斯卡的算法兼容性,方便各种计算机视觉和图像分析任务在您的应用程序内。
public override void Grayscale()
Examples
下面的例子将彩色TIFF图像转化为其灰色图像,灰色图像仅由灰色的阴影组成,仅提供强度信息。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
tiffImage.Grayscale();
tiffImage.Save(dir + "sample.Grayscale.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
InsertFrame(饰 饰 TiffFrame)
在框序列中将新框插入指定的指数中,确保精确控制框架安排 使用此方法来管理框架顺序有效,促进动态操纵和图像组织在您的申请中包含内容。
public void InsertFrame(int index, TiffFrame frameToInsert)
Parameters
index
int
新框架指数在框架列表中
frameToInsert
TiffFrame
插入的框架。
NormalizeAngle(白色,颜色)
使用 NormalizeAngle 方法,专门为扫描文档设计修复扫描,确保准确的调整。将此功能集成到您的文本处理工作流中,以提高文档可读性和质量,提高文档认可的整体效率分析任务。此方法使用 Aspose.Imaging.RasterImage.GetSkewAngle 和 Aspose.Imaging.FileFormats.Tiff.TiffImage.Rotate(System.Single,System.Boolean,Aspose.Imaging.Color) 方法。
public override void NormalizeAngle(bool resizeProportionally, Color backgroundColor)
Parameters
resizeProportionally
bool
如果设置为“真实”,您的图像大小将根据旋转直角(角点)的投影而改变,否则它会使尺寸不受触摸,只有内部图像内容被旋转。
backgroundColor
Color
背景的颜色。
ReleaseManagedResources()
释放管理资源 确保没有未管理资源在这里释放,因为它们可能已经释放了。
protected override void ReleaseManagedResources()
RemoveFrame(因特)
无力地从图像序列中删除其指数所识别的框架,在您的应用程序中简化框架管理。功能性提高框架操作的效率和准确性,促进无缝组织和图像内容的呈现。
public TiffFrame RemoveFrame(int index)
Parameters
index
int
要删除框架指数。
Returns
除去的框架。
Examples
下面的例子表明如何从个别的拉斯特图像中组成一个混合式TIFF。
Aspose.Imaging.ImageOptions.TiffOptions createTiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
createTiffOptions.Source = new Aspose.Imaging.Sources.FileCreateSource("c:\\temp\\multipage.tif", false);
createTiffOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
createTiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Create(createTiffOptions, 100, 100))
{
// This is Font and Brush for drawing text on individual frames.
Aspose.Imaging.Font font = new Aspose.Imaging.Font("Arial", 64);
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.White);
// Create 5 frames
for (int i = 1; i <= 5; i++)
{
Aspose.Imaging.ImageOptions.PngOptions createPngOptions = new Aspose.Imaging.ImageOptions.PngOptions();
createPngOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
// Create a PNG image and draw the number of page on it.
Aspose.Imaging.FileFormats.Png.PngImage pngImage = (Aspose.Imaging.FileFormats.Png.PngImage)Image.Create(createPngOptions, 100, 100);
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(pngImage);
gr.DrawString(i.ToString(), font, brush, 10, 10);
// Create a frame based on the PNG image.
Aspose.Imaging.FileFormats.Tiff.TiffFrame frame = new Aspose.Imaging.FileFormats.Tiff.TiffFrame(pngImage);
// Add the frame to the TIFF image.
tiffImage.AddFrame(frame);
}
// The image was created with a single default frame. Let's remove it.
Aspose.Imaging.FileFormats.Tiff.TiffFrame activeFrame = tiffImage.ActiveFrame;
tiffImage.ActiveFrame = tiffImage.Frames[1];
tiffImage.RemoveFrame(0);
// Don't forget to dispose the frame if you won't add it to some other TiffImage
activeFrame.Dispose();
tiffImage.Save();
}
Remarks
注意:请不要忘记将框架配置,如果您不会将其添加到其他 TiffImage。
RemoveFrame(TiffFrame)
有效地从图像序列中删除指定的框架,方便在您的应用程序中简化框架管理. 集成此功能提高框架操作的准确性和灵活性,确保无缝图像内容的组织和呈现。
public void RemoveFrame(TiffFrame frame)
Parameters
frame
TiffFrame
要移除的框架。
Remarks
注意:请不要忘记将框架配置,如果您不会将其添加到其他 TiffImage。
RemoveMetadata()
删除此图像示例 meta 数据 通过设置此 Aspose.Imaging.Xmp.IHasXMPData.xmp Data 和 _ www.exif.ihas Exif。 零.
public override void RemoveMetadata()
ReplaceFrame(饰 饰 TiffFrame)
在指定位置的框架被另一个框架无缝替换,促进图像序列内的动态框架管理。方法提高框架操作的灵活性和准确性,确保最佳的组织和图像内容在您的应用程序内呈现。
public TiffFrame ReplaceFrame(int index, TiffFrame frameToReplace)
Parameters
index
int
基于零的框架位置。
frameToReplace
TiffFrame
要取代的框架。
Returns
除去的框架。
Remarks
注意:请不要忘记将框架配置,如果您不会将其添加到其他 TiffImage。
Resize(int , int , resizeType)
根据指定的重复类型重复图像,使灵活图像尺寸的调整,同时保持视角比例或应用具体扩展算法. 将此方法纳入您的图像处理工作流实现在您的申请中对重复操作的准确控制。
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
新的宽度。
newHeight
int
新高度。
resizeType
ResizeType
回归类型。
Examples
这个例子加载了一个 TIFF 图像,并使用各种重复方法重新绘制它。
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// 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.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// 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.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// 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.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// 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());
}
Resize(int , int , ImageResizeSettings)
根据指定的设置调整图像的尺寸,允许准确超越尺寸、方面比例和规模行为的控制。方法进入您的图像处理工作流,以实现自定义复制根据您的申请的具体要求进行操作。
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)
Parameters
newWidth
int
新的宽度。
newHeight
int
新高度。
settings
ImageResizeSettings
重新设置。
Examples
此示例加载了 TIFF 图像,并使用各种重新设置重复图像。
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)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Scale down by 2 times using adaptive resampling.
tiffImage.Resize(image.Width / 2, image.Height / 2, resizeSettings);
// Save to PNG
tiffImage.Save(dir + "downsample.adaptive.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ResizeHeightProportionally(重定向,重定向)
进行比例调整图像的高度,保持其外观相对一致的视觉完整性. 使用这种方法以动态复制您的应用程序中的图像,在各种平台上提供最佳显示设备,不损害内容质量。
public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)
Parameters
newHeight
int
新高度。
resizeType
ResizeType
回归的类型。
Examples
这个例子加载了一个 TIFF 图像,并使用不同的重复方法相对重复它,只有高度,宽度自动计算。
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// Scale up by 2 times using Nearest Neighbour resampling.
image.ResizeHeightProportionally(image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// Scale down by 2 times using Nearest Neighbour resampling.
image.ResizeHeightProportionally(image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// Scale up by 2 times using Bilinear resampling.
image.ResizeHeightProportionally(image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// Scale down by 2 times using Bilinear resampling.
image.ResizeHeightProportionally(image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
ResizeProportional(int , int , resizeType)
在图像上进行比例重定向操作,保持其视角的比例,调整其尺寸. 使用此方法以动态规模图像在应用程序中,确保内容完整的一致视觉表现。 比例重定向将根据 newWidth’/width 和
newHeight’/height 的比例重定向每个框架。
public void ResizeProportional(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
新的宽度。
newHeight
int
新高度。
resizeType
ResizeType
回归类型。
ResizeWidthProportionally(重定向,重定向)
调整图像的宽度,同时保持其视角比例,确保相应的反射,以获得最佳视觉呈现。 使用此方法动态规模图像在您的应用程序内,方便一致和美学上令人愉快的表演在各种显示背景下。
public override void ResizeWidthProportionally(int newWidth, ResizeType resizeType)
Parameters
newWidth
int
新的宽度。
resizeType
ResizeType
回归的类型。
Examples
这个例子加载了一个 TIFF 图像,并使用不同的重复方法相对重复它,只有宽度被指定,高度自动计算。
string dir = "c:\\temp\\";
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// Scale up by 2 times using Nearest Neighbour resampling.
image.ResizeWidthProportionally(image.Width* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// Scale down by 2 times using Nearest Neighbour resampling.
image.ResizeWidthProportionally(image.Width / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with the default options.
image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// Scale up by 2 times using Bilinear resampling.
image.ResizeWidthProportionally(image.Width* 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
// Scale down by 2 times using Bilinear resampling.
image.ResizeWidthProportionally(image.Width / 2, Aspose.Imaging.ResizeType.BilinearResample);
// Save to PNG with the default options.
image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
}
Rotate(彩色 , 彩色 , 彩色)
旋转图像在其中心点周围,以确定的角度,使其准确方向调整:将此功能纳入图像处理中管道,以便精确的转换,确保最佳调整和在您的应用程序中提供视觉内容。
public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
float
旋转的角度在度,积极的值会旋转时钟。
resizeProportionally
bool
如果设置为“真实”,您的图像大小将根据旋转直角(角点)的投影而改变,否则它会使尺寸不受触摸,只有内部图像内容被旋转。
backgroundColor
Color
背景的颜色。
Examples
下面的例子表明如何在45度时钟地旋转中间的TIFF图像。
string dir = "c:\\temp\\";
Aspose.Imaging.ImageOptions.TiffOptions createTiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Create a permanent, not temporary file source.
createTiffOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "rotated.tif", false);
createTiffOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;
createTiffOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Create(createTiffOptions, 100, 100))
{
// The linear gradient from the left-top to the right-bottom corner of the image.
Aspose.Imaging.Brushes.LinearGradientBrush brush =
new Aspose.Imaging.Brushes.LinearGradientBrush(
new Aspose.Imaging.Point(0, 0),
new Aspose.Imaging.Point(tiffImage.Width, tiffImage.Height),
Aspose.Imaging.Color.Red,
Aspose.Imaging.Color.Green);
// Fill the active frame with the linear gradient brush.
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(tiffImage);
gr.FillRectangle(brush, tiffImage.Bounds);
// Rotate the image around the center by 45 degrees clockwise.
// The image size changed according to rotated rectangle (corner points).
tiffImage.Rotate(45f, true, Aspose.Imaging.Color.Black);
tiffImage.Save();
// Rotate the image around the center by 45 degrees clockwise.
// Leave the image dimensions untouched and only the internal image content are rotated.
tiffImage.Rotate(45f, false, Aspose.Imaging.Color.Gray);
tiffImage.Save(dir + "rotated.preservesize.tif");
}
RotateFlip(RotateFlipType)
进行旋转、滑动或两项操作的组合,仅在活跃框架:这种方法允许单独框架的准确操作图像序列,增强图像编辑和组成中的灵活性你的申请。
public override void RotateFlip(RotateFlipType rotateFlipType)
Parameters
rotateFlipType
RotateFlipType
旋转的Flip类型。
Examples
此示例加载 TIFF 图像,以 90 度的时钟向旋转,并可选地垂直和(或)垂直滑动图像。
string dir = "c:\\temp\\";
Aspose.Imaging.RotateFlipType[] rotateFlipTypes = new Aspose.Imaging.RotateFlipType[]
{
Aspose.Imaging.RotateFlipType.Rotate90FlipNone,
Aspose.Imaging.RotateFlipType.Rotate90FlipX,
Aspose.Imaging.RotateFlipType.Rotate90FlipXY,
Aspose.Imaging.RotateFlipType.Rotate90FlipY,
};
foreach (Aspose.Imaging.RotateFlipType rotateFlipType in rotateFlipTypes)
{
// Rotate, flip and save to the output file.
using (Aspose.Imaging.FileFormats.Tiff.TiffImage image = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
image.RotateFlip(rotateFlipType);
image.Save(dir + "sample." + rotateFlipType + ".png", new Aspose.Imaging.ImageOptions.PngOptions());
}
}
SaveData(Stream)
将对象的数据存储到指定的流。
protected override void SaveData(Stream stream)
Parameters
stream
Stream
流以保存对象的数据。
SetResolution(双,双)
设置指定的 Aspose.Imaging.RasterImage 的分辨率,可精确控制图像呈现和显示属性。功能性,以优化视觉输出,并确保与多样性相容性输出设备和平台,提高整体用户体验。
public override void SetResolution(double dpiX, double dpiY)
Parameters
dpiX
double
垂直分辨率,每英寸点,的Aspose.Imaging.RasterImage。
dpiY
double
垂直分辨率,每英寸点,的Aspose.Imaging.RasterImage。
Examples
下面的示例显示如何设置 TIFF 图像的水平/垂直分辨率。
string dir = "c:\\temp\\";
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
// Get horizontal and vertical resolution of the TiffImage.
double horizontalResolution = tiffImage.HorizontalResolution;
double verticalResolution = tiffImage.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");
tiffImage.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution, in pixels per inch: {0}", tiffImage.HorizontalResolution);
System.Console.WriteLine("The vertical resolution, in pixels per inch: {0}", tiffImage.VerticalResolution);
}
}
UpdateDimensions(int , int , int)
更新图像尺寸。
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
新图像宽度。
newHeight
int
新图像高度。