Aspose::Words::Drawing::ImageData Class Reference

Defines an image for a shape. More...

#include "Aspose.Words.Cpp/Model/Drawing/ImageData.h"

Inherits IBorderAttrSource.

Public Member Functions

System::ArrayPtr< uint8_t > get_ImageBytes ()
 Gets or sets the raw bytes of the image stored in the shape. More...
 
void set_ImageBytes (System::ArrayPtr< uint8_t > value)
 Setter for Aspose::Words::Drawing::ImageData::get_ImageBytes. More...
 
bool get_HasImage ()
 Returns true if the shape has image bytes or links an image. More...
 
System::SharedPtr< Aspose::Words::Drawing::ImageSizeget_ImageSize ()
 Gets the information about image size and resolution. More...
 
Aspose::Words::Drawing::ImageType get_ImageType ()
 Gets the type of the image. More...
 
bool get_IsLink ()
 Returns true if the image is linked to the shape (when Aspose::Words::Drawing::ImageData::get_SourceFullName is specified). More...
 
bool get_IsLinkOnly ()
 Returns true if the image is linked and not stored in the document. More...
 
System::String get_SourceFullName ()
 Gets or sets the path and name of the source file for the linked image. More...
 
void set_SourceFullName (System::String value)
 Setter for Aspose::Words::Drawing::ImageData::get_SourceFullName. More...
 
System::String get_Title ()
 Defines the title of an image. More...
 
void set_Title (System::String value)
 Setter for Aspose::Words::Drawing::ImageData::get_Title. More...
 
double get_CropTop ()
 Defines the fraction of picture removal from the top side. More...
 
void set_CropTop (double value)
 Setter for Aspose::Words::Drawing::ImageData::get_CropTop. More...
 
double get_CropBottom ()
 Defines the fraction of picture removal from the bottom side. More...
 
void set_CropBottom (double value)
 Setter for Aspose::Words::Drawing::ImageData::get_CropBottom. More...
 
double get_CropLeft ()
 Defines the fraction of picture removal from the left side. More...
 
void set_CropLeft (double value)
 Setter for Aspose::Words::Drawing::ImageData::get_CropLeft. More...
 
double get_CropRight ()
 Defines the fraction of picture removal from the right side. More...
 
void set_CropRight (double value)
 Setter for Aspose::Words::Drawing::ImageData::get_CropRight. More...
 
System::SharedPtr< Aspose::Words::BorderCollectionget_Borders ()
 Gets the collection of borders of the image. Borders only have effect for inline images. More...
 
System::Drawing::Color get_ChromaKey ()
 Defines the color value of the image that will be treated as transparent. More...
 
void set_ChromaKey (System::Drawing::Color value)
 Setter for Aspose::Words::Drawing::ImageData::get_ChromaKey. More...
 
double get_Brightness ()
 Gets or sets the brightness of the picture. The value for this property must be a number from 0.0 (dimmest) to 1.0 (brightest). More...
 
void set_Brightness (double value)
 Setter for Aspose::Words::Drawing::ImageData::get_Brightness. More...
 
double get_Contrast ()
 Gets or sets the contrast for the specified picture. The value for this property must be a number from 0.0 (the least contrast) to 1.0 (the greatest contrast). More...
 
void set_Contrast (double value)
 Setter for Aspose::Words::Drawing::ImageData::get_Contrast. More...
 
bool get_BiLevel ()
 Determines whether an image will be displayed in black and white. More...
 
void set_BiLevel (bool value)
 Setter for Aspose::Words::Drawing::ImageData::get_BiLevel. More...
 
bool get_GrayScale ()
 Determines whether a picture will display in grayscale mode. More...
 
void set_GrayScale (bool value)
 Setter for Aspose::Words::Drawing::ImageData::get_GrayScale. More...
 
System::SharedPtr< System::Collections::Generic::SortedList< Aspose::Words::BorderType, int32_t > > get_PossibleBorderKeys ()
 
