Using the image source requires the image-source module.
var imageSource = require("image-source");
The pre-required imageSource
module is used throughout the following code snippets.
We also use fs module defined as follows:
var fs = require("file-system");
This is similar to loading Bitmap from R.drawable.logo
on Android or calling [UIImage imageNamed@"logo"]
on iOS
var img = imageSource.fromResource("logo");
imageSource.fromUrl("http://www.google.com/images/errors/logo_sm_2.png").then(function (res) {
console.log("Image successfully loaded");
}).fail(function (error) {
console.log("Error loading image: " + error);
});
var img = imageSource.fromResource("logo");
var folder = fs.knownFolders.documents();
var path = fs.path.join(folder.path, "Test.png");
var saved = img.saveToFile(path, imageSource.ImageFormat.PNG);
var folder = fs.knownFolders.documents();
var path = fs.path.join(folder.path, "Test.png");
var img = imageSource.fromFile(path);