Class Image
Името на пространството: Aspose.Note Асамблея: Aspose.Note.dll (25.4.0)
Представяне на изображение.
public sealed class Image : CompositeNode<loop>, ICompositeNode<loop>, ICompositeNode, IEnumerable<loop>, IEnumerable, IPageChildNode, IOutlineElementChildNode, ITaggable, INode
Inheritance
object
←
Node
←
CompositeNodeBase
←
CompositeNode
Implements
ICompositeNode
наследници
CompositeNode
Examples
Показва как да се свърже хипервръзка към изображение.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
var document = new Document();
var page = new Page(document);
var image = new Image(document, dataDir + "image.jpg") { HyperlinkUrl = "http://image.com" };
page.AppendChildLast(image);
document.AppendChildLast(page);
document.Save(dataDir + "Image with Hyperlink_out.one");
Показва как да зададете текст описание за изображение.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
var document = new Document();
var page = new Page(document);
var image = new Image(document, dataDir + "image.jpg")
{
AlternativeTextTitle = "This is an image's title!",
AlternativeTextDescription = "And this is an image's description!"
};
page.AppendChildLast(image);
document.AppendChildLast(page);
dataDir = dataDir + "ImageAlternativeText_out.one";
document.Save(dataDir);
Показва как да се получи снимка от документ.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<aspose.note.image> nodes = oneFile.GetChildNodes<aspose.note.image>();
foreach (Aspose.Note.Image image in nodes)
{
using (MemoryStream stream = new MemoryStream(image.Bytes))
{
using (Bitmap bitMap = new Bitmap(stream))
{
// Save image bytes to a file
bitMap.Save(String.Format(dataDir + "{0}", Path.GetFileName(image.FileName)));
}
}
}</aspose.note.image></aspose.note.image>
Показва как да получите мета-информация на изображението.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<aspose.note.image> images = oneFile.GetChildNodes<aspose.note.image>();
foreach (Aspose.Note.Image image in images)
{
Console.WriteLine("Width: {0}", image.Width);
Console.WriteLine("Height: {0}", image.Height);
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
Console.WriteLine("FileName: {0}", image.FileName);
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
Console.WriteLine();
}</aspose.note.image></aspose.note.image>
Показва как да добавите нова картина с таг.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tags();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Initialize Outline class object
Outline outline = new Outline(doc);
// Initialize OutlineElement class object
OutlineElement outlineElem = new OutlineElement(doc);
// Load an image
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "icon.jpg");
// Insert image in the document node
outlineElem.AppendChildLast(image);
image.Tags.Add(NoteTag.CreateYellowStar());
// Add outline element node
outline.AppendChildLast(outlineElem);
// Add outline node
page.AppendChildLast(outline);
// Add page node
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "AddImageNodeWithTag_out.one";
doc.Save(dataDir);
Показва как да добавите изображение от файл към документ с определени свойства на потребителя.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load document from the stream.
Document doc = new Document(dataDir + "Aspose.one");
// Get the first page of the document.
Aspose.Note.Page page = doc.FirstChild;
// Load an image from the file.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
// Change the image's size according to your needs (optional).
Width = 100,
Height = 100,
// Set the image's location in the page (optional).
HorizontalOffset = 100,
VerticalOffset = 400,
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add the image to the page.
page.AppendChildLast(image);
Показва как да добавите изображение от потока към документ.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline1 = new Outline(doc);
OutlineElement outlineElem1 = new OutlineElement(doc);
using (FileStream fs = File.OpenRead(dataDir + "image.jpg"))
{
// Load the second image using the image name, extension and stream.
Aspose.Note.Image image1 = new Aspose.Note.Image(doc, "Penguins.jpg", fs)
{
// Set image alignment
Alignment = HorizontalAlignment.Right
};
outlineElem1.AppendChildLast(image1);
}
outline1.AppendChildLast(outlineElem1);
page.AppendChildLast(outline1);
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out.one";
doc.Save(dataDir);
Показва как да добавите изображение от файл към документ.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Initialize Outline class object and set offset properties
Outline outline = new Outline(doc);
// Initialize OutlineElement class object
OutlineElement outlineElem = new OutlineElement(doc);
// Load an image by the file path.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add image
outlineElem.AppendChildLast(image);
// Add outline elements
outline.AppendChildLast(outlineElem);
// Add Outline node
page.AppendChildLast(outline);
// Add Page node
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "BuildDocAndInsertImage_out.one";
doc.Save(dataDir);
Constructors
Image(Стрий)
Иницијализира нова инстанция на Aspose.Note.Снимка клас.
public Image(string path)
Parameters
path
string
Една лента, която съдържа пътя към файла, от който да се създаде Aspose.Note.Image.
Image(Стринг, Стринг и Стринг)
Иницијализира нова инстанция на Aspose.Note.Снимка клас.
public Image(string path, string altTitle = null, string altDescription = null)
Parameters
path
string
Една лента, която съдържа пътя към файла, от който да се създаде Aspose.Note.Image.
altTitle
string
Алтернативният заглавие.
altDescription
string
Алтернативното описание.
Image(Стрий, Стрий)
Иницијализира нова инстанция на Aspose.Note.Снимка клас.
public Image(string fileName, Stream imageStream)
Parameters
fileName
string
Името на изображението.
imageStream
Stream
Поток, който съдържа изображението.
Image()
Иницијализира нова инстанция на Aspose.Note.Снимка клас.
public Image()
Properties
Alignment
Получавате или поставяте съответствието.
public HorizontalAlignment Alignment { get; set; }
стойност на имота
Examples
Показва как да добавите изображение от файл към документ с определени свойства на потребителя.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load document from the stream.
Document doc = new Document(dataDir + "Aspose.one");
// Get the first page of the document.
Aspose.Note.Page page = doc.FirstChild;
// Load an image from the file.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
// Change the image's size according to your needs (optional).
Width = 100,
Height = 100,
// Set the image's location in the page (optional).
HorizontalOffset = 100,
VerticalOffset = 400,
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add the image to the page.
page.AppendChildLast(image);
Показва как да добавите изображение от потока към документ.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline1 = new Outline(doc);
OutlineElement outlineElem1 = new OutlineElement(doc);
using (FileStream fs = File.OpenRead(dataDir + "image.jpg"))
{
// Load the second image using the image name, extension and stream.
Aspose.Note.Image image1 = new Aspose.Note.Image(doc, "Penguins.jpg", fs)
{
// Set image alignment
Alignment = HorizontalAlignment.Right
};
outlineElem1.AppendChildLast(image1);
}
outline1.AppendChildLast(outlineElem1);
page.AppendChildLast(outline1);
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out.one";
doc.Save(dataDir);
Показва как да добавите изображение от файл към документ.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Initialize Outline class object and set offset properties
Outline outline = new Outline(doc);
// Initialize OutlineElement class object
OutlineElement outlineElem = new OutlineElement(doc);
// Load an image by the file path.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add image
outlineElem.AppendChildLast(image);
// Add outline elements
outline.AppendChildLast(outlineElem);
// Add Outline node
page.AppendChildLast(outline);
// Add Page node
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "BuildDocAndInsertImage_out.one";
doc.Save(dataDir);
AlternativeTextDescription
Получава или поставя едно тяло с алтернативен текст за изображението.
public string AlternativeTextDescription { get; set; }
стойност на имота
Examples
Показва как да зададете текст описание за изображение.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
var document = new Document();
var page = new Page(document);
var image = new Image(document, dataDir + "image.jpg")
{
AlternativeTextTitle = "This is an image's title!",
AlternativeTextDescription = "And this is an image's description!"
};
page.AppendChildLast(image);
document.AppendChildLast(page);
dataDir = dataDir + "ImageAlternativeText_out.one";
document.Save(dataDir);
AlternativeTextTitle
Получава или поставя заглавие на алтернативен текст за изображението.
public string AlternativeTextTitle { get; set; }
стойност на имота
Examples
Показва как да зададете текст описание за изображение.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
var document = new Document();
var page = new Page(document);
var image = new Image(document, dataDir + "image.jpg")
{
AlternativeTextTitle = "This is an image's title!",
AlternativeTextDescription = "And this is an image's description!"
};
page.AppendChildLast(image);
document.AppendChildLast(page);
dataDir = dataDir + "ImageAlternativeText_out.one";
document.Save(dataDir);
Bytes
Вземете изображението в магазина за данни.
public byte[] Bytes { get; }
стойност на имота
byte []
Examples
Показва как да се получи снимка от документ.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<aspose.note.image> nodes = oneFile.GetChildNodes<aspose.note.image>();
foreach (Aspose.Note.Image image in nodes)
{
using (MemoryStream stream = new MemoryStream(image.Bytes))
{
using (Bitmap bitMap = new Bitmap(stream))
{
// Save image bytes to a file
bitMap.Save(String.Format(dataDir + "{0}", Path.GetFileName(image.FileName)));
}
}
}</aspose.note.image></aspose.note.image>
FileName
Получава името на файла.
public string FileName { get; }
стойност на имота
Examples
Показва как да получите мета-информация на изображението.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<aspose.note.image> images = oneFile.GetChildNodes<aspose.note.image>();
foreach (Aspose.Note.Image image in images)
{
Console.WriteLine("Width: {0}", image.Width);
Console.WriteLine("Height: {0}", image.Height);
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
Console.WriteLine("FileName: {0}", image.FileName);
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
Console.WriteLine();
}</aspose.note.image></aspose.note.image>
FilePath
Вземете пътя към файла на изображението.
public string FilePath { get; }
стойност на имота
Format
Получава формата на изображението.
public ImageFormat Format { get; }
стойност на имота
Height
Това е истинската височина на изображението в MS OneNote документ.
public float Height { get; set; }
стойност на имота
Examples
Показва как да получите мета-информация на изображението.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<aspose.note.image> images = oneFile.GetChildNodes<aspose.note.image>();
foreach (Aspose.Note.Image image in images)
{
Console.WriteLine("Width: {0}", image.Width);
Console.WriteLine("Height: {0}", image.Height);
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
Console.WriteLine("FileName: {0}", image.FileName);
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
Console.WriteLine();
}</aspose.note.image></aspose.note.image>
Показва как да добавите изображение от файл към документ с определени свойства на потребителя.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load document from the stream.
Document doc = new Document(dataDir + "Aspose.one");
// Get the first page of the document.
Aspose.Note.Page page = doc.FirstChild;
// Load an image from the file.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
// Change the image's size according to your needs (optional).
Width = 100,
Height = 100,
// Set the image's location in the page (optional).
HorizontalOffset = 100,
VerticalOffset = 400,
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add the image to the page.
page.AppendChildLast(image);
HorizontalOffset
Получава или поставя хоризонталната отстъпка.
public float HorizontalOffset { get; set; }
стойност на имота
Examples
Показва как да добавите изображение от файл към документ с определени свойства на потребителя.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load document from the stream.
Document doc = new Document(dataDir + "Aspose.one");
// Get the first page of the document.
Aspose.Note.Page page = doc.FirstChild;
// Load an image from the file.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
// Change the image's size according to your needs (optional).
Width = 100,
Height = 100,
// Set the image's location in the page (optional).
HorizontalOffset = 100,
VerticalOffset = 400,
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add the image to the page.
page.AppendChildLast(image);
HyperlinkUrl
Получава или поставя хипервръзката, свързана с изображението.
public string HyperlinkUrl { get; set; }
стойност на имота
Examples
Показва как да се свърже хипервръзка към изображение.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
var document = new Document();
var page = new Page(document);
var image = new Image(document, dataDir + "image.jpg") { HyperlinkUrl = "http://image.com" };
page.AppendChildLast(image);
document.AppendChildLast(page);
document.Save(dataDir + "Image with Hyperlink_out.one");
IsBackground
Разберете дали изображението е образа на фона.
public bool IsBackground { get; set; }
стойност на имота
LastModifiedTime
Получава или определя последното модифицирано време.
public DateTime LastModifiedTime { get; set; }
стойност на имота
Examples
Показва как да получите мета-информация на изображението.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<aspose.note.image> images = oneFile.GetChildNodes<aspose.note.image>();
foreach (Aspose.Note.Image image in images)
{
Console.WriteLine("Width: {0}", image.Width);
Console.WriteLine("Height: {0}", image.Height);
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
Console.WriteLine("FileName: {0}", image.FileName);
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
Console.WriteLine();
}</aspose.note.image></aspose.note.image>
OriginalHeight
Това е оригиналната ширина на изображението, преди да се рециклира.
public float OriginalHeight { get; }
стойност на имота
Examples
Показва как да получите мета-информация на изображението.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<aspose.note.image> images = oneFile.GetChildNodes<aspose.note.image>();
foreach (Aspose.Note.Image image in images)
{
Console.WriteLine("Width: {0}", image.Width);
Console.WriteLine("Height: {0}", image.Height);
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
Console.WriteLine("FileName: {0}", image.FileName);
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
Console.WriteLine();
}</aspose.note.image></aspose.note.image>
OriginalWidth
Това е оригиналната ширина на изображението, преди да се рециклира.
public float OriginalWidth { get; }
стойност на имота
Examples
Показва как да получите мета-информация на изображението.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<aspose.note.image> images = oneFile.GetChildNodes<aspose.note.image>();
foreach (Aspose.Note.Image image in images)
{
Console.WriteLine("Width: {0}", image.Width);
Console.WriteLine("Height: {0}", image.Height);
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
Console.WriteLine("FileName: {0}", image.FileName);
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
Console.WriteLine();
}</aspose.note.image></aspose.note.image>
Tags
Получавате списъка на всички етикети на параграф.
public List<itag> Tags { get; }
стойност на имота
Examples
Показва как да добавите нова картина с таг.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Tags();
// Create an object of the Document class
Document doc = new Document();
// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);
// Initialize Outline class object
Outline outline = new Outline(doc);
// Initialize OutlineElement class object
OutlineElement outlineElem = new OutlineElement(doc);
// Load an image
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "icon.jpg");
// Insert image in the document node
outlineElem.AppendChildLast(image);
image.Tags.Add(NoteTag.CreateYellowStar());
// Add outline element node
outline.AppendChildLast(outlineElem);
// Add outline node
page.AppendChildLast(outline);
// Add page node
doc.AppendChildLast(page);
// Save OneNote document
dataDir = dataDir + "AddImageNodeWithTag_out.one";
doc.Save(dataDir);
VerticalOffset
Получава или поставя вертикалната отстъпка.
public float VerticalOffset { get; set; }
стойност на имота
Examples
Показва как да добавите изображение от файл към документ с определени свойства на потребителя.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load document from the stream.
Document doc = new Document(dataDir + "Aspose.one");
// Get the first page of the document.
Aspose.Note.Page page = doc.FirstChild;
// Load an image from the file.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
// Change the image's size according to your needs (optional).
Width = 100,
Height = 100,
// Set the image's location in the page (optional).
HorizontalOffset = 100,
VerticalOffset = 400,
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add the image to the page.
page.AppendChildLast(image);
Width
Това е действителната ширина на изображението в MS OneNote документ.
public float Width { get; set; }
стойност на имота
Examples
Показва как да получите мета-информация на изображението.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load the document into Aspose.Note.
Document oneFile = new Document(dataDir + "Aspose.one");
// Get all Image nodes
IList<aspose.note.image> images = oneFile.GetChildNodes<aspose.note.image>();
foreach (Aspose.Note.Image image in images)
{
Console.WriteLine("Width: {0}", image.Width);
Console.WriteLine("Height: {0}", image.Height);
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
Console.WriteLine("FileName: {0}", image.FileName);
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
Console.WriteLine();
}</aspose.note.image></aspose.note.image>
Показва как да добавите изображение от файл към документ с определени свойства на потребителя.
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Images();
// Load document from the stream.
Document doc = new Document(dataDir + "Aspose.one");
// Get the first page of the document.
Aspose.Note.Page page = doc.FirstChild;
// Load an image from the file.
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
// Change the image's size according to your needs (optional).
Width = 100,
Height = 100,
// Set the image's location in the page (optional).
HorizontalOffset = 100,
VerticalOffset = 400,
// Set image alignment
Alignment = HorizontalAlignment.Right
};
// Add the image to the page.
page.AppendChildLast(image);
Methods
Accept(DocumentVisitor)
Приема посетителя на възела.
public override void Accept(DocumentVisitor visitor)
Parameters
visitor
DocumentVisitor
Предметът на класа, произтичащ от Aspose.Note.DocumentVisitor.
Replace(Image)
Заменя текущите данни за изображение с данните от предоставения обект на изображението.
public void Replace(Image newImage)
Parameters
newImage
Image
Предметът на изображението съдържа новите данни.