[dali_1.4.26] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / plugins / dali-script-v8 / docs / content / image.js
1 /**
2  *
3 ## Image API
4
5 An Image object represents a resource that can be added to Material.
6   
7 The image is discarded when all Materials using the Image object are discarded.
8   
9 Note: if a resource was shared between Image objects it exists until its last reference is gone.
10   
11 Image objects are responsible for the underlying resource's lifetime.
12   
13 ### The hierarchy of Image is:
14
15 - {{#crossLink "image"}}Image base class {{/crossLink}} provides basic functionality
16  - {{#crossLink "ResourceImage"}}ResourceImage {{/crossLink}} used for loading image files and nine-patch files
17  - {{#crossLink "BufferImage"}}BufferImage {{/crossLink}} used for generating your own image
18  - {{#crossLink "FrameBufferImage"}}FrameBufferImage {{/crossLink}} contains the result of an 'off screen' render pass of a RenderTask.
19
20   
21 ### Example:
22 ```
23 // Create a resource image with a given URL
24 var image = new dali.ResourceImage( {url: "background.png"} );
25   
26 // Create materials that specifie the visual properties of the renderer.
27 var material1 = new dali.Material();
28 var material2 = new dali.Material();
29   
30 // Add images as texture to be used by the materials
31 material1.addTexture( image, "sTexture" );
32 material2.addTexture( image, "sTexture" );
33
34 ```
35 The API supports functionality such as:
36
37 + {{#crossLink "image/Image:method"}}new dali.ResourceImage{{/crossLink}}
38 + {{#crossLink "image/getWidth:method"}}{{/crossLink}}
39 + {{#crossLink "image/getHeight:method"}}{{/crossLink}}
40   
41 ### 9 patch images
42
43 The Image class also has support for loading 9 patch Images if the filename contains .9.
44 e.g.
45 ```
46 var blackFrame = new dali.ResourceImage( {url:"black-frame.9.png"} );
47 var borderNinePatch = new dali.ResourceImage( {url:"border.9.png"} );
48 ```
49 The nine patch image will scale automatically with the size of the actor.
50   
51 Tool for making 9 patches
52   
53   http://romannurik.github.io/AndroidAssetStudio/nine-patches.html
54   
55 More information on them:
56   
57   http://radleymarx.com/blog/simple-guide-to-9-patch/
58   
59   http://developer.android.com/tools/help/draw9patch.html
60   
61
62
63  @class Image
64  */