void SetImage (System::SharedPtr< System::Drawing::Image > image)
 Sets the image that the shape displays. More...
 
void SetImage (System::SharedPtr< System::IO::Stream > stream)
 Sets the image that the shape displays. More...
 
void SetImage (System::String fileName)
 Sets the image that the shape displays. More...
 
System::SharedPtr< System::Drawing::ImageToImage ()
 Gets the image stored in the shape as a System::Drawing::Image object. More...
 
System::SharedPtr< System::IO::StreamToStream ()
 Creates and returns a stream that contains the image bytes. More...
 
System::ArrayPtr< uint8_t > ToByteArray ()
 Returns image bytes for any image regardless whether the image is stored or linked. More...
 
void Save (System::SharedPtr< System::IO::Stream > stream)
 Saves the image into the specified stream. More...
 
void Save (System::String fileName)
 Saves the image into a file. More...
 
System::SharedPtr< System::ObjectGetDirectBorderAttr (int32_t key)
 
System::SharedPtr< System::ObjectFetchInheritedBorderAttr (int32_t key)
 
void SetBorderAttr (int32_t key, System::SharedPtr< System::Object > value)
 

Detailed Description

Defines an image for a shape.

Use the Aspose::Words::Drawing::Shape::get_ImageData property to access and modify the image inside a shape. You do not create instances of the Aspose::Words::Drawing::ImageData class directly.

An image can be stored inside a shape, linked to external file or both (linked and stored in the document).

Regardless of whether the image is stored inside the shape or linked, you can always access the actual image using the Aspose::Words::Drawing::ImageData::ToByteArray, Aspose::Words::Drawing::ImageData::ToStream, Aspose::Words::Drawing::ImageData::ToImage or Aspose::Words::Drawing::ImageData::Save(System::String) methods. If the image is stored inside the shape, you can also directly access it using the Aspose::Words::Drawing::ImageData::get_ImageBytes property.

To store an image inside a shape use the Aspose::Words::Drawing::ImageData::SetImage(System::String) method. To link an image to a shape, set the Aspose::Words::Drawing::ImageData::get_SourceFullName property.

Member Function Documentation

◆ FetchInheritedBorderAttr()

System::SharedPtr<System::Object> Aspose::Words::Drawing::ImageData::FetchInheritedBorderAttr ( int32_t  key)

◆ get_BiLevel()

bool Aspose::Words::Drawing::ImageData::get_BiLevel ( )

Determines whether an image will be displayed in black and white.

The default value is false.

◆ get_Borders()

System::SharedPtr<Aspose::Words::BorderCollection> Aspose::Words::Drawing::ImageData::get_Borders ( )

Gets the collection of borders of the image. Borders only have effect for inline images.

◆ get_Brightness()

double Aspose::Words::Drawing::ImageData::get_Brightness ( )

Gets or sets the brightness of the picture. The value for this property must be a number from 0.0 (dimmest) to 1.0 (brightest).

The default value is 0.5.

◆ get_ChromaKey()

System::Drawing::Color Aspose::Words::Drawing::ImageData::get_ChromaKey ( )

Defines the color value of the image that will be treated as transparent.

The default value is 0.

◆ get_Contrast()

double Aspose::Words::Drawing::ImageData::get_Contrast ( )

Gets or sets the contrast for the specified picture. The value for this property must be a number from 0.0 (the least contrast) to 1.0 (the greatest contrast).

The default value is 0.5.

◆ get_CropBottom()

double Aspose::Words::Drawing::ImageData::get_CropBottom ( )

Defines the fraction of picture removal from the bottom side.

The amount of cropping can range from -1.0 to 1.0. The default value is 0. Note that a value of 1 will display no picture at all. Negative values will result in the picture being squeezed inward from the edge being cropped (the empty space between the picture and the cropped edge will be filled by the fill color of the shape). Positive values less than 1 will result in the remaining picture being stretched to fit the shape.

The default value is 0.

◆ get_CropLeft()

double Aspose::Words::Drawing::ImageData::get_CropLeft ( )

