Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
No Matches

Class: kodi::addon::CInstanceImageDecoder

Image decoder add-on instance
This instance type is used to allow Kodi various additional image format types. More...


 Definitions, structures and enumerators
 Image decoder add-on general variables


 kodi::addon::CInstanceImageDecoder::CInstanceImageDecoder (const IInstanceInfo &instance)
 Class constructor.
virtual bool kodi::addon::CInstanceImageDecoder::SupportsFile (const std::string &filename)
 Checks addon support given file path.
virtual bool kodi::addon::CInstanceImageDecoder::ReadTag (const std::string &file, kodi::addon::ImageDecoderInfoTag &tag)
 Read tag of a file.
virtual bool kodi::addon::CInstanceImageDecoder::LoadImageFromMemory (const std::string &mimetype, const uint8_t *buffer, size_t bufSize, unsigned int &width, unsigned int &height)=0
 Initialize an encoder.
virtual bool kodi::addon::CInstanceImageDecoder::Decode (uint8_t *pixels, unsigned int width, unsigned int height, unsigned int pitch, ADDON_IMG_FMT format)=0
 Decode previously loaded image.

Detailed Description

Class: kodi::addon::CInstanceImageDecoder

Image decoder add-on instance
This instance type is used to allow Kodi various additional image format types.

This usage can be requested under various conditions, by a Mimetype protocol defined in addon.xml or supported file extensions.

Include the header #include <kodi/addon-instance/ImageDecoder.h> to use this class.

Here is an example of what the addon.xml.in would look like for an image decoder addon:

<?xml version="1.0" encoding="UTF-8"?>
name="My image decoder addon"
provider-name="Your Name">
<mimetype name="image/mymimea">
<mimetype name="image/mymimeb">
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">My image decoder addon summary</summary>
<description lang="en_GB">My image decoder description</description>

Standard values that can be declared for processing in addon.xml.

These values are used by Kodi to identify associated images and file extensions and then to select the associated addon.

Labels Type Description
point string The identification of the addon instance to image decoder is mandatory kodi.imagedecoder. In addition, the instance declared in the first <support> is also the main type of addon.
library_@PLATFORM@ string The runtime library used for the addon. This is usually declared by cmake and correctly displayed in the translated addon.xml.
<support>...</support> XML group Contains the formats supported by the addon.
<mimetype name="image/mymimea">...</mimetype> string / group The from addon operated image mimetypes.
Optional can be with <description> and <icon> additional info added where used for list views in Kodi.
<mimetype ...><extension>...</extension></mimetype> string The file extensions / styles supported by this addon and relates to given mimetype before.
Required to use about info support by CInstanceImageDecoder::SupportsFile and CInstanceImageDecoder::ReadTag!
For more detailed description of the addon.xml, see also https://kodi.wiki/view/Addon.xml.


class ATTR_DLL_LOCAL CMyImageDecoder : public kodi::addon::CInstanceImageDecoder
CMyImageDecoder(const kodi::addon::IInstanceInfo& instance);
bool LoadImageFromMemory(const uint8_t* buffer,
size_t bufSize,
unsigned int& width,
unsigned int& height) override;
bool Decode(uint8_t* pixels,
unsigned int width,
unsigned int height,
unsigned int pitch,
ADDON_IMG_FMT format) override;
CMyImageDecoder::CMyImageDecoder(const kodi::addon::IInstanceInfo& instance)
: CInstanceImageDecoder(instance)
bool CMyImageDecoder::LoadImageFromMemory(const uint8_t* buffer,
size_t bufSize,
unsigned int& width,
unsigned int& height)
return true;
bool CMyImageDecoder::Decode(uint8_t* pixels,
unsigned int width,
unsigned int height,
unsigned int pitch,
ADDON_IMG_FMT format) override;
return true;
class ATTR_DLL_LOCAL CMyAddon : public kodi::addon::CAddonBase
CMyAddon() = default;
// If you use only one instance in your add-on, can be instanceType and
// instanceID ignored
ADDON_STATUS CMyAddon::CreateInstance(const kodi::addon::IInstanceInfo& instance,
kodi::Log(ADDON_LOG_INFO, "Creating my image decoder instance");
hdl = new CMyImageDecoder(instance);
else if (...)
unsigned __int8 uint8_t
Definition DirectXGraphics.h:130
Definition addon_base.h:121
Definition addon_base.h:86
Definition addon_base.h:344
uint8_t * buffer
Definition addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audiodecoder.h:116
const char unsigned int int int int int64_t int enum AudioEngineDataFormat * format
Definition addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audiodecoder.h:113
Definition kodi-dev-kit/include/kodi/AddonBase.h:583
Definition kodi-dev-kit/include/kodi/addon-instance/imagedecoder.h:537
virtual ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo &instance, KODI_ADDON_INSTANCE_HDL &hdl)
Definition kodi-dev-kit/include/kodi/AddonBase.h:386
Definition kodi-dev-kit/include/kodi/AddonBase.h:306
1 : To include information messages in the log file.
Definition addon_base.h:187
Definition addon_base.h:138
For everything OK and no error.
Definition addon_base.h:140
Unknown and incomprehensible error.
Definition addon_base.h:152
Image decoder instance, see kodi::addon::CInstanceImageDecoder.
Definition versions.h:245
Definition kodi-dev-kit/include/kodi/c-api/addon-instance/imagedecoder.h:30
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition kodi-dev-kit/include/kodi/AddonBase.h:1746
#define ADDONCREATOR(AddonClass)
Definition kodi-dev-kit/include/kodi/AddonBase.h:1855
uint8_t * pixels
Definition kodi-dev-kit/include/kodi/c-api/addon-instance/imagedecoder.h:420
uint8_t size_t unsigned int unsigned int unsigned int pitch
Definition kodi-dev-kit/include/kodi/c-api/addon-instance/imagedecoder.h:424
const char const uint8_t size_t unsigned int unsigned int * height
Definition kodi-dev-kit/include/kodi/c-api/addon-instance/imagedecoder.h:417
const char const uint8_t size_t unsigned int * width
Definition kodi-dev-kit/include/kodi/c-api/addon-instance/imagedecoder.h:416
Definition addon_base.h:268

