LuciadCPillar 2024.0.08
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
luciad::ImageIcon Class Referencefinal

Helper class for loading JPEG or PNG files. More...

#include <luciad/drawing/ImageIcon.h>

Classes

class  Builder
 Builder which takes images as input to create an IIcon. More...
 

Public Member Functions

 ImageIcon ()=delete
 

Static Public Member Functions

static std::shared_ptr< IIconcreate (const std::string &filePath)
 Create an IIcon from a PNG or JPEG file. More...
 
static Builder newBuilder ()
 Creates a Builder which allows to construct an IIcon based on 1 or more images. More...
 
static std::shared_ptr< IIcontoIcon (const std::shared_ptr< luciad::Image > &image)
 Converts an Image to an Icon. More...
 

Detailed Description

Helper class for loading JPEG or PNG files.

Since
2020.2

Constructor & Destructor Documentation

◆ ImageIcon()

luciad::ImageIcon::ImageIcon ( )
delete

Member Function Documentation

◆ create()

static std::shared_ptr< IIcon > luciad::ImageIcon::create ( const std::string &  filePath)
static

Create an IIcon from a PNG or JPEG file.

Will throw a RuntimeError if the file does not contain any valid data or if the file format could not be recognized.

It accepts icon files with following naming convention.

  • The base icon at display scale 1 is named <name>.<ext> where <ext> is PNG or JPEG.
  • The icon at display scale f is named <name>@<f>x.<ext>. f is typically a value like 2 or 4. See the article on high DPI for additional information.
Parameters
filePatha file path
Returns
an IIcon from a PNG or JPEG file
Exceptions
luciad::RuntimeExceptionif the file does not contain any valid data or if the file format could not be recognized.

◆ newBuilder()

static Builder luciad::ImageIcon::newBuilder ( )
static

Creates a Builder which allows to construct an IIcon based on 1 or more images.

Returns
the builder.
Since
2023.1

◆ toIcon()

static std::shared_ptr< IIcon > luciad::ImageIcon::toIcon ( const std::shared_ptr< luciad::Image > &  image)
static

Converts an Image to an Icon.

The used display scale is 1. The anchor point of the icon is at the center of the image.

Returns
the IIcon.
Exceptions
luciad::NullArgumentExceptionwhen passing a nullptr value.
Since
2023.1