Class Image
Namespace: Aspose.Note
Assembly: Aspose.Note.dll (25.6.0)
Represents an Image.
public sealed class Image : CompositeNode<loop>, ICompositeNode<loop>, ICompositeNode,
IEnumerable<loop>, IEnumerable, IPageChildNode, IOutlineElementChildNode, ITaggable, INode
{
}
Inheritance
object
←
Node
←
CompositeNodeBase
←
CompositeNode
Implements
ICompositeNode
Inherited Members
CompositeNode
Examples
Shows how to bind a hyperlink to an image.
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");
Shows how to set text description for an image.
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 += "ImageAlternativeText_out.one";
document.Save(dataDir);
Shows how to get an image from a document.
string dataDir = RunExamples.GetDataDir_Images();
Aspose.Words.Document oneFile = new Aspose.Words.Document(dataDir + "Aspose.one");
IList<aspose.note.Image> nodes = oneFile.GetChildNodes<aspose.note.Image>();
foreach (var image in nodes)
{
using (MemoryStream stream = new MemoryStream(image.Bytes))
{
using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(stream))
{
bitmap.Save(Path.Combine(dataDir, Path.GetFileName(image.FileName)));
}
}
}
Shows how to get image’s meta information.
Aspose.Words.Document oneFile = new Aspose.Words.Document(dataDir + "Aspose.one");
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();
}
System.Environment.NewLine;
Shows how to add new image with tag.
string dataDir = RunExamples.GetDataDir_Tags();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "icon.jpg");
outlineElem.AppendChildLast(image);
image.Tags.Add(NoteTag.CreateYellowStar());
outlineElem.AppendChildLast(image); // Moved the Tags.Add line after appending child last for better readability
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "AddImageNodeWithTag_out.one"; // Appended a space and added quotes to the concatenation for better readability
doc.Save(dataDir);
Shows how to add an image from file to a document with user defined properties.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document(dataDir + "Aspose.one");
Aspose.Note.Page page = doc.FirstChild;
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Width = 100,
Height = 100,
HorizontalOffset = 100,
VerticalOffset = 400,
Alignment = Aspose.Note.HorizontalAlignment.Right
};
page.AppendChildLast(image);
Shows how to add an image from stream to a document.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document();
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"))
{
Aspose.Note.Image image1 = new Aspose.Note.Image(doc, "Penguins.jpg", fs)
{
Alignment = HorizontalAlignment.Right
};
outlineElem1.AppendChildLast(image1);
}
outline1.AppendChildLast(outlineElem1);
page.AppendChildLast(outline1);
doc.AppendChildLast(page);
dataDir += "BuildDocAndInsertImageUsingImageStream_out.one";
doc.Save(dataDir);
Shows how to add an image from file to a document.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Alignment = HorizontalAlignment.Right
};
outlineElem.AppendChildLast(image);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "BuildDocAndInsertImage_out.one";
doc.Save(dataDir);
Constructors
Image(string)
Initializes a new instance of the Aspose.Note.Image class.
public Image(string path)
{
}
Parameters
path
string
A string that contains the path to the file from which to create the Aspose.Note.Image.
Image(string, string, string)
Initializes a new instance of the Aspose.Note.Image class.
public Image(string path, string altTitle, string altDescription = null)
{
}
Parameters
path
string
A string that contains the path to the file from which to create the Aspose.Note.Image.
altTitle
string
The alternative title.
altDescription
string
The alternative description.
Image(string, Stream)
Initializes a new instance of the Aspose.Note.Image class.
public Image(string fileName, Stream imageStream)
{
}
Parameters
fileName
string
A name of the image.
imageStream
Stream
A stream which contains the image.
Image()
Initializes a new instance of the Aspose.Note.Image class.
public Image()
{
}
Properties
Alignment
Gets or sets the alignment.
public HorizontalAlignment Alignment
{
get;
set;
}
Property Value
Examples
Shows how to add an image from file to a document with user defined properties.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document(dataDir + "Aspose.one");
Aspose.Note.Page page = doc.FirstChild;
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Width = 100,
Height = 100,
HorizontalOffset = 100,
VerticalOffset = 400,
Alignment = Aspose.Note.HorizontalAlignment.Right
};
page.AppendChildLast(image);
Shows how to add an image from stream to a document.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document();
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"))
{
Aspose.Note.Image image1 = new Aspose.Note.Image(doc, "Penguins.jpg", fs)
{
Alignment = HorizontalAlignment.Right
};
outlineElem1.AppendChildLast(image1);
}
outline1.AppendChildLast(outlineElem1);
page.AppendChildLast(outline1);
doc.AppendChildLast(page);
dataDir += "BuildDocAndInsertImageUsingImageStream_out.one";
doc.Save(dataDir);
Shows how to add an image from file to a document.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Alignment = HorizontalAlignment.Right
};
outlineElem.AppendChildLast(image);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "BuildDocAndInsertImage_out.one";
doc.Save(dataDir);
AlternativeTextDescription
Gets or sets a body an alternative text for the image.
public string AlternativeTextDescription
{
get;
set;
}
Property Value
Examples
Shows how to set text description for an image.
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 += "ImageAlternativeText_out.one";
document.Save(dataDir);
AlternativeTextTitle
Gets or sets a title of alternative text for the image.
public string AlternativeTextTitle
{
get;
set;
}
Property Value
Examples
Shows how to set text description for an image.
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 += "ImageAlternativeText_out.one";
document.Save(dataDir);
Bytes
Gets the image data store.
public byte[] Bytes
{
get
{
}
}
Property Value
byte []
Examples
Shows how to get an image from a document.
string dataDir = RunExamples.GetDataDir_Images();
Document oneFile = new Document(dataDir + "Aspose.one");
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))
{
bitMap.Save(String.Format(dataDir + "{0}", Path.GetFileName(image.FileName)));
}
}
}
FileName
Gets the file name.
public string FileName
{
get
{
return _fileName;
}
}
Property Value
Examples
Shows how to get image’s meta information.
string dataDir = RunExamples.GetDataDir_Images();
Document oneFile = new Document(dataDir + "Aspose.one");
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();
}
FilePath
Gets the path to the image file.
public string FilePath
{
get;
}
Here is the re-formatted C# code according to standard conventions for proper indentation, spacing, and general readability improvements:
public string FilePath
{
get;
}
As per your requirements, this formatting engine does not modify or remove code comments, rename any variables, methods, classes, or types, change or remove namespaces, alter logic or behavior in any way, add any output beyond the raw C# code, assume any library-specific knowledge, or return code fences (e.g., ```csharp), no explanations, and no conversational text.
Property Value
Format
Gets the image’s format.
public ImageFormat Format
{
get
{
return _format;
}
}
In this reformatted version, I've maintained proper indentation, added braces for the property getter, and adjusted spacing for readability.
Property Value
Height
Gets or sets the height. This is the real height of the image in the MS OneNote document.
public float Height
{
get;
private set;
}
Property Value
Examples
Shows how to get image’s meta information.
string dataDir = RunExamples.GetDataDir_Images();
Document oneFile = new Document(dataDir + "Aspose.one");
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();
}
Shows how to add an image from file to a document with user defined properties.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document(dataDir + "Aspose.one");
Aspose.Note.Page page = doc.FirstChild;
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Width = 100,
Height = 100,
HorizontalOffset = 100,
VerticalOffset = 400,
Alignment = HorizontalAlignment.Right
};
page.AppendChildLast(image);
HorizontalOffset
Gets or sets the horizontal offset.
public float HorizontalOffset
{
get;
private set;
}
Property Value
Examples
Shows how to add an image from file to a document with user defined properties.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document(dataDir + "Aspose.one");
Aspose.Note.Page page = doc.FirstChild;
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Width = 100,
Height = 100,
HorizontalOffset = 100,
VerticalOffset = 400,
Alignment = HorizontalAlignment.Right
};
page.AppendChildLast(image);
HyperlinkUrl
Gets or sets the hyperlink associated with the image.
public string HyperlinkUrl
{
get;
set;
}
Property Value
Examples
Shows how to bind a hyperlink to an image.
var 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
Gets whether the image is a background image.
public bool IsBackground
{
get;
private set;
}
Property Value
LastModifiedTime
Gets or sets last modified time.
public DateTime LastModifiedTime
{
get;
private set;
}
Property Value
Examples
Shows how to get image’s meta information.
Aspose.Words.Document oneFile = new Aspose.Words.Document(dataDir + "Aspose.one");
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();
}
Here's the code with consistent indentation and spacing:
Aspose.Words.Document oneFile = new Aspose.Words.Document(dataDir + "Aspose.one");
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();
}
OriginalHeight
Gets the original height. This is the original width of the image, before resizing.
public float OriginalHeight
{
get
{
}
}
Property Value
Examples
Shows how to get image’s meta information.
string dataDir = RunExamples.GetDataDir_Images();
Aspose.Words.Document oneFile = new Aspose.Words.Document(dataDir + "Aspose.one");
var images = oneFile.GetChildNodes<aspose.note.Image>();
foreach (var 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();
}
OriginalWidth
Gets the original width. This is the original width of the image, before resizing.
public float OriginalWidth
{
get
{
}
}
Property Value
Examples
Shows how to get image’s meta information.
string dataDir = RunExamples.GetDataDir_Images();
Aspose.Words.Document oneFile = new Aspose.Words.Document(dataDir + "Aspose.one");
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();
}
Tags
Gets the list of all tags of a paragraph.
public List<ITag> Tags { get; }
Property Value
Examples
Shows how to add new image with tag.
string dataDir = RunExamples.GetDataDir_Tags();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "icon.jpg");
outlineElem.AppendChildLast(image);
image.Tags.Add(NoteTag.CreateYellowStar());
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "AddImageNodeWithTag_out.one";
doc.Save(dataDir);
VerticalOffset
Gets or sets the vertical offset.
public float VerticalOffset
{
get;
private set;
}
Property Value
Examples
Shows how to add an image from file to a document with user defined properties.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document(dataDir + "Aspose.one");
Aspose.Note.Page page = doc.FirstChild;
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Width = 100,
Height = 100,
HorizontalOffset = 100,
VerticalOffset = 400,
Alignment = Aspose.Note.HorizontalAlignment.Right
};
page.AppendChildLast(image);
Width
Gets or sets the width. This is the real width of the image in the MS OneNote document.
public float Width
{
get;
private set;
}
Property Value
Examples
Shows how to get image’s meta information.
string dataDir = RunExamples.GetDataDir_Images();
Document oneFile = new Document(dataDir + "Aspose.one");
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();
}
Shows how to add an image from file to a document with user defined properties.
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document(dataDir + "Aspose.one");
Aspose.Note.Page page = doc.FirstChild;
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Width = 100,
Height = 100,
HorizontalOffset = 100,
VerticalOffset = 400,
Alignment = HorizontalAlignment.Right
};
page.AppendChildLast(image);
Methods
Accept(DocumentVisitor)
Accepts the visitor of the node.
public override void Accept(DocumentVisitor visitor)
{
}
Parameters
visitor
DocumentVisitor
The object of a class derived from the Aspose.Note.DocumentVisitor.
Replace(Image)
Replaces the current image data with the data from the provided Image object.
public void Replace(Image newImage)
{
}
Parameters
newImage
Image
The Image object containing the new data.