Defines the fraction of picture removal from the left side.

The amount of cropping can range from -1.0 to 1.0. The default value is 0. Note that a value of 1 will display no picture at all. Negative values will result in the picture being squeezed inward from the edge being cropped (the empty space between the picture and the cropped edge will be filled by the fill color of the shape). Positive values less than 1 will result in the remaining picture being stretched to fit the shape.

The default value is 0.

◆ get_CropRight()

double Aspose::Words::Drawing::ImageData::get_CropRight ( )

Defines the fraction of picture removal from the right side.

The amount of cropping can range from -1.0 to 1.0. The default value is 0. Note that a value of 1 will display no picture at all. Negative values will result in the picture being squeezed inward from the edge being cropped (the empty space between the picture and the cropped edge will be filled by the fill color of the shape). Positive values less than 1 will result in the remaining picture being stretched to fit the shape.

The default value is 0.

◆ get_CropTop()

double Aspose::Words::Drawing::ImageData::get_CropTop ( )

Defines the fraction of picture removal from the top side.

The amount of cropping can range from -1.0 to 1.0. The default value is 0. Note that a value of 1 will display no picture at all. Negative values will result in the picture being squeezed inward from the edge being cropped (the empty space between the picture and the cropped edge will be filled by the fill color of the shape). Positive values less than 1 will result in the remaining picture being stretched to fit the shape.

The default value is 0.

◆ get_GrayScale()

bool Aspose::Words::Drawing::ImageData::get_GrayScale ( )

Determines whether a picture will display in grayscale mode.

The default value is false.

◆ get_HasImage()

bool Aspose::Words::Drawing::ImageData::get_HasImage ( )

Returns true if the shape has image bytes or links an image.

◆ get_ImageBytes()

System::ArrayPtr<uint8_t> Aspose::Words::Drawing::ImageData::get_ImageBytes ( )

Gets or sets the raw bytes of the image stored in the shape.

Setting the value to null or an empty array will remove the image from the shape.

Returns null if the image is not stored in the document (e.g the image is probably linked in this case).

See also
Aspose::Words::Drawing::ImageData::SetImage(System::String), Aspose::Words::Drawing::ImageData::ToByteArray, Aspose::Words::Drawing::ImageData::ToImage
See also
Aspose::Words::Drawing::ImageData::ToStream
See also
Aspose::Words::Drawing::ImageData::Save(System::String)

◆ get_ImageSize()

System::SharedPtr<Aspose::Words::Drawing::ImageSize> Aspose::Words::Drawing::ImageData::get_ImageSize ( )

Gets the information about image size and resolution.

If the image is linked only and not stored in the document, returns zero size.

◆ get_ImageType()

Aspose::Words::Drawing::ImageType Aspose::Words::Drawing::ImageData::get_ImageType ( )

Gets the type of the image.

◆ get_IsLink()

bool Aspose::Words::Drawing::ImageData::get_IsLink ( )

Returns true if the image is linked to the shape (when Aspose::Words::Drawing::ImageData::get_SourceFullName is specified).

◆ get_IsLinkOnly()

bool Aspose::Words::Drawing::ImageData::get_IsLinkOnly ( )

Returns true if the image is linked and not stored in the document.

◆ get_PossibleBorderKeys()

System::SharedPtr<System::Collections::Generic::SortedList<Aspose::Words::BorderType, int32_t> > Aspose::Words::Drawing::ImageData::get_PossibleBorderKeys ( )

◆ get_SourceFullName()

System::String Aspose::Words::Drawing::ImageData::get_SourceFullName ( )

Gets or sets the path and name of the source file for the linked image.

The default value is an empty string.

If Aspose::Words::Drawing::ImageData::get_SourceFullName is not an empty string, the image is linked.

◆ get_Title()

System::String Aspose::Words::Drawing::ImageData::get_Title ( )

Defines the title of an image.

The default value is an empty string.

◆ GetDirectBorderAttr()

