Class Image
Represents the functionalities for using images in presentation
Inheritance
System.Object
Image
Namespace: Syncfusion.Drawing
Assembly: Syncfusion.Compression.Portable.dll
Syntax
public class Image : Object
Constructors
Image(Stream)
Initializes a new instance of the Image class with the specified image stream.
Declaration
public Image(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The System.IO.Stream instance of the image. |
Examples
//Create an instance of PowerPoint presentation
IPresentation presentation = Presentation.Create();
//Add a slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create an instance for image as stream
Stream imageStream = File.Open("Image.gif", FileMode.Open);
//Get the image from file path
Image image = new Image(imageStream);
// Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(new MemoryStream(image.ImageData), 120,100,290,200);
//Save the presentation
presentation.Save("Output.pptx");
//close the presentation
presentation.Close();
'Create an instance of PowerPoint presentation
Dim presentation As IPresentation = Presentation.Create()
'Add a slide to the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Create an instance for image as stream
Dim imageStream As Stream = File.Open("Image.gif", FileMode.Open)
'Get the image from file path
Dim image As New Image(imageStream)
' Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(New MemoryStream(image.ImageData), 120, 100, 290, 200)
'Save the presentation
presentation.Save("Output.pptx")
'close the presentation
presentation.Close()
Properties
Format
Gets the image format. Read-only.
Declaration
public ImageFormat Format { get; }
Property Value
Type | Description |
---|---|
ImageFormat | The image format. |
Examples
//Create an instance of PowerPoint presentation
IPresentation presentation = Presentation.Create();
//Add a slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create an instance for image as stream
Stream imageStream = File.Open("Image.gif", FileMode.Open);
//Get the image from file path
Image image = Image.FromStream(imageStream);
//Get the image format, read only
ImageFormat imageFormat = image.Format;
//Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(new MemoryStream(image.ImageData), 300, 270, 410, 250);
//Save the presentation
presentation.Save("Output.pptx");
//close the presentation
presentation.Close();
'Create an instance of PowerPoint presentation
Dim presentation As IPresentation = Presentation.Create()
'Add a slide to the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Create an instance for image as stream
Dim imageStream As Stream = File.Open("Image.gif", FileMode.Open)
'Get the image from file path
Dim image As Image = Image.FromStream(imageStream)
'Get the image format, read only
Dim imageFormat As ImageFormat = image.Format
'Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(New MemoryStream(image.ImageData), 300, 270, 410, 250)
'Save the presentation
presentation.Save("Output.pptx")
'close the presentation
presentation.Close()
Height
Gets the height of the Image. Read-only.
Declaration
public int Height { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The height. |
Examples
//Create an instance of PowerPoint presentation
IPresentation presentation = Presentation.Create();
//Add a slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create an instance for image as stream
Stream imageStream = File.Open("Image.gif", FileMode.Open);
//Get the image from file path
Image image = Image.FromStream(imageStream);
//Get the size of image, it is read only
int Height = image.Height;
int width = image.Width;
//Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(new MemoryStream(image.ImageData), 300, 270, 410, 250);
//Save the presentation
presentation.Save("Output.pptx");
//close the presentation
presentation.Close();
'Create an instance of PowerPoint presentation
Dim presentation As IPresentation = Presentation.Create()
'Add a slide to the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Create an instance for image as stream
Dim imageStream As Stream = File.Open("Image.gif", FileMode.Open)
'Get the image from file path
Dim image As Image = Image.FromStream(imageStream)
'Get the size of image, it is read only
Dim Height As Integer = image.Height
Dim width As Integer = image.Width
'Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(New MemoryStream(image.ImageData), 300, 270, 410, 250)
'Save the presentation
presentation.Save("Output.pptx")
'close the presentation
presentation.Close()
ImageData
Gets the image data as byte array. Read-only.
Declaration
public byte[] ImageData { get; }
Property Value
Type | Description |
---|---|
System.Byte[] | The image data. |
Examples
//Create an instance of PowerPoint presentation
IPresentation presentation = Presentation.Create();
//Add a slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create an instance for image as stream
Stream imageStream = File.Open("Image.gif", FileMode.Open);
//Get the image from file path
Image image = Image.FromStream(imageStream);
//Get the image data of image
byte[] imageData = image.ImageData;
//Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(new MemoryStream(imageData), 300, 270, 410, 250);
//Save the presentation
presentation.Save("Output.pptx");
//close the presentation
presentation.Close();
'Create an instance of PowerPoint presentation
Dim presentation As IPresentation = Presentation.Create()
'Add a slide to the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Create an instance for image as stream
Dim imageStream As Stream = File.Open("Image.gif", FileMode.Open)
'Get the image from file path
Dim image As Image = Image.FromStream(imageStream)
'Get the image data of image
Dim imageData As Byte() = image.ImageData
'Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(New MemoryStream(imageData), 300, 270, 410, 250)
'Save the presentation
presentation.Save("Output.pptx")
'close the presentation
presentation.Close()
RawFormat
Gets the file format of the Image. Read-only.
Declaration
public ImageFormat RawFormat { get; }
Property Value
Type | Description |
---|---|
ImageFormat | The image format. |
Examples
//Create an instance of PowerPoint presentation
IPresentation presentation = Presentation.Create();
//Add a slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create an instance for image as stream
Stream imageStream = File.Open("Image.gif", FileMode.Open);
//Get the image from file path
Image image = Image.FromStream(imageStream);
//Get the image format, read only
ImageFormat imageFormat = image.RawFormat;
//Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(new MemoryStream(image.ImageData), 300, 270, 410, 250);
//Save the presentation
presentation.Save("Output.pptx");
//close the presentation
presentation.Close();
'Create an instance of PowerPoint presentation
Dim presentation As IPresentation = Presentation.Create()
'Add a slide to the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Create an instance for image as stream
Dim imageStream As Stream = File.Open("Image.gif", FileMode.Open)
'Get the image from file path
Dim image As Image = Image.FromStream(imageStream)
'Get the image format, read only
Dim imageFormat As ImageFormat = image.RawFormat
'Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(New MemoryStream(image.ImageData), 300, 270, 410, 250)
'Save the presentation
presentation.Save("Output.pptx")
'close the presentation
presentation.Close()
Size
Gets the width and height of the image. Read-only.
Declaration
public Size Size { get; }
Property Value
Type | Description |
---|---|
Size | The size. |
Examples
//Create an instance of PowerPoint presentation
IPresentation presentation = Presentation.Create();
//Add a slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create an instance for image as stream
Stream imageStream = File.Open("Image.gif", FileMode.Open);
//Get the image from file path
Image image = Image.FromStream(imageStream);
//Get the size of image, it is read only
System.Drawing.Size size = image.Size;
//Set the width and height of the image
size.Width = 300;
size.Width = 200;
//Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(new MemoryStream(image.ImageData), 120,100,size.Width,size.Height);
//Save the presentation
presentation.Save("Output.pptx");
//close the presentation
presentation.Close();
'Create an instance of PowerPoint presentation
Dim presentation As IPresentation = Presentation.Create()
'Add a slide to the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Create an instance for image as stream
Dim imageStream As Stream = File.Open("Image.gif", FileMode.Open)
'Get the image from file path
Dim image As Image = Image.FromStream(imageStream)
'Get the size of image, it is read only
Dim size As System.Drawing.Size = image.Size
'Set the width and height of the image
size.Width = 300
size.Width = 200
'Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(New MemoryStream(image.ImageData), 120, 100, size.Width, size.Height)
'Save the presentation
presentation.Save("Output.pptx")
'close the presentation
presentation.Close()
Width
Gets the width of the Image. Read-only.
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The width. |
Examples
//Create an instance of PowerPoint presentation
IPresentation presentation = Presentation.Create();
//Add a slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create an instance for image as stream
Stream imageStream = File.Open("Image.gif", FileMode.Open);
//Get the image from file path
Image image = Image.FromStream(imageStream);
//Get the size of image, it is read only
int Height = image.Height;
int width = image.Width;
// Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(new MemoryStream(image.ImageData), 300, 270, 410, 250);
//Save the presentation
presentation.Save("Output.pptx");
//close the presentation
presentation.Close();
'Create an instance of PowerPoint presentation
Dim presentation As IPresentation = Presentation.Create()
'Add a slide to the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Create an instance for image as stream
Dim imageStream As Stream = File.Open("Image.gif", FileMode.Open)
'Get the image from file path
Dim image As Image = Image.FromStream(imageStream)
'Get the size of image, it is read only
Dim Height As Integer = image.Height
Dim width As Integer = image.Width
' Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(New MemoryStream(image.ImageData), 300, 270, 410, 250)
'Save the presentation
presentation.Save("Output.pptx")
'close the presentation
presentation.Close()
Methods
Clone()
Creates an independent copy of the specified image.
Declaration
public Image Clone()
Returns
Type | Description |
---|---|
Image | The Image this method creates. |
Examples
//Create an instance of PowerPoint presentation
IPresentation presentation = Presentation.Create();
//Add a slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create an instance for image as stream
Stream imageStream = File.Open("Image.gif", FileMode.Open);
//Get the image from file path
Image image = Image.FromStream(imageStream);
//Clone the image
Image clonedImage = image.Clone();
// Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(new MemoryStream(clonedImage.ImageData), 300, 270, 410, 250);
//Save the presentation
presentation.Save("Image.pptx");
//close the presentation
presentation.Close();
'Create an instance of PowerPoint presentation
Dim presentation As IPresentation = Presentation.Create()
'Add a slide to the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Create an instance for image as stream
Dim imageStream As Stream = File.Open("Image.gif", FileMode.Open)
'Get the image from file path
Dim image As Image = Image.FromStream(imageStream)
'Clone the image
Dim clonedImage As Image = image.Clone()
' Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(New MemoryStream(clonedImage.ImageData), 300, 270, 410, 250)
'Save the presentation
presentation.Save("Image.pptx")
'close the presentation
presentation.Close()
FromStream(Stream)
Creates an Image from the specified stream.
Declaration
public static Image FromStream(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | A System.IO.Stream that contains the data for this Image. |
Returns
Type | Description |
---|---|
Image | Returns the Image this method creates. |
Examples
//Create an instance of PowerPoint presentation
IPresentation presentation = Presentation.Create();
//Add a slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create an instance for image as stream
Stream imageStream = File.Open("Image.gif", FileMode.Open);
//Get the image from file path
Image image = Image.FromStream(imageStream);
// Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(new MemoryStream(image.ImageData), 300, 270, 410, 250);
//Save the presentation
presentation.Save("Image.pptx");
//close the presentation
presentation.Close();
'Create an instance of PowerPoint presentation
Dim presentation As IPresentation = Presentation.Create()
'Add a slide to the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Create an instance for image as stream
Dim imageStream As Stream = File.Open("Image.gif", FileMode.Open)
'Get the image from file path
Dim image As Image = Image.FromStream(imageStream)
' Add the image to the slide by specifying position and size
slide.Pictures.AddPicture(New MemoryStream(image.ImageData), 300, 270, 410, 250)
'Save the presentation
presentation.Save("Image.pptx")
'close the presentation
presentation.Close()
FromStream(Stream, Boolean, Boolean)
Declaration
public static Image FromStream(Stream stream, bool p, bool p3)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
System.Boolean | p | |
System.Boolean | p3 |
Returns
Type |
---|
Image |