Class TiffFrame
Nombre del espacio: Aspose.Imaging.FileFormats.Tiff Asamblea: Aspose.Imaging.dll (25.4.0)
El Tiff Frame.
[JsonObject(MemberSerialization.OptIn)]
public sealed class TiffFrame : RasterCachedImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasExifData, IHasXmpData, IHasMetadata
Inheritance
object ← DisposableObject ← DataStreamSupporter ← Image ← RasterImage ← RasterCachedImage ← TiffFrame
Implements
IDisposable ,y, IObjectWithBounds ,y, IRasterImageArgb32PixelLoader ,y, IRasterImageRawDataLoader ,y, IHasExifData ,y, IHasXmpData ,y, IHasMetadata
Miembros heredados
RasterCachedImage.CacheData() ,y, RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte) ,y, RasterCachedImage.Resize(int, int, ResizeType) ,y, RasterCachedImage.Resize(int, int, ImageResizeSettings) ,y, RasterCachedImage.RotateFlip(RotateFlipType) ,y, RasterCachedImage.Rotate(float, bool, Color) ,y, RasterCachedImage.Crop(Rectangle) ,y, RasterCachedImage.Dither(DitheringMethod, int, IColorPalette) ,y, RasterCachedImage.Grayscale() ,y, RasterCachedImage.NormalizeHistogram() ,y, RasterCachedImage.BinarizeFixed(byte) ,y, RasterCachedImage.BinarizeOtsu() ,y, RasterCachedImage.BinarizeBradley(double, int) ,y, RasterCachedImage.BinarizeBradley(double) ,y, RasterCachedImage.AdjustBrightness(int) ,y, RasterCachedImage.AdjustContrast(float) ,y, RasterCachedImage.AdjustGamma(float, float, float) ,y, RasterCachedImage.AdjustGamma(float) ,y, RasterCachedImage.IsCached ,y, RasterImage.RemoveMetadata() ,y, RasterImage.Save(Stream, ImageOptionsBase, Rectangle) ,y, RasterImage.GetModifyDate(bool) ,y, RasterImage.Dither(DitheringMethod, int) ,y, RasterImage.Dither(DitheringMethod, int, IColorPalette) ,y, RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader) ,y, RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings) ,y, RasterImage.GetDefaultArgb32Pixels(Rectangle) ,y, RasterImage.GetDefaultRawData(Rectangle, RawDataSettings) ,y, RasterImage.GetArgb32Pixel(int, int) ,y, RasterImage.GetPixel(int, int) ,y, RasterImage.SetArgb32Pixel(int, int, int) ,y, RasterImage.SetPixel(int, int, Color) ,y, RasterImage.ReadScanLine(int) ,y, RasterImage.ReadArgb32ScanLine(int) ,y, RasterImage.WriteScanLine(int, Color[]) ,y, RasterImage.WriteArgb32ScanLine(int, int[]) ,y, RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader) ,y, RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader) ,y, RasterImage.LoadArgb32Pixels(Rectangle) ,y, RasterImage.LoadArgb64Pixels(Rectangle) ,y, RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader) ,y, RasterImage.LoadPixels(Rectangle) ,y, RasterImage.LoadCmykPixels(Rectangle) ,y, RasterImage.LoadCmyk32Pixels(Rectangle) ,y, RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader) ,y, RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader) ,y, RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings) ,y, RasterImage.SaveArgb32Pixels(Rectangle, int[]) ,y, RasterImage.SavePixels(Rectangle, Color[]) ,y, RasterImage.SaveCmykPixels(Rectangle, CmykColor[]) ,y, RasterImage.SaveCmyk32Pixels(Rectangle, int[]) ,y, RasterImage.SetResolution(double, double) ,y, RasterImage.SetPalette(IColorPalette, bool) ,y, RasterImage.Resize(int, int, ImageResizeSettings) ,y, RasterImage.Rotate(float, bool, Color) ,y, RasterImage.Rotate(float) ,y, RasterImage.BinarizeFixed(byte) ,y, RasterImage.BinarizeOtsu() ,y, RasterImage.BinarizeBradley(double) ,y, RasterImage.BinarizeBradley(double, int) ,y, RasterImage.Blend(Point, RasterImage, Rectangle, byte) ,y, RasterImage.Blend(Point, RasterImage, byte) ,y, RasterImage.Grayscale() ,y, RasterImage.NormalizeHistogram() ,y, RasterImage.AdjustBrightness(int) ,y, RasterImage.AdjustContrast(float) ,y, RasterImage.AdjustGamma(float, float, float) ,y, RasterImage.AdjustGamma(float) ,y, RasterImage.GetSkewAngle() ,y, RasterImage.NormalizeAngle() ,y, RasterImage.NormalizeAngle(bool, Color) ,y, RasterImage.Filter(Rectangle, FilterOptionsBase) ,y, RasterImage.ReplaceColor(Color, byte, Color) ,y, RasterImage.ReplaceColor(int, byte, int) ,y, RasterImage.ReplaceNonTransparentColors(Color) ,y, RasterImage.ReplaceNonTransparentColors(int) ,y, RasterImage.ToBitmap() ,y, RasterImage.PremultiplyComponents ,y, RasterImage.UseRawData ,y, RasterImage.UpdateXmpData ,y, RasterImage.XmpData ,y, RasterImage.RawIndexedColorConverter ,y, RasterImage.RawCustomColorConverter ,y, RasterImage.RawFallbackIndex ,y, RasterImage.RawDataSettings ,y, RasterImage.UsePalette ,y, RasterImage.RawDataFormat ,y, RasterImage.RawLineSize ,y, RasterImage.IsRawDataAvailable ,y, RasterImage.HorizontalResolution ,y, RasterImage.VerticalResolution ,y, RasterImage.HasTransparentColor ,y, RasterImage.HasAlpha ,y, RasterImage.TransparentColor ,y, RasterImage.ImageOpacity ,y, Image.CanLoad(string) ,y, Image.CanLoad(string, LoadOptions) ,y, Image.CanLoad(Stream) ,y, Image.CanLoad(Stream, LoadOptions) ,y, Image.Create(ImageOptionsBase, int, int) ,y, Image.Create(Image[]) ,y, Image.Create(MultipageCreateOptions) ,y, Image.Create(string[], bool) ,y, Image.Create(string[]) ,y, Image.Create(Image[], bool) ,y, Image.GetFileFormat(string) ,y, Image.GetFileFormat(Stream) ,y, Image.GetFittingRectangle(Rectangle, int, int) ,y, Image.GetFittingRectangle(Rectangle, int[], int, int) ,y, Image.Load(string, LoadOptions) ,y, Image.Load(string) ,y, Image.Load(Stream, LoadOptions) ,y, Image.Load(Stream) ,y, Image.GetProportionalWidth(int, int, int) ,y, Image.GetProportionalHeight(int, int, int) ,y, Image.RemoveMetadata() ,y, Image.CanSave(ImageOptionsBase) ,y, Image.Resize(int, int) ,y, Image.Resize(int, int, ResizeType) ,y, Image.Resize(int, int, ImageResizeSettings) ,y, Image.GetDefaultOptions(object[]) ,y, Image.GetOriginalOptions() ,y, Image.ResizeWidthProportionally(int) ,y, Image.ResizeHeightProportionally(int) ,y, Image.ResizeWidthProportionally(int, ResizeType) ,y, Image.ResizeHeightProportionally(int, ResizeType) ,y, Image.ResizeWidthProportionally(int, ImageResizeSettings) ,y, Image.ResizeHeightProportionally(int, ImageResizeSettings) ,y, Image.RotateFlip(RotateFlipType) ,y, Image.Rotate(float) ,y, Image.Crop(Rectangle) ,y, Image.Crop(int, int, int, int) ,y, Image.Save() ,y, Image.Save(string) ,y, Image.Save(string, ImageOptionsBase) ,y, Image.Save(string, ImageOptionsBase, Rectangle) ,y, Image.Save(Stream, ImageOptionsBase) ,y, Image.Save(Stream, ImageOptionsBase, Rectangle) ,y, Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) ,y, Image.SetPalette(IColorPalette, bool) ,y, Image.BitsPerPixel ,y, Image.Bounds ,y, Image.Container ,y, Image.Height ,y, Image.Palette ,y, Image.UsePalette ,y, Image.Size ,y, Image.Width ,y, Image.InterruptMonitor ,y, Image.BufferSizeHint ,y, Image.AutoAdjustPalette ,y, Image.HasBackgroundColor ,y, Image.FileFormat ,y, Image.BackgroundColor ,y, DataStreamSupporter.CacheData() ,y, DataStreamSupporter.Save() ,y, DataStreamSupporter.Save(Stream) ,y, DataStreamSupporter.Save(string) ,y, DataStreamSupporter.Save(string, bool) ,y, DataStreamSupporter.DataStreamContainer ,y, DataStreamSupporter.IsCached ,y, DisposableObject.Dispose() ,y, DisposableObject.Disposed ,y, object.GetType() ,y, object.ToString() ,y, object.Equals(object?) ,y, object.Equals(object?, object?) ,y, object.ReferenceEquals(object?, object?) ,y, object.GetHashCode()
Examples
Este ejemplo muestra cómo crear una imagen TIFF desde el escudo y salvarla en un archivo.
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");
}
Constructors
TiffFrame(Stream)
Inicia una nueva instancia de la clase Aspose.Imaging.FileFormats.Tiff.TiffFrame.
public TiffFrame(Stream stream)
Parameters
stream
Stream
El flujo para cargar una imagen y inicializar los pixel de marco y los datos de paleta con.
TiffFrame(Cortesía, TiffOptions)
Inicia una nueva instancia de la clase Aspose.Imaging.FileFormats.Tiff.TiffFrame.
public TiffFrame(Stream stream, TiffOptions options)
Parameters
stream
Stream
El flujo para cargar una imagen y inicializar los pixel de marco y los datos de paleta con.
options
TiffOptions
Las opciones para utilizar para el marco recién creado.
TiffFrame(El string)
Inicia una nueva instancia de la clase Aspose.Imaging.FileFormats.Tiff.TiffFrame.
public TiffFrame(string path)
Parameters
path
string
El camino para cargar una imagen y iniciar los datos de pixel y paleta con.
TiffFrame(Síntomas, TiffOptions)
Inicia una nueva instancia de la clase Aspose.Imaging.FileFormats.Tiff.TiffFrame.
public TiffFrame(string path, TiffOptions options)
Parameters
path
string
El camino para cargar una imagen y iniciar los datos de pixel y paleta con.
options
TiffOptions
Las opciones para utilizar para el marco recién creado.
TiffFrame(RasterImage)
Inicia una nueva instancia de la clase Aspose.Imaging.FileFormats.Tiff.TiffFrame.
public TiffFrame(RasterImage image)
Parameters
image
RasterImage
La imagen para iniciar el pixel de marco y los datos de paleta con.
Examples
El siguiente ejemplo muestra cómo componer un mutlipage TIFF de imágenes de raster individuales.
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();
}
TiffFrame(Desarrollo, TiffOptions)
Inicia una nueva instancia de la clase Aspose.Imaging.FileFormats.Tiff.TiffFrame.
public TiffFrame(RasterImage image, TiffOptions options)
Parameters
image
RasterImage
La imagen para iniciar el pixel de marco y los datos de paleta con.
options
TiffOptions
Las opciones para utilizar para el marco recién creado.
TiffFrame(Opciones, int, int)
Inicia una nueva instancia de la clase Aspose.Imaging.FileFormats.Tiff.TiffFrame.
public TiffFrame(TiffOptions options, int width, int height)
Parameters
options
TiffOptions
Las opciones de marco.
width
int
de la amplitud.
height
int
La altura.
Examples
Este ejemplo muestra cómo crear una imagen TIFF desde el escudo y salvarla en un archivo.
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");
}
Este ejemplo muestra cómo crear una imagen TIFF con 2 cuadros y guardarla en un archivo.
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
El parámetro de opciones es nulo.
Properties
BackgroundColor
Obtenga o establece un valor para el color de fondo.
public override Color BackgroundColor { get; set; }
Valor de la propiedad
BitsPerPixel
Recibe los bits de la imagen por cuenta de píxeles.
public override int BitsPerPixel { get; }
Valor de la propiedad
ExifData
Obtenga o establece datos EXIF desde el marco.
public ExifData ExifData { get; set; }
Valor de la propiedad
FrameOptions
Obtenga el marco para crear opciones.
public TiffOptions FrameOptions { get; }
Valor de la propiedad
HasAlpha
Recibe un valor que indica si esta instancia tiene alfa.
public override bool HasAlpha { get; }
Valor de la propiedad
Examples
El siguiente ejemplo carga una imagen TIFF y imprime información sobre el formato de datos crudos y el canal alfa.
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
HasTransparentColor
Recibe un valor que indica si la imagen tiene color transparente.
public override bool HasTransparentColor { get; set; }
Valor de la propiedad
Height
Obtenga la altura de la imagen.
public override int Height { get; }
Valor de la propiedad
HorizontalResolution
Obtenga o establece la resolución horizontal, en píxeles por pulgón, de este Aspose.Imaging.RasterImage.
public override double HorizontalResolution { get; set; }
Valor de la propiedad
Examples
El siguiente ejemplo muestra cómo definir la resolución horizontal/vertical de un marco TIFF separado.
string dir = "c:\\temp\\";
// Load a TIFF image from a file.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
int i = 0;
foreach (Aspose.Imaging.FileFormats.Tiff.TiffFrame frame in tiffImage.Frames)
{
// Get horizontal and vertical resolution of the TiffFrame.
double horizontalResolution = frame.HorizontalResolution;
double verticalResolution = frame.VerticalResolution;
System.Console.WriteLine("The horizontal resolution of frame {0}, pixels per inch: {1}", i, horizontalResolution);
System.Console.WriteLine("The vertical resolution, of frame {0}, pixels per inch: {1}", i, 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");
frame.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution of frame {0}, pixels per inch: {1}", i, horizontalResolution);
System.Console.WriteLine("The vertical resolution, of frame {0}, pixels per inch: {1}", i, verticalResolution);
}
++i;
}
}
PathResources
Obtenga o establece los recursos del camino.
public List<pathresource> PathResources { get; set; }
Valor de la propiedad
List &ylt; PathResource >
Examples
Transferir Paths Clipping durante la exportación de TIFF a la imagen PSD.
using (var image = Image.Load("Sample.tif"))
{
image.Save("SampleWithPaths.psd", new PsdOptions());
}
El siguiente ejemplo muestra cómo recuperar los caminos de la imagen de TIFF y mostrar sus nombres en la consola.
using (var image = (TiffImage)Image.Load("Sample.tif"))
{
foreach (var path in image.ActiveFrame.PathResources)
{
Console.WriteLine(path.Name);
}
}
El siguiente ejemplo muestra cómo modificar las Paths de Clipping ya existentes. por ejemplo, solo puede mantener una Path de Clipping en la imagen.
using (var image = (TiffImage)Image.Load("Sample.tif"))
{
var paths = image.ActiveFrame.PathResources;
image.ActiveFrame.PathResources = paths.Take(1).ToList();
image.Save();
}
El siguiente ejemplo muestra cómo crear Clipping Path en la imagen TIFF. Para hacerlo, necesita crear una instancia de la clase PathResource. El código siguiente muestra cómo puede crear un camino vacío en la imagen TIFF.
var options = new TiffOptions(TiffExpectedFormat.Default);
var frame = new TiffFrame(options, 800, 600);
using (var image = new TiffImage(frame))
{
image.ActiveFrame.PathResources = new List<pathresource>
{
new PathResource
{
BlockId = 2000,
Name = "My Clipping Path",
Records = new List<vectorpathrecord>()
}
};
image.Save("ImageWithEmptyPath.tiff");
}</vectorpathrecord></pathresource>
Crea el Path Clipping manualmente.
static void Main()
{
using (var image = (TiffImage)Image.Load("Sample.tif"))
{
image.ActiveFrame.PathResources = new List<pathresource> { new PathResource
{
BlockId = 2000, // Block Id according to Photoshop specification
Name = "My Clipping Path", // Path name
Records = CreateRecords(0.2f, 0.2f, 0.8f, 0.2f, 0.8f, 0.8f, 0.2f, 0.8f) // Create path records using coordinates
}};
image.Save("ImageWithPath.tif");
}
}
private static List<vectorpathrecord> CreateRecords(params float[] coordinates)
{
var records = CreateBezierRecords(coordinates); // Create Bezier records using coordinates
records.Insert(0, new LengthRecord // LengthRecord required by Photoshop specification
{
IsOpen = false, // Lets create closed path
RecordCount = (ushort)records.Count // Record count in the path
});
return records;
}
private static List<vectorpathrecord> CreateBezierRecords(float[] coordinates)
{
return CoordinatesToPoints(coordinates)
.Select(CreateBezierRecord)
.ToList();
}
private static IEnumerable<pointf> CoordinatesToPoints(float[] coordinates)
{
for (var index = 0; index < coordinates.Length; index += 2)
yield return new PointF(coordinates[index], coordinates[index + 1]);
}
private static VectorPathRecord CreateBezierRecord(PointF point)
{
return new BezierKnotRecord { PathPoints = new[] { point, point, point } };
}</pointf></vectorpathrecord></vectorpathrecord></pathresource>
VerticalResolution
Obtenga o establece la resolución vertical, en píxeles por pulgón, de este Aspose.Imaging.RasterImage.
public override double VerticalResolution { get; set; }
Valor de la propiedad
Examples
El siguiente ejemplo muestra cómo definir la resolución horizontal/vertical de un marco TIFF separado.
string dir = "c:\\temp\\";
// Load a TIFF image from a file.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.tif"))
{
Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)image;
int i = 0;
foreach (Aspose.Imaging.FileFormats.Tiff.TiffFrame frame in tiffImage.Frames)
{
// Get horizontal and vertical resolution of the TiffFrame.
double horizontalResolution = frame.HorizontalResolution;
double verticalResolution = frame.VerticalResolution;
System.Console.WriteLine("The horizontal resolution of frame {0}, pixels per inch: {1}", i, horizontalResolution);
System.Console.WriteLine("The vertical resolution, of frame {0}, pixels per inch: {1}", i, 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");
frame.SetResolution(96.0, 96.0);
System.Console.WriteLine("The horizontal resolution of frame {0}, pixels per inch: {1}", i, horizontalResolution);
System.Console.WriteLine("The vertical resolution, of frame {0}, pixels per inch: {1}", i, verticalResolution);
}
++i;
}
}
Width
Obtenga la ancho de la imagen.
public override int Width { get; }
Valor de la propiedad
XmpData
Obtener o establecer datos Xmp.
public override XmpPacketWrapper XmpData { get; set; }
Valor de la propiedad
Methods
AlignResolutions()
El método ayuda a que las resoluciones horizontales y verticales sean iguales.
public void AlignResolutions()
CopyFrame(TiffFrame)
Copia todo el marco (duplicado).
public static TiffFrame CopyFrame(TiffFrame tiffFrame)
Parameters
tiffFrame
TiffFrame
El cuadro tiff para copiar.
Returns
El recién copiado tiff frame.
CreateFrameFrom(TiffFrame y TiffOptions)
Crea el marco de la tiffFrame’ especificada utilizando las opciones
especificadas.Los datos de pixel se conservan pero se converten en el formato deseado.
public static TiffFrame CreateFrameFrom(TiffFrame tiffFrame, TiffOptions options)
Parameters
tiffFrame
TiffFrame
El marco tiff para crear de.
options
TiffOptions
Las nuevas opciones a utilizar.
Returns
El nuevo marco creado.
Examples
El siguiente ejemplo muestra cómo crear una copia de grayscale de un marco existente y agregarlo a una imagen 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 + "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))
{
// 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 a linear gradient brush.
Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(tiffImage.ActiveFrame);
gr.FillRectangle(brush, tiffImage.Bounds);
// Grayscale options
Aspose.Imaging.ImageOptions.TiffOptions createTiffFrameOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
createTiffFrameOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
createTiffFrameOptions.Photometric = Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.MinIsBlack;
createTiffFrameOptions.BitsPerSample = new ushort[] { 8 };
// Create a grayscale copy of the active frame.
// The pixel data is preserved but converted to the desired format.
Aspose.Imaging.FileFormats.Tiff.TiffFrame grayscaleFrame = Aspose.Imaging.FileFormats.Tiff.TiffFrame.CreateFrameFrom(tiffImage.ActiveFrame, createTiffFrameOptions);
// Add the newly created frame to the TIFF image.
tiffImage.AddFrame(grayscaleFrame);
tiffImage.Save();
}
Crop(Rectangle)
Crotando la imagen.
public override void Crop(Rectangle rectangle)
Parameters
rectangle
Rectangle
El rectángulo.
GetOriginalOptions()
Obtenga las opciones basadas en las configuraciones de archivo original.Esto puede ser útil para mantener la profundidad del bit y otros parámetros de la imagen original sin cambios.Por ejemplo, si cargamos una imagen de PNG en blanco y negro con 1 bito por píxel y luego la guardamos utilizando elAspose.Imaging.DataStreamSupporter.Save(System.String) método, la imagen PNG de salida con 8 bits por pixel se producir.Para evitarlo y ahorrar la imagen PNG con 1 bits por píxel, utilice este método para obtener las opciones de ahorro correspondientes y pasarlaspara el método Aspose.Imaging.Image.Save(System.String,Aspose.Imaging.ImageOptionsBase) como el segundo parámetro.
public override ImageOptionsBase GetOriginalOptions()
Returns
Las opciones basadas en las configuraciones de archivo original.
ReleaseManagedResources()
Asegúrese de que los recursos no gestionados no se liberan aquí, ya que pueden haber sido ya liberados.
protected override void ReleaseManagedResources()
RemoveMetadata()
Elimina estos metadatos de instancia de la imagen al configurar los valores de Aspose.Imaging.Xmp.IHasXMPData.xmpDat y Wl17.Exif. Nula.
public override void RemoveMetadata()
Resize(int, int, resizeType)
Recupera la imagen.
public override void Resize(int newWidth, int newHeight, ResizeType resizeType)
Parameters
newWidth
int
La nueva amplitud.
newHeight
int
La nueva altura.
resizeType
ResizeType
El tipo de residuos.
Rotate(float, bool, color)
Imagen rotativa alrededor del centro.
public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)
Parameters
angle
float
El ángulo de rotación en grados. valores positivos rotarán de manera horaria.
resizeProportionally
bool
si se establece a ‘verdad’ tendrás su tamaño de imagen cambiado de acuerdo con las proyecciones rectangulares rotadas (puntos de esquina) en otro caso que deja las dimensiones no tocadas y sólo los contenidos de la imagen interna son rotados.
backgroundColor
Color
El color del fondo.
SaveData(Stream)
ahorrar los datos.
protected override void SaveData(Stream stream)
Parameters
stream
Stream
El flujo para salvar los datos a.
UpdateDimensions(El int, int)
Actualizar las dimensiones de la imagen.
protected override void UpdateDimensions(int newWidth, int newHeight)
Parameters
newWidth
int
La nueva imagen es amplia.
newHeight
int
El nuevo tamaño de la imagen.