Difference between revisions of "Image Control"

From Official Kodi Wiki
Jump to navigation Jump to search
Line 33: Line 33:
|- class="userrow"
|- class="userrow"
| class="usercell" | <strong>aspectratio</strong>
| 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.  When set to "keep", the image can be aligned within the <width>,<height> box using the align attribute. For example, <aspectratio align="right">keep</aspectratio> will align the image on the righthand edge of the <width>,<height> box, and it will be centered vertically, whereas <aspectratio align="bottom">keep</aspectratio> will align the image on the bottom edge, centered horizontally.  Finally, the scalediffuse="false" attribute can be used to specify that the diffuse texture should not be scaled with the image, i.e. that the diffuse texture should apply to the <width>,<height> box, regardless of the aspect of the main texture.  This allows (for instance) the bounding box region to be masked off by the diffuse texture regardless of the image placement.
| class="usercell" | This specifies how the image will be drawn inside the box defined by <width> and <height>. [[Aspect Ratio|See here for more information]].
|- class="userrow"
|- class="userrow"
| class="usercell" | <strong>texture</strong>
| class="usercell" | <strong>texture</strong>

Revision as of 08:15, 5 October 2009

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.

1 Example

<xml> <control type="image" id="1">

     <description>My first image control</description>
     <texture border="5" flipY="true" flipX="false">mytexture.png</texture>

</control> </xml>

2 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:

2.1 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 slightly 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.

2.2 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.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.

3 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.

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,right,top,bottom values.
info Specifies the information that this image control is presenting. XBMC 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 underline <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.