System::SharedPtr<System::Object> Aspose::Words::Drawing::ImageData::GetDirectBorderAttr ( int32_t  key)

◆ Save() [1/2]

void Aspose::Words::Drawing::ImageData::Save ( System::SharedPtr< System::IO::Stream stream)

Saves the image into the specified stream.

Parameters
streamThe stream where to save the image to.

Is it the responsibility of the caller to dispose the stream object.

◆ Save() [2/2]

void Aspose::Words::Drawing::ImageData::Save ( System::String  fileName)

Saves the image into a file.

Parameters
fileNameThe file name where to save the image.

◆ set_BiLevel()

void Aspose::Words::Drawing::ImageData::set_BiLevel ( bool  value)

◆ set_Brightness()

void Aspose::Words::Drawing::ImageData::set_Brightness ( double  value)

◆ set_ChromaKey()

void Aspose::Words::Drawing::ImageData::set_ChromaKey ( System::Drawing::Color  value)

◆ set_Contrast()

void Aspose::Words::Drawing::ImageData::set_Contrast ( double  value)

◆ set_CropBottom()

void Aspose::Words::Drawing::ImageData::set_CropBottom ( double  value)

◆ set_CropLeft()

void Aspose::Words::Drawing::ImageData::set_CropLeft ( double  value)

◆ set_CropRight()

void Aspose::Words::Drawing::ImageData::set_CropRight ( double  value)

◆ set_CropTop()

void Aspose::Words::Drawing::ImageData::set_CropTop ( double  value)

◆ set_GrayScale()

void Aspose::Words::Drawing::ImageData::set_GrayScale ( bool  value)

◆ set_ImageBytes()

void Aspose::Words::Drawing::ImageData::set_ImageBytes ( System::ArrayPtr< uint8_t >  value)

◆ set_SourceFullName()

void Aspose::Words::Drawing::ImageData::set_SourceFullName ( System::String  value)

◆ set_Title()

void Aspose::Words::Drawing::ImageData::set_Title ( System::String  value)

◆ SetBorderAttr()

void Aspose::Words::Drawing::ImageData::SetBorderAttr ( int32_t  key,
System::SharedPtr< System::Object value 
)

◆ SetImage() [1/3]

void Aspose::Words::Drawing::ImageData::SetImage ( System::SharedPtr< System::Drawing::Image image)

Sets the image that the shape displays.

Parameters
imageThe image object.

◆ SetImage() [2/3]

void Aspose::Words::Drawing::ImageData::SetImage ( System::SharedPtr< System::IO::Stream stream)

Sets the image that the shape displays.

Parameters
streamThe stream that contains the image.

◆ SetImage() [3/3]

void Aspose::Words::Drawing::ImageData::SetImage ( System::String  fileName)

Sets the image that the shape displays.

Parameters
fileNameThe image file. Can be a file name or a URL.

◆ ToByteArray()

System::ArrayPtr<uint8_t> Aspose::Words::Drawing::ImageData::ToByteArray ( )

Returns image bytes for any image regardless whether the image is stored or linked.

Returns
If the image is linked, downloads the image every time it is called.
See also
Aspose::Words::Drawing::ImageData::get_ImageBytes

◆ ToImage()

System::SharedPtr<System::Drawing::Image> Aspose::Words::Drawing::ImageData::ToImage ( )

Gets the image stored in the shape as a System::Drawing::Image object.

Returns

A new System::Drawing::Image object is created every time this method is called.

It is the responsibility of the caller to dispose the image object.

◆ ToStream()

System::SharedPtr<System::IO::Stream> Aspose::Words::Drawing::ImageData::ToStream ( )

Creates and returns a stream that contains the image bytes.

If the image bytes are stored in the shape, creates and returns a System::IO::MemoryStream object.

If the image is linked and stored in a file, opens the file and returns a System::IO::FileStream object.

If the image is linked and stored in an external URL, downloads the file and returns a System::IO::MemoryStream object.

Is it the responsibility of the caller to dispose the stream object.