Renamed image module to image-source. Extended the testRunner to accept module name to run.

This commit is contained in:
atanasovg
2014-05-15 16:13:33 +03:00
parent 9a0fb96d62
commit c946c24ae2
17 changed files with 75 additions and 71 deletions

View File

@ -0,0 +1,33 @@
export var fromResource = function (name: string) {
return UIKit.UIImage.imageNamed(name);
}
export var fromFile = function (path: string) {
return UIKit.UIImage.imageWithContentsOfFile(path);
}
export var fromData = function (data: any) {
return UIKit.UIImage.imageWithData(data);
}
export var saveToFile = function (instance: UIKit.UIImage, path: string, format: number, quality?: number): boolean {
if (!instance) {
return false;
}
var res = false;
var data = null;
switch (format) {
case 0: // PNG
data = UIKit.UIImagePNGRepresentation(instance);
break;
case 1: // JPEG
data = UIKit.UIImageJPEGRepresentation(instance, ('undefined' == typeof quality) ? 1.0 : quality);
break;
}
if (null != data) {
res = data.writeToFileAtomically(path, true);
}
return res;
}