The destruction of the example class CMyImageDecoder is called from Kodi's header. Manually deleting the add-on instance is not required.

Function Documentation

◆ CInstanceImageDecoder()

kodi::addon::CInstanceImageDecoder::CInstanceImageDecoder ( const IInstanceInfo & instance)

Class constructor.

[in]instanceThe from Kodi given instance given be add-on CreateInstance call with instance id ADDON_INSTANCE_IMAGEDECODER.

◆ Decode()

virtual bool kodi::addon::CInstanceImageDecoder::Decode ( uint8_t * pixels,
unsigned int width,
unsigned int height,
unsigned int pitch,
ADDON_IMG_FMT format )
pure virtual

Decode previously loaded image.

[in]pixelsOutput buffer
[in]widthWidth of output image
[in]heightHeight of output image
[in]pitchPitch of output image
[in]formatFormat of output image
true if successful done, false on error

◆ LoadImageFromMemory()

virtual bool kodi::addon::CInstanceImageDecoder::LoadImageFromMemory ( const std::string & mimetype,
const uint8_t * buffer,
size_t bufSize,
unsigned int & width,
unsigned int & height )
pure virtual

Initialize an encoder.

[in]mimetypeThe mimetype wanted from Kodi
[in]bufferThe data to read from memory
[in]bufSizeThe buffer size
[in,out]widthThe optimal width of image on entry, obtained width on return
[in,out]heightThe optimal height of image, actual obtained height on return
true if successful done, false on error

◆ ReadTag()

virtual bool kodi::addon::CInstanceImageDecoder::ReadTag ( const std::string & file,
kodi::addon::ImageDecoderInfoTag & tag )

Read tag of a file.

[in]fileFile to read tag for
[out]tagInformation tag about
True on success, false on failure

The following table contains values that can be set with class ImageDecoderInfoTag :

Name Type Set call Get call
Width int SetWidth GetWidth
Height int SetHeight GetHeight
Distance float SetDistance GetDistance
Color enum ADDON_IMG_COLOR SetColor GetColor
Orientation enum ADDON_IMG_ORIENTATION SetOrientation GetOrientation
Metering mode enum ADDON_IMG_METERING_MODE SetMeteringMode GetMeteringMode
Exposure time float SetExposureTime GetExposureTime
Exposure bias float SetExposureBias GetExposureBias
Exposure program enum ADDON_IMG_EXPOSURE_PROGRAM SetExposureProgram GetExposureProgram
Exposure mode enum ADDON_IMG_EXPOSURE_MODE SetExposureMode GetExposureMode
Time created time_t SetTimeCreated GetTimeCreated
Aperture F number float SetApertureFNumber GetApertureFNumber
Flash used ADDON_IMG_FLASH_TYPE SetFlashUsed GetFlashUsed
Light source ADDON_IMG_LIGHT_SOURCE SetLightSource GetLightSource
Focal length int SetFocalLength GetFocalLength
Focal length in 35 mm format int SetFocalLengthIn35mmFormat GetFocalLengthIn35mmFormat
Digital zoom ratio float SetDigitalZoomRatio GetDigitalZoomRatio
ISO sensitivity float SetISOSpeed GetISOSpeed
Camera manufacturer std::string SetCameraManufacturer GetCameraManufacturer
GPS info bool, char, float[3], char, float[3], int, float SetGPSInfo GetGPSInfo
Camera model std::string SetCameraModel GetCameraModel
Author std::string SetAuthor GetAuthor
Description std::string SetDescription GetDescription
Copyright std::string SetCopyright GetCopyright

◆ SupportsFile()

virtual bool kodi::addon::CInstanceImageDecoder::SupportsFile ( const std::string & filename)

Checks addon support given file path.

[in]filenameThe file to read
true if successfully done and supported, otherwise false
Optional to add, as default becomes true used.