FileImageSource Class
Specifies an image file as a data source to be displayed by an Image element.
The file pointed to by the File
property will be added to the app as a bundle file automatically.
Example
This example displays an image from the file kitten.jpg
:
<Image>
<FileImageSource File="kitten.jpg" />
</Image>
Referencing from JavaScript
When building your project, Fuse needs to know which files to bundle with the app. Since UX is statically compiled, it will automatically bundle files whose path is hard-coded in one of the UX files in your project.
However, if the path comes from JavaScript or some other dynamic data source, it cannot automatically be inferred by the compiler.
Thus, we need to explicitly specify it as a bundle file in our .unoproj
:
"Includes": [
"assets/kitten.jpg:Bundle"
]
We can now use JavaScript to specify the path to the image:
<JavaScript>
module.exports = {
image: "assets/kitten.jpg"
}
</JavaScript>
<Image>
<FileImageSource File="{image}" />
</Image>
Location
- Namespace
- Fuse.Resources
- Package
- Fuse.Elements 2.9.1
Interface of FileImageSource
Density : float ux
Specifies the source's pixel density.
File : FileSource ux
FileImageSource Constructor uno
FileImageSource(FileSource) Constructor uno
Policy : MemoryPolicy ux
TargetSize : int2 ux
The Target size of the image to resize.