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"?>
<addon
id="imagedecoder.myspecialnamefor"
version="1.0.0"
name="My image decoder addon"
provider-name="Your Name">
<requires>@ADDON_DEPENDS@</requires>
<extension
point="kodi.imagedecoder"
extension=".imga|.imgb"
mimetype="image/mymimea|image/mymimea"
library_@PLATFORM@="@LIBRARY_FILENAME@"/>
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">My image decoder addon summary</summary>
<description lang="en_GB">My image decoder description</description>
<platform>@PLATFORM@</platform>
</extension>
</addon>
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 <extension ... /> is also the main type of addon. |
extension | string | The from addon operated and supported image file endings.
Use a | to separate between different ones. |
defaultPort | string | The from addon operated image mimetypes.
Use a | to separate between different ones. |
library_@PLATFORM@ | string | The runtime library used for the addon. This is usually declared by cmake and correctly displayed in the translated addon.xml . |
Example:
#include <kodi/addon-instance/ImageDecoder.h>
{
public:
CMyImageDecoder(KODI_HANDLE instance, const std::string& kodiVersion);
bool LoadImageFromMemory(unsigned char* buffer,
unsigned int bufSize,
unsigned int& width,
unsigned int& height) override;
bool Decode(unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int pitch,
...
};
CMyImageDecoder::CMyImageDecoder(KODI_HANDLE instance, const std::string& kodiVersion)
: CInstanceImageDecoder(instance, kodiVersion)
{
...
}
bool CMyImageDecoder::LoadImageFromMemory(unsigned char* buffer,
unsigned int bufSize,
unsigned int& width,
unsigned int& height)
{
...
return true;
}
bool CMyImageDecoder::Decode(unsigned char* pixels,
unsigned int width,
unsigned int height,
unsigned int pitch,
{
...
return true;
}
{
public:
CMyAddon() = default;
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance) override;
};
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance)
{
{
addonInstance = new CMyImageDecoder(instance, version);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
Definition: AddonBase.h:322
Definition: ImageDecoder.h:199
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition: addon_base.h:177
ADDON_STATUS
Definition: addon_base.h:128
@ ADDON_STATUS_OK
For everything OK and no error.
Definition: addon_base.h:130
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition: addon_base.h:142
@ ADDON_INSTANCE_IMAGEDECODER
Image Decoder instance, see kodi::addon::CInstanceImageDecoder.
Definition: versions.h:244
ImageFormat
Image format types Used to define wanted target format where image decoder should give to Kodi.
Definition: image_decoder.h:26
void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: AddonBase.h:749
The destruction of the example class CMyImageDecoder
is called from Kodi's header. Manually deleting the add-on instance is not required.
◆ CInstanceImageDecoder()
Class constructor.
- Parameters
-
[in] | instance | The from Kodi given instance given be add-on CreateInstance call with instance id ADDON_INSTANCE_IMAGEDECODER. |
[in] | kodiVersion | [opt] Version used in Kodi for this instance, to allow compatibility to older Kodi versions. |
- Note
- Recommended to set
kodiVersion
.
◆ LoadImageFromMemory()
virtual bool LoadImageFromMemory |
( |
unsigned char * |
buffer, |
|
|
unsigned int |
bufSize, |
|
|
unsigned int & |
width, |
|
|
unsigned int & |
height |
|
) |
| |
|
pure virtual |
Initialize an encoder.
- Parameters
-
[in] | buffer | The data to read from memory |
[in] | bufSize | The buffer size |
[in,out] | width | The optimal width of image on entry, obtained width on return |
[in,out] | height | The optimal height of image, actual obtained height on return |
- Returns
- true if successful done, false on error
◆ Decode()
virtual bool Decode |
( |
unsigned char * |
pixels, |
|
|
unsigned int |
width, |
|
|
unsigned int |
height, |
|
|
unsigned int |
pitch, |
|
|
ImageFormat |
format |
|
) |
| |
|
pure virtual |
Decode previously loaded image.
- Parameters
-
[in] | pixels | Output buffer |
[in] | width | Width of output image |
[in] | height | Height of output image |
[in] | pitch | Pitch of output image |
[in] | format | Format of output image |
- Returns
- true if successful done, false on error
◆ MimeType()
Callback to Kodi Function
Get the wanted mime type from Kodi.
- Returns
- the mimetype wanted from Kodi