diff --git a/src/image.android.ts b/src/image.android.ts index a0db671..956884c 100644 --- a/src/image.android.ts +++ b/src/image.android.ts @@ -679,14 +679,18 @@ export class Img extends ImageBase { } } - private getDrawable(path: string) { + private getDrawable(path: string | ImageSource) { let drawable: android.graphics.drawable.BitmapDrawable; - if (utils.isFileOrResourcePath(path)) { - if (path.indexOf(utils.RESOURCE_PREFIX) === 0) { - drawable = this.getDrawableFromResource(path); - } else { - drawable = this.getDrawableFromLocalFile(path); + if (typeof path === 'string') { + if (utils.isFileOrResourcePath(path)) { + if (path.indexOf(utils.RESOURCE_PREFIX) === 0) { + drawable = this.getDrawableFromResource(path); + } else { + drawable = this.getDrawableFromLocalFile(path); + } } + } else { + drawable = new android.graphics.drawable.BitmapDrawable(path.android); } return drawable; diff --git a/src/image.d.ts b/src/image.d.ts index 810c394..d1e2c01 100644 --- a/src/image.d.ts +++ b/src/image.d.ts @@ -1,4 +1,5 @@ import * as viewModule from 'tns-core-modules/ui/core/view'; +import { ImageSource } from 'tns-core-modules/image-source/image-source'; export const debug: boolean; declare function setDebug(value: boolean) @@ -68,7 +69,7 @@ export class Img extends viewModule.View { /** * String value used for the image URI. */ - src: string; + src: string | ImageSource; /** * String value used for the lower res image URI. @@ -78,12 +79,12 @@ export class Img extends viewModule.View { /** * String value used for the placeholder image URI. */ - placeholderImageUri: string; + placeholderImageUri: string | ImageSource; /** * String value used for the failure image URI. */ - failureImageUri: string; + failureImageUri: string | ImageSource; /** * String value used by Image image scale type. This property can be set to: diff --git a/src/image.ios.ts b/src/image.ios.ts index 7424d5c..0875103 100644 --- a/src/image.ios.ts +++ b/src/image.ios.ts @@ -532,18 +532,19 @@ export class Img extends ImageBase { this.handleImageProgress(totalSize > 0 ? currentSize / totalSize : -1, totalSize); }; - private getUIImage(path: string) { + private getUIImage(path: string | ImageSource) { if (!path) { return null; } let image; - if (utils.isFileOrResourcePath(path)) { - // if (path.indexOf(utils.RESOURCE_PREFIX) === 0) { - // image = imageSource.fromFileOrResource(path); - // } else { - image = fromFileOrResource(path); - // } + if (typeof path === 'string') { + if (utils.isFileOrResourcePath(path)) { + image = fromFileOrResource(path); + } + } else { + image = path; } + // console.log("getUIImage", path, !!image, !!image && !!image.ios); if (image) { image = image.ios;