Class: kodi::addon::CInstanceImageDecoder
Image decoder add-on instance
This instance type is used to allow Kodi various additional image format types.
More...
|
| | 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 |
| | Load an image from a memory buffer.
|
| |
| virtual bool | kodi::addon::CInstanceImageDecoder::Decode (uint8_t *pixels, size_t pixelBufferSize, unsigned int width, unsigned int height, unsigned int pitch, ADDON_IMG_FMT format)=0 |
| | Decode previously loaded image.
|
| |
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"
library_@PLATFORM@="@LIBRARY_FILENAME@">
<support>
<mimetype name="image/mymimea">
<extension>.imga</extension>
<description>30100</description>
<icon>resources/file_format_icon_a.png</icon>
</mimetype>
<mimetype name="image/mymimeb">
<extension>.imgb</extension>
<description>30101</description>
<icon>resources/file_format_icon_b.png</icon>
</mimetype>
</support>
</extension>
<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 <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.
- Note
- Required to use about info support by CInstanceImageDecoder::SupportsFile and CInstanceImageDecoder::ReadTag!
|
Example:
{
public:
size_t bufSize,
unsigned int&
height)
override;
size_t pixelBufferSize,
...
};
{
...
}
bool CMyImageDecoder::LoadImageFromMemory(
const std::string&
mimetype,
size_t bufSize,
{
...
return true;
}
size_t pixelBufferSize,
{
...
return true;
}
{
public:
CMyAddon() = default;
};
{
{
}
else if (...)
{
...
}
}
unsigned __int8 uint8_t
Definition DirectXGraphics.h:130
void * KODI_ADDON_INSTANCE_HDL
Definition addon_base.h:122
#define ATTR_DLL_LOCAL
Definition addon_base.h:86
KODI_ADDON_HDL * hdl
Definition addon_base.h:346
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:776
Definition kodi-dev-kit/include/kodi/addon-instance/imagedecoder.h:541
virtual ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo &instance, KODI_ADDON_INSTANCE_HDL &hdl)
Definition kodi-dev-kit/include/kodi/AddonBase.h:579
Definition kodi-dev-kit/include/kodi/AddonBase.h:502
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition addon_base.h:188
ADDON_STATUS
Definition addon_base.h:139
@ ADDON_STATUS_OK
For everything OK and no error.
Definition addon_base.h:141
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition addon_base.h:153
@ ADDON_INSTANCE_IMAGEDECODER
Image decoder instance, see kodi::addon::CInstanceImageDecoder.
Definition versions.h:252
ADDON_IMG_FMT
Definition kodi-dev-kit/include/kodi/c-api/addon-instance/imagedecoder.h:30
virtual bool LoadImageFromMemory(const std::string &mimetype, const uint8_t *buffer, size_t bufSize, unsigned int &width, unsigned int &height)=0
Load an image from a memory buffer.
virtual bool Decode(uint8_t *pixels, size_t pixelBufferSize, unsigned int width, unsigned int height, unsigned int pitch, ADDON_IMG_FMT format)=0
Decode previously loaded image.
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:1939
#define ADDONCREATOR(AddonClass)
Definition kodi-dev-kit/include/kodi/AddonBase.h:2048
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 * mimetype
Definition kodi-dev-kit/include/kodi/c-api/addon-instance/imagedecoder.h:413
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:269
The destruction of the example class CMyImageDecoder is called from Kodi's header. Manually deleting the add-on instance is not required.
◆ CInstanceImageDecoder()
| kodi::addon::CInstanceImageDecoder::CInstanceImageDecoder |
( |
const IInstanceInfo & | instance | ) |
|
|
inlineexplicit |
Class constructor.
- Parameters
-
◆ Decode()
| virtual bool kodi::addon::CInstanceImageDecoder::Decode |
( |
uint8_t * | pixels, |
|
|
size_t | pixelBufferSize, |
|
|
unsigned int | width, |
|
|
unsigned int | height, |
|
|
unsigned int | pitch, |
|
|
ADDON_IMG_FMT | format ) |
|
pure virtual |
Decode previously loaded image.
- Parameters
-
| [out] | pixels | Output buffer |
| [in] | pixelBufferSize | Size of the output buffer in bytes |
| [in] | width | Width of output image |
| [in] | height | Height of output image |
| [in] | pitch | Byte offset between the start of one output row and the next |
| [in] | format | Format of output image |
- Returns
- true if successful done, false on error
- Note
- The buffer holds
height rows of pitch bytes, pixelBufferSize in total. pitch already accounts for format, so an add-on that writes a fixed number of bytes per pixel regardless of format will overrun the buffer for any format narrower than the one it assumes. Return false for a format the add-on does not implement rather than falling through to a default.
◆ 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 |
Load an image from a memory buffer.
- Parameters
-
| [in] | mimetype | The mimetype wanted from Kodi |
| [in] | buffer | The data to read from memory |
| [in] | bufSize | The buffer size |
| [in,out] | width | Upper bound for the width on entry, the width actually produced on return |
| [in,out] | height | Upper bound for the height on entry, the height actually produced on return |
- Returns
- true if successful done, false on error
- Note
width and height are a maximum, not a request. Kodi passes the renderer's maximum texture size here when the caller has no preferred size, so returning them unchanged as the image's natural size can ask for an allocation of several thousand pixels square. Report the size the image actually has.
◆ ReadTag()
Read tag of a file.
- Parameters
-
| [in] | file | File to read tag for |
| [out] | tag | Information tag about |
- Returns
- True on success, false on failure
The following table contains values that can be set with class ImageDecoderInfoTag :
◆ SupportsFile()
| virtual bool kodi::addon::CInstanceImageDecoder::SupportsFile |
( |
const std::string & | filename | ) |
|
|
inlinevirtual |
Checks addon support given file path.
- Parameters
-
| [in] | filename | The file to read |
- Returns
- true if successfully done and supported, otherwise false
- Note
- Optional to add, as default becomes
true used.