Image Control: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Jmarshall
No edit summary
(44 intermediate revisions by 13 users not shown)
Line 1: Line 1:
The image control is used for displaying images in XBMC. You can choose the position, size, transparency and contents of the image to be displayed.
{{mininav| [[Skinning]] }}
===Example===
<section begin="main content" />
<xml>
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 ===
<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>
       <left>80</left>
       <posy>60</posy>
       <top>60</top>
       <width>250</width>
       <width>250</width>
       <height>200</height>
       <height>200</height>
       <visible>true</visible>
       <visible>true</visible>
       <colordiffuse>FFFFFFFF</colordiffuse>
       <colordiffuse>FFFFFFFF</colordiffuse>
       <colorkey>FFFF00FF</colorkey>
       <fadetime>200</fadetime>
       <texture border="5" flipY="true" flipX="false">mytexture.png</texture>
       <texture border="5" flipy="true" flipx="false">mytexture.png</texture>
       <info>MusicPlayer.Cover</info>
       <bordertexture border="5">mybordertexture.png</bordertexture>
      <bordersize>5</bordersize>
       <aspectratio>keep</aspectratio>
       <aspectratio>keep</aspectratio>
</control>
</control>
</xml>
</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 should be as close as possible to the nearest highest power of 2 in width and height. The reason for this is XBMC uses swizzled textures which are quicker to render and quicker to load once they're compressed into the Textures.xpr file. Note that the image does not need to be square, and will not be scaled into a power of 2 size. Rather, any pixels outside of a power of two size will simply be dead space (wasted memory). If you cannot manage this, then XBMCTex will opt for a linear (non-swizzled) texture format which must be aligned to 64 pixels in the horizontal, but has no restrictions in the vertical direction.  These are <b>slightly</b> slower to load and render, but for the most part there's not a lot of difference. The XBMCTex program that does the image injection into Textures.xpr will tell you what format it's using, and how much pixel wastage (memory waste) is contained in each image.


====Formats====
If you wish to use full 8 bit transparency, then use PNG. If you only need a single transparent colour, then you can specify this in the <colorkey> tag, so any image will be fine. It is suggested that you use PNG and JPG as much as possible. Note that once the images are injected into Textures.xpr, they are not stored as JPG or PNG – rather they are stored in a xbox native format for faster loading. 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 only support 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.
=== 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.
 


===Available Tags===
=== Formats ===
Note that each tag is '''lower case only.''' This is important, as xml tags are case-sensitive.
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.


{| class="dtable" border="0"
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.
|- class="userrow"
 
| class="usercell" | <strong>description</strong>
 
| class="usercell" | Only used to make things clear for the skinner. Not read by XBMC at all.
=== Available tags and attributes ===
|- class="userrow"
In addition to the [[Default Control Tags|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.
| class="usercell" | <strong>type</strong>
 
| class="usercell" | Should be image for an image control.
{| class="prettytable"
|- class="userrow"
! Tag !! Description
| class="usercell" | <strong>id</strong>
|-  
| class="usercell" | Specifies the control's id. The value this takes depends on the control type, and the window that you are using the control on. There are special control id's that must be present in each window. Any other controls that the skinner adds can be any id they like. Most image controls can be id 0 or id 1, as the only information they display is specified either in the <texture> or <info> tags.
| '''aspectratio'''
|- class="userrow"
| This specifies how the image will be drawn inside the box defined by <code><width></code> and <code><height></code>. [[Aspect Ratio|See here for more information]].
| class="usercell" | <strong>posx</strong>
|-  
| class="usercell" | Specifies where the left edge of the image should be drawn. This is offset from the window's coordinates (normally the left edge of the screen, or 0).
| '''texture'''
|- class="userrow"
| Specifies the image file which should be displayed. [[Texture Attributes|See here for additional information about textures.]]
| class="usercell" | <strong>posy</strong>
|-  
| class="usercell" | Specifies where the top edge of the image should be drawn. This is offset from the window's coordinates (normally the top edge of the screen, or 0).
| '''bordertexture'''
|- class="userrow"
| 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.
| class="usercell" | <strong>width</strong>
|-  
| class="usercell" | Specifies the width that should be used to draw the image. The image will be resized to fit into this width.
| '''bordersize'''
|- class="userrow"
| 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.
| class="usercell" | <strong>height</strong>
|-  
| class="usercell" | Specifies the height that should be used to draw the image. The image will be resized to fit into this height.
| '''info'''
|- class="userrow"
| Specifies the information that this image control is presenting. Kodi will select the texture to use based on this tag. [[InfoLabels|See here for&nbsp;more information.]]
| class="usercell" | <strong>visible</strong>
|-  
| class="usercell" | Specifies a condition as to when this control will be visible. Can be true, false, or a condition. [[Conditional Visibility|See here for&nbsp;more information.]] Defaults to true.
| '''fadetime'''
|- class="userrow"
| 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.
| class="usercell" | <strong>animation</strong>
|-  
| class="usercell" | Specifies the animation to be run when the control enters a particular state. [[Animating Your Skin|See here for more information]]
| '''background'''
|- class="userrow"
| For images inside a container, you can specify background="true" to load the textures in a background worker thread.
| class="usercell" | <strong>aspectratio</strong>
| class="usercell" | This specifies how the image will be drawn inside the box defined by <width> and <height>. When set to “keep” the images aspect ratio will be kept, and the image will be resized to fit inside the <width>,<height> box (with transparent bars if the ratios are not the same). When set to “stretch”, the image will be stretched to <width> by <height> pixels (it's aspect ratio will therefore be lost). When set to “scale” then the box will be resized so that it completely fills the <width>,<height> box and any portions of the image outside the box will be cropped off.
|- class="userrow"
| class="usercell" | <strong>texture</strong>
| class="usercell" | Specifies the image file which should be displayed. You can use animated gif's, jpgs, pngs, or bmps. This should be the path to the image file from the media/ folder of your skin directory. XBMC will first look inside the compresses Textures.xpr file, and if not found, will look inside the media/ folder for the actual skin file. Compressing textures into Textures.xpr means far faster loading times.
|- class="userrow"
| class="usercell" | <strong>info</strong>
| class="usercell" | Specifies the information that this image control is presenting. XBMC will select the texture to use based on this tag. [[InfoLabels|See here for&nbsp;more information.]]
|- class="userrow"
| class="usercell" | <strong>colordiffuse</strong>
| class="usercell" | TThis specifies the color to be used for the texture basis. It's in hex AARRGGBB format. If you define <colordiffuse>FFFF00FF</colordiffuse> (magenta), the image will be given a magenta tint when rendered. Defaults to FFFFFFFF (no tint).
|- class="userrow"
| class="usercell" | <strong>colorkey</strong>
| class="usercell" | This specifies the color in the image file that should be considered transparent. All pixels of this colour will be replaced by transparent black. Defaults to 0 (none)
|}
|}
[[category:Skin Development]]
 
 
=== 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" />
 
 
[[Category:Skin development]]

Revision as of 01:12, 10 January 2021

Home icon grey.png   ▶ Skinning ▶ Image Control

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>
      <left>80</left>
      <top>60</top>
      <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>
      <aspectratio>keep</aspectratio>
</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.
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.


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.