Maps SDK for C++ 1.0.0
Loading...
Searching...
No Matches
gem::Image Class Reference

Image object. More...

Inheritance diagram for gem::Image:
Collaboration diagram for gem::Image:

Public Member Functions

 Image (const DataBuffer &data, int format)
 Create an image object from a data buffer in a specific format formats currently supported are enumerated in EImageFileFormat.
 Image (const DataBuffer &data, int format, const Size &size)
 Create an image object from a data buffer in a specific format and resize it to the requested dimensions formats currently supported are enumerated in EImageFileFormat.
 Image (const String &path)
 Create an image object from a given file path.
 Image (const String &path, const Size &size)
 Create an image object from a given file path and resize it to the requested dimensions.
 Image (int id)
 Create an image object from an image id.
 Image (const Image &)=default
 Default copy constructor.
 Image (Image &&)=default
 Default move constructor noexcept is deduced.
Image & operator= (const Image &image)=default
 Default copy assignment.
Image & operator= (Image &&image)=default
 Default move assignment noexcept is deduced.
bool operator== (const Image &img) const noexcept
 Equal operator.
unsigned getType () const noexcept
 Get the type of the image, see EImageType.
unsigned getUid () const noexcept
 Get the unique ID of the image.
int render (IBitmap &bitmap) const noexcept
 Render the Image into the provided IBitmap.
Size getSize () const noexcept
 Get the preferred size of the image.
SizeF getAspectRatio () const noexcept
 Get the icon aspect ratio as pair of ( width_aspect, height_aspect ).
float getAspectRatioF () const noexcept
 Get the icon aspect ratio as a direct raport width / height.
bool isScalable () const noexcept
 Check if icon is scalable ( i.e.
bool isValid () const noexcept
 Check the validity of the Image.
template<typename TSpecializedImage>
TSpecializedImage & cast () noexcept
 Cast to specialized image.
template<typename TSpecializedImage>
const TSpecializedImage & cast () const noexcept
 Cast to const specialized image.
DataBuffer exportAs (const Size &size, int format) const noexcept
 Export image as a data buffer in the specified format.
int exportAs (const Size &size, int format, const String &path) const noexcept
 Export image to a file in the specified format.

Protected Member Functions

template<typename ... TArgs>
StrongPointer< IBitmaprenderTo (const Size &size, TArgs &&... args) const noexcept
 Render the Image into a new IBitmap of the specified size, using the provided additional arguments if needed.
template<typename ... TArgs>
DataBuffer exportTo (const Size &size, int format, TArgs &&... args) const noexcept
 Export image to a data buffer or file in the specified format, using the provided additional arguments if needed.
template<typename ... TArgs>
int exportTo (const Size &size, int format, const String &path, TArgs &&... args) const noexcept
 Export image to a file in the specified format, using the provided additional arguments if needed.

Detailed Description

Image object.

Implements share-read / copy-on-write Api object over IIcon.

Constructor & Destructor Documentation

◆ Image() [1/5]

gem::Image::Image ( const DataBuffer & data,
int format )
inline

Create an image object from a data buffer in a specific format formats currently supported are enumerated in EImageFileFormat.

Parameters
dataData buffer containing the image
formatData buffer format, see EImageFileFormat

◆ Image() [2/5]

gem::Image::Image ( const DataBuffer & data,
int format,
const Size & size )
inline

Create an image object from a data buffer in a specific format and resize it to the requested dimensions formats currently supported are enumerated in EImageFileFormat.

Parameters
dataData buffer containing the image
formatData buffer format, see EImageFileFormat
sizeImage desired size

◆ Image() [3/5]

gem::Image::Image ( const String & path)
inline

Create an image object from a given file path.

Parameters
pathImage file path. Must be an image file in one of the supported file formats, see EImageFileFormat

◆ Image() [4/5]

gem::Image::Image ( const String & path,
const Size & size )
inline

Create an image object from a given file path and resize it to the requested dimensions.

Parameters
pathImage file path. Must be an image file in one of the supported file formats, see EImageFileFormat
sizeThe side of the image.

◆ Image() [5/5]

gem::Image::Image ( int id)

Create an image object from an image id.

Parameters
idId of image.

Member Function Documentation

◆ cast() [1/2]

template<typename TSpecializedImage>
const TSpecializedImage & gem::Image::cast ( ) const
inlinenoexcept

Cast to const specialized image.

Returns
Specialized image

◆ cast() [2/2]

template<typename TSpecializedImage>
TSpecializedImage & gem::Image::cast ( )
inlinenoexcept

Cast to specialized image.

Returns
Specialized image

◆ exportAs() [1/2]

DataBuffer gem::Image::exportAs ( const Size & size,
int format ) const
inlinenoexcept

Export image as a data buffer in the specified format.

Parameters
[in]sizeThe exported image size in pixels
[in]formatThe exported image format, see EImageFileFormat
Returns
Data buffer containing the image in the specified format

◆ exportAs() [2/2]

int gem::Image::exportAs ( const Size & size,
int format,
const String & path ) const
inlinenoexcept

Export image to a file in the specified format.

Parameters
[in]sizeThe exported image size in pixels
[in]formatThe exported image format, see EImageFileFormat
[in]pathThe file path where to save the image
Returns
The opration result code

◆ exportTo() [1/2]

template<typename ... TArgs>
int gem::Image::exportTo ( const Size & size,
int format,
const String & path,
TArgs &&... args ) const
inlineprotectednoexcept

Export image to a file in the specified format, using the provided additional arguments if needed.

Parameters
[in]sizeThe exported image size in pixels
[in]formatThe exported image format, see EImageFileFormat
[in]pathThe file path where to save the image
[in]argsAdditional arguments to be forwarded to the Render function, if needed by the specific image type
Returns
The opration result code

◆ exportTo() [2/2]

template<typename ... TArgs>
DataBuffer gem::Image::exportTo ( const Size & size,
int format,
TArgs &&... args ) const
inlineprotectednoexcept

Export image to a data buffer or file in the specified format, using the provided additional arguments if needed.

Parameters
[in]sizeThe exported image size in pixels
[in]formatThe exported image format, see EImageFileFormat
[in]argsAdditional arguments to be forwarded to the Render function, if needed by the specific image type
Returns
If exporting to data buffer, returns the data buffer containing the image in the specified format.

◆ getAspectRatio()

SizeF gem::Image::getAspectRatio ( ) const
inlinenoexcept

Get the icon aspect ratio as pair of ( width_aspect, height_aspect ).

If width > height return { width / height, 1.f ) If width < height return { 1.f, height / width )

Returns
The aspect ratio of the image

◆ getAspectRatioF()

float gem::Image::getAspectRatioF ( ) const
inlinenoexcept

Get the icon aspect ratio as a direct raport width / height.

Returns
The aspect ratio of the image

◆ getSize()

Size gem::Image::getSize ( ) const
inlinenoexcept

Get the preferred size of the image.

Returns
The preferred size of the image

◆ getType()

unsigned gem::Image::getType ( ) const
inlinenoexcept

Get the type of the image, see EImageType.

Returns
The type of the image

◆ getUid()

unsigned gem::Image::getUid ( ) const
inlinenoexcept

Get the unique ID of the image.

Returns
The unique ID of the image

◆ isScalable()

bool gem::Image::isScalable ( ) const
inlinenoexcept

Check if icon is scalable ( i.e.

it has vectorial format )

Returns
True if the image is scalable, false otherwise

◆ isValid()

bool gem::Image::isValid ( ) const
inlinenoexcept

Check the validity of the Image.

Returns
True if the image is valid, false otherwise

◆ operator=() [1/2]

Image & gem::Image::operator= ( const Image & image)
default

Default copy assignment.

Parameters
imageOther image
Returns
Reference to this object

◆ operator=() [2/2]

Image & gem::Image::operator= ( Image && image)
default

Default move assignment noexcept is deduced.

Parameters
imageOther image
Returns
Reference to this object

◆ operator==()

bool gem::Image::operator== ( const Image & img) const
inlinenoexcept

Equal operator.

Parameters
imgOther image.
Returns
True if the images are equal, false otherwise.

◆ render()

int gem::Image::render ( IBitmap & bitmap) const
inlinenoexcept

Render the Image into the provided IBitmap.

Parameters
[in]bitmapThe IBitmap object where to render the image
Returns
KNoError on success. KNotSupported in case of unsupported encoding.

◆ renderTo()

template<typename ... TArgs>
StrongPointer< IBitmap > gem::Image::renderTo ( const Size & size,
TArgs &&... args ) const
inlineprotectednoexcept

Render the Image into a new IBitmap of the specified size, using the provided additional arguments if needed.

Parameters
[in]sizeThe size of the bitmap to render into
[in]argsAdditional arguments to be forwarded to the Render function, if needed by the specific image type
Returns
A StrongPointer to the rendered IBitmap, or an empty StrongPointer if rendering failed.