How to use the tns-core-modules/image-source.fromNativeSource function in tns-core-modules

To help you get started, we’ve selected a few tns-core-modules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NativeScript / NativeScript / tests / app / ui / image-cache / image-cache-tests.ts View on Github external
export const test_ImageCache_NothingAtProvidedUrl = function () {
    const cache = new imageCacheModule.Cache();
    cache.maxRequests = 5;

    let errorCaught = false;
    let errorMessage: string;

    let imgSource: imageSource.ImageSource;
    const url = "https://github.com/NativeScript-NoImage.png";
    // Try to read the image from the cache
    const image = cache.get(url);
    if (image) {
        // If present -- use it.
        imgSource = imageSource.fromNativeSource(image);
    }
    else {
        // If not present -- request its download.
        cache.push({
            key: url,
            url: url,
            completed: (image: any, key: string) => {
                if (url === key) {
                    imgSource = imageSource.fromNativeSource(image);
                }
            },
            error: (key: string) => {
                console.log("No image for key: ", key);
                errorMessage = `No image for key: ${key}`;
                errorCaught = true;
            }
github charsleysa / nativescript-mdc / src / components / floatingActionButton / floatingActionButton-common.ts View on Github external
}
                        traceWrite(err, traceCategories.Debug);
                    }
                });
            }
        } else if (value instanceof ImageSource) {
            // Support binding the imageSource trough the src property
            this.imageSource = value;
            this.isLoading = false;
        } else if (value instanceof ImageAsset) {
            fromAsset(value).then((result) => {
                this.imageSource = result;
                this.isLoading = false;
            });
        } else {
            this.imageSource = fromNativeSource(value);
            this.isLoading = false;
        }
    }
}
github bradmartin / nativescript-image-filters / src / imagefilters.android.ts View on Github external
return new Promise((resolve, reject) => {
      try {
        if (!img || !degree) {
          reject('Missing required arguments');
        }

        const bmp = this._processor.tintImage(this._getBitmap(img), degree);
        const isrc = fromNativeSource(bmp);
        resolve(isrc);
      } catch (err) {
        reject(err);
      }
    });
  }
github jlooper / nativescript-paint / src / paint.ios.ts View on Github external
return new Promise((resolve, reject) => {
			try {
				const data = this.nativeView.getSketch();
				if (data) {
					resolve(fromNativeSource(data));
				} else {
					reject('Pad is empty.');
				}
			} catch (err) {
				reject(err);
			}
		});
	}
github bradmartin / nativescript-image-filters / src / imagefilters.android.ts View on Github external
return new Promise((resolve, reject) => {
      try {
        if (!img) {
          reject('Image is required');
        }

        const bmp = this._processor.emboss(this._getBitmap(img));
        const isrc = fromNativeSource(bmp);
        resolve(isrc);
      } catch (err) {
        reject(err);
      }
    });
  }
github bradmartin / nativescript-image-filters / src / imagefilters.android.ts View on Github external
return new Promise((resolve, reject) => {
      try {
        if (!img || !watermark) {
          reject('Missing required arguments');
        }

        const bmp = this._processor.waterMark(
          this._getBitmap(img),
          watermark,
          location,
          color,
          alpha,
          size,
          underline
        );
        const isrc = fromNativeSource(bmp);
        resolve(isrc);
      } catch (err) {
        reject(err);
      }
    });
  }
github EddyVerbruggen / nativescript-ar / src / screengrab.android.ts View on Github external
onPixelCopyFinished: (copyResult: number) => {
                    if (copyResult === android.view.PixelCopy.SUCCESS) {
                        resolve(fromNativeSource(bitmap));
                    } else {
                        reject("Field to copy screen image")
                    }
                    handlerThread.quitSafely();
                }
            }), new android.os.Handler(handlerThread.getLooper()));
github NathanaelA / nativescript-exoplayer / src / videoplayer-common.ts View on Github external
value = value.trim();
        video["_url"] = value;
        video.isLoadingProperty = true;
        if (isFileOrResourcePath(value)) {
            video.imageSource = imageSource.fromFileOrResource(value);
            video.isLoadingProperty = false;
        } else {
            if (video["_url"] === value) {
                video.imageSource = imageSource.fromUrl(value);
                video.isLoadingProperty = false;
            }
        }
    } else if (value instanceof imageSource.ImageSource) {
        video.imageSource = value;
    } else {
        video.imageSource = imageSource.fromNativeSource(value);
    }
}
github bradmartin / nativescript-image-filters / src / imagefilters.android.ts View on Github external
return new Promise((resolve, reject) => {
      try {
        if (!img) {
          reject('Image is required');
        }

        const bmp = this._processor.doGreyScale(this._getBitmap(img));
        const isrc = fromNativeSource(bmp);
        resolve(isrc);
      } catch (err) {
        reject(err);
      }
    });
  }
github bradmartin / nativescript-image-filters / src / imagefilters.android.ts View on Github external
return new Promise((resolve, reject) => {
      try {
        if (!img || !shadingColor) {
          reject('Missing required arguments');
        }

        const bmp = this._processor.applyShadingFilter(
          this._getBitmap(img),
          shadingColor
        );
        const isrc = fromNativeSource(bmp);
        resolve(isrc);
      } catch (err) {
        reject(err);
      }
    });
  }