Image Control: Difference between revisions
No edit summary |
|||
(10 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{mininav| [[Skinning]] }} | |||
<section begin="main content" /> | <section begin="main content" /> | ||
The image control is used for displaying images in | The image control is used for displaying images in Kodi. You can choose the position, size, transparency and contents of the image to be displayed. | ||
=== Example === | === Example === | ||
<syntaxhighlight lang="xml" enclose="div"> | <syntaxhighlight lang="xml" enclose="div"> | ||
<control type="image" id="1"> | <control type="image" id="1"> | ||
<description>My first image control</description> | <description>My first image control</description> | ||
< | <posx>80</posx> | ||
< | <posy>60</posy> | ||
<width>250</width> | <width>250</width> | ||
<height>200</height> | <height>200</height> | ||
Line 15: | Line 18: | ||
<bordertexture border="5">mybordertexture.png</bordertexture> | <bordertexture border="5">mybordertexture.png</bordertexture> | ||
<bordersize>5</bordersize> | <bordersize>5</bordersize> | ||
<texture>$INFO[MusicPlayer.Cover]</texture> | |||
<aspectratio>keep</aspectratio> | <aspectratio>keep</aspectratio> | ||
<imagefilter>linear</imagefilter> | |||
<diffusefilter>linear</diffusefilter> | |||
</control> | </control> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Image Size and Type Restrictions === | === Image Size and Type Restrictions === | ||
For the <texture> tags, and for all <texture> tags in other controls, there is a small set of rules that you should follow if at all possible: | For the '''<texture>''' tags, and for all '''<texture>''' tags in other controls, there is a small set of rules that you should follow if at all possible: | ||
=== Size === | |||
Images can be any size, though some graphics cards allow only power of 2 textures, so this may be a consideration. For the most case, it doesn't really matter what size things are - Kodi will quite happily load most files. | Images can be any size, though some graphics cards allow only power of 2 textures, so this may be a consideration. For the most case, it doesn't really matter what size things are - Kodi will quite happily load most files. | ||
=== Formats === | |||
If you wish to use transparency, then use PNG. It is suggested that you use PNG and JPG as much as possible. Note that once the images are injected into Textures.xbt, they are not stored as JPG or PNG – rather they are stored in a native format used for GPUs for faster loading, such as ARGB or DXTc textures. The size of the images (in kb) is therefore not as important as the size of the images in pixels – so feel free to store them in a lossless (eg PNG) manner if you wish. | If you wish to use transparency, then use PNG. It is suggested that you use PNG and JPG as much as possible. Note that once the images are injected into Textures.xbt, they are not stored as JPG or PNG – rather they are stored in a native format used for GPUs for faster loading, such as ARGB or DXTc textures. The size of the images (in kb) is therefore not as important as the size of the images in pixels – so feel free to store them in a lossless (eg PNG) manner if you wish. | ||
The only exception to this is if you require an animated texture. In this case, we support only animated GIF. There are also some animated gifs that may not work. Use ImageReady CS and make sure you set the gif-anim to “restore to background” and they should work fine. | The only exception to this is if you require an animated texture. In this case, we support only animated GIF. There are also some animated gifs that may not work. Use ImageReady CS and make sure you set the gif-anim to “restore to background” and they should work fine. | ||
=== Available tags and attributes === | === Available tags and attributes === | ||
Line 42: | Line 51: | ||
|- | |- | ||
| '''bordertexture''' | | '''bordertexture''' | ||
| Specifies the image file which should be displayed as a border around the image. Use the <code><bordersize></code> to specify the size of the border. The <code><width></code>,<code><height></code> box specifies the size of the image plus border. | | Specifies the image file which should be displayed as a border around the image. Use the <code><bordersize></code> to specify the size of the border. The <code><width></code>,<code><height></code> box specifies the size of the image plus border. Set the argument <code>infill="false"</code> to hint to the GUI that the inner portion of the border doesn't have to be rendered. | ||
|- | |- | ||
| '''bordersize''' | | '''bordersize''' | ||
Line 51: | Line 60: | ||
|- | |- | ||
| '''fadetime''' | | '''fadetime''' | ||
| This specifies a crossfade time that will be used whenever the underlying <texture> filename changes. The previous image will be held until the new image is ready, and then they will be crossfaded. This is particularly useful for a large thumbnail image showing the focused item in a list, or for fanart or other large backdrops. | | This specifies a crossfade time that will be used whenever the underlying '''<texture>''' filename changes. The previous image will be held until the new image is ready, and then they will be crossfaded. This is particularly useful for a large thumbnail image showing the focused item in a list, or for fanart or other large backdrops. | ||
|- | |- | ||
| '''background''' | | '''background''' | ||
| For images inside a container, you can specify background="true" to load the textures in a background worker thread. | | For images inside a container, you can specify background="true" to load the textures in a background worker thread. | ||
|- | |||
| '''imagefilter''' | |||
| This can take two values: '''linear''' or '''nearest'''. Linear scaling is the default, and smoothly blurs between pixels. Nearest neighbor scaling will apply a pixelated effect to the image. | |||
|- | |||
| '''diffusefilter''' | |||
| Equivalent of '''imagefilter''' for the diffuse texture. | |||
|} | |} | ||
For the tags "texture" and "bordertexture", the following attributes are available. | |||
{| class="prettytable" | |||
! Tag !! Description | |||
|- | |||
| '''border''' | |||
| Used to specify a region of the texture to be considered a border that should not be scaled when the texture is scaled to fit a control's dimensions. The portion in the border region will remain unscaled. Particularly useful to achieve rounded corners that do not change size when a control is resized. Note that zoom animations and GUI rescaling will still affect the border region - it is just the scaling of the texture to the control size which is unaffected. Using border="5" will give a 5 pixel border all around the texture. You can specify each of the border amounts on each edge individually using border="left,top,right,bottom". | |||
|- | |||
| '''infill''' | |||
| Available if the "border" attribute is used. Hint for the GUI drawing routine if the center portion or just the outer frame should be drawn. Useful if the texture center is fully transparent. Accepts boolean values "true" (default) and "false". | |||
|- | |||
| '''flipx''' | |||
| Specifies that the texture should be flipped in the horizontal direction, useful for reflections. | |||
|- | |||
| '''flipy''' | |||
| Specifies that the texture should be flipped in the vertical direction, useful for reflections. | |||
|- | |||
| '''background''' | |||
| Used on the '''<imagepath>''' tag. When set to "true", this forces the image to be loaded via the large texture manager (except for textures located in Textures.xbt). | |||
|- | |||
| '''diffuse''' | |||
| Specifies a diffuse texture which is "modulated" or multiplied with the texture in order to give specific effects, such as making the image gain transparency, or tint it in various ways. As it's applied per-pixel many effects are possible, the most popular being by a transparent reflection which slowly gets more and more opaque. This is achieved using a WHITE image where the transparency increases as you move down the texture. | |||
|- | |||
| '''colordiffuse''' | |||
| This specifies the color to be used for the texture basis. It's is specified in hexadecimal notation using the AARRGGBB format. If you define '''<texture colordiffuse="FFFFAAFF">texture.png</texture>''' (magenta), the image will be given a magenta tint when rendered. You can also specify this as a name from the colour theme, or you can also use $VAR and $INFO for dynamic values. | |||
|} | |||
=== Texture Loading === | |||
==== Normal texture loading ==== | |||
The only textures loaded by Kodi are the ones currently visible. Nothing displays on the screen until all the images have been loaded in memory, this can result in "jerky" scrolling through panel containers. As you scroll down, Kodi will delay the scrolling animation until all of the images in the next row are loaded. | |||
==== Background loading ==== | |||
Images are loaded one at a time in a background worker thread and are shown as soon as xbmc processes them. Has the benefit that images can be loaded into memory before they're visible, resulting in smoother scrolling and transitions. | |||
==== Preloading ==== | |||
Used to automatically load the next items (or rows/columns in the case of a panel) while scrolling. Currently limited to 2. | |||
<section end="main content" /> | <section end="main content" /> | ||
[[Category:Skin development]] | [[Category:Skin development]] |
Latest revision as of 15:18, 18 July 2025
![]() |
![]() |
![]() |
The image control is used for displaying images in Kodi. You can choose the position, size, transparency and contents of the image to be displayed.
Example
<control type="image" id="1"> <description>My first image control</description> <posx>80</posx> <posy>60</posy> <width>250</width> <height>200</height> <visible>true</visible> <colordiffuse>FFFFFFFF</colordiffuse> <fadetime>200</fadetime> <texture border="5" flipy="true" flipx="false">mytexture.png</texture> <bordertexture border="5">mybordertexture.png</bordertexture> <bordersize>5</bordersize> <texture>$INFO[MusicPlayer.Cover]</texture> <aspectratio>keep</aspectratio> <imagefilter>linear</imagefilter> <diffusefilter>linear</diffusefilter> </control>
Image Size and Type Restrictions
For the <texture> tags, and for all <texture> tags in other controls, there is a small set of rules that you should follow if at all possible:
Size
Images can be any size, though some graphics cards allow only power of 2 textures, so this may be a consideration. For the most case, it doesn't really matter what size things are - Kodi will quite happily load most files.
Formats
If you wish to use transparency, then use PNG. It is suggested that you use PNG and JPG as much as possible. Note that once the images are injected into Textures.xbt, they are not stored as JPG or PNG – rather they are stored in a native format used for GPUs for faster loading, such as ARGB or DXTc textures. The size of the images (in kb) is therefore not as important as the size of the images in pixels – so feel free to store them in a lossless (eg PNG) manner if you wish.
The only exception to this is if you require an animated texture. In this case, we support only animated GIF. There are also some animated gifs that may not work. Use ImageReady CS and make sure you set the gif-anim to “restore to background” and they should work fine.
Available tags and attributes
In addition to the default control tags, the following tags are available. Note that each tag is lower case only. This is important, as xml tags are case-sensitive.
Tag | Description |
---|---|
aspectratio | This specifies how the image will be drawn inside the box defined by <width> and <height> . See here for more information.
|
texture | Specifies the image file which should be displayed. See here for additional information about textures. |
bordertexture | Specifies the image file which should be displayed as a border around the image. Use the <bordersize> to specify the size of the border. The <width> ,<height> box specifies the size of the image plus border. Set the argument infill="false" to hint to the GUI that the inner portion of the border doesn't have to be rendered.
|
bordersize | Specifies the size of the border. A single number specifies the border should be the same size all the way around the image, whereas a comma separated list of 4 values indicates left,top,right,bottom values. |
info | Specifies the information that this image control is presenting. Kodi will select the texture to use based on this tag. See here for more information. |
fadetime | This specifies a crossfade time that will be used whenever the underlying <texture> filename changes. The previous image will be held until the new image is ready, and then they will be crossfaded. This is particularly useful for a large thumbnail image showing the focused item in a list, or for fanart or other large backdrops. |
background | For images inside a container, you can specify background="true" to load the textures in a background worker thread. |
imagefilter | This can take two values: linear or nearest. Linear scaling is the default, and smoothly blurs between pixels. Nearest neighbor scaling will apply a pixelated effect to the image. |
diffusefilter | Equivalent of imagefilter for the diffuse texture. |
For the tags "texture" and "bordertexture", the following attributes are available.
Tag | Description |
---|---|
border | Used to specify a region of the texture to be considered a border that should not be scaled when the texture is scaled to fit a control's dimensions. The portion in the border region will remain unscaled. Particularly useful to achieve rounded corners that do not change size when a control is resized. Note that zoom animations and GUI rescaling will still affect the border region - it is just the scaling of the texture to the control size which is unaffected. Using border="5" will give a 5 pixel border all around the texture. You can specify each of the border amounts on each edge individually using border="left,top,right,bottom". |
infill | Available if the "border" attribute is used. Hint for the GUI drawing routine if the center portion or just the outer frame should be drawn. Useful if the texture center is fully transparent. Accepts boolean values "true" (default) and "false". |
flipx | Specifies that the texture should be flipped in the horizontal direction, useful for reflections. |
flipy | Specifies that the texture should be flipped in the vertical direction, useful for reflections. |
background | Used on the <imagepath> tag. When set to "true", this forces the image to be loaded via the large texture manager (except for textures located in Textures.xbt). |
diffuse | Specifies a diffuse texture which is "modulated" or multiplied with the texture in order to give specific effects, such as making the image gain transparency, or tint it in various ways. As it's applied per-pixel many effects are possible, the most popular being by a transparent reflection which slowly gets more and more opaque. This is achieved using a WHITE image where the transparency increases as you move down the texture. |
colordiffuse | This specifies the color to be used for the texture basis. It's is specified in hexadecimal notation using the AARRGGBB format. If you define <texture colordiffuse="FFFFAAFF">texture.png</texture> (magenta), the image will be given a magenta tint when rendered. You can also specify this as a name from the colour theme, or you can also use $VAR and $INFO for dynamic values. |
Texture Loading
Normal texture loading
The only textures loaded by Kodi are the ones currently visible. Nothing displays on the screen until all the images have been loaded in memory, this can result in "jerky" scrolling through panel containers. As you scroll down, Kodi will delay the scrolling animation until all of the images in the next row are loaded.
Background loading
Images are loaded one at a time in a background worker thread and are shown as soon as xbmc processes them. Has the benefit that images can be loaded into memory before they're visible, resulting in smoother scrolling and transitions.
Preloading
Used to automatically load the next items (or rows/columns in the case of a panel) while scrolling. Currently limited to 2.