當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript image-source.ImageSource類代碼示例

本文整理匯總了TypeScript中tns-core-modules/image-source.ImageSource的典型用法代碼示例。如果您正苦於以下問題:TypeScript ImageSource類的具體用法?TypeScript ImageSource怎麽用?TypeScript ImageSource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ImageSource類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: imageSourceFromAsset

export function imageSourceFromAsset(imageAsset){
    let source = new imageSource.ImageSource();
     source.fromAsset(imageAsset).then((source) => {
         let folder = fs.knownFolders.documents().path;
         let fileName = "test.png"
         let path = fs.path.join(folder, fileName);
         let saved = source.saveToFile(path, "png");
         if(saved){
            console.log("saved image")
         }
     })
}
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:12,代碼來源:image-source-snippet.ts

示例2:

 .then((imageAsset) => {
     let source = new imageSource.ImageSource();
     source.fromAsset(imageAsset).then((source) => {
       this.imageCropper.show(source,{width:100,height:100}).then((args) => {
         if(args.image !== null){
           this.imageUrl = args.image;
         }
       })
       .catch(function(e){
         console.log(e);
       });                     
     });
 }).catch((err) => {
開發者ID:bthurlow,項目名稱:nativescript-imagecropper,代碼行數:13,代碼來源:app.component.ts

示例3: function

          const onResult = function(args) {
            const requestCode = args.requestCode;
            const resultCode = args.resultCode;
            const data = args.intent;
            // var _that = this;

            if (resultCode === android.app.Activity.RESULT_OK && requestCode === com.yalantis.ucrop.UCrop.REQUEST_CROP) {
              const resultUri: android.net.Uri = com.yalantis.ucrop.UCrop.getOutput(data);
              const is: ImageSource = new ImageSource();
              try {
                is.setNativeSource(android.graphics.BitmapFactory.decodeFile(resultUri.getPath()));
              } catch (e) {
                console.error(e);
              }
              ImageCropper._cleanFiles();
              application.android.off(application.AndroidApplication.activityResultEvent, onResult);
              if (is.android) {
                resolve({
                  response: "Success",
                  image: is,
                });
              } else {
                reject({
                  response: "Error",
                  image: null
                });
              }
              return;
            }
            else if (resultCode === android.app.Activity.RESULT_CANCELED && requestCode === com.yalantis.ucrop.UCrop.REQUEST_CROP) {
              ImageCropper._cleanFiles();
              application.android.off(application.AndroidApplication.activityResultEvent, onResult);
              resolve({
                response: "Cancelled",
                image: null
              });
              return;
            }
            else if (resultCode === com.yalantis.ucrop.UCrop.RESULT_ERROR) {
              ImageCropper._cleanFiles();
              const cropError: java.lang.Throwable = com.yalantis.ucrop.UCrop.getError(data);
              console.log(cropError.getMessage());
              application.android.off(application.AndroidApplication.activityResultEvent, onResult);
              reject({
                response: "Error",
                image: null
              });
              return;
            }
          };
開發者ID:bthurlow,項目名稱:nativescript-imagecropper,代碼行數:50,代碼來源:imagecropper.android.ts

示例4: constructor

 constructor() {
     super();
     let asset = new imageAssetModule.ImageAsset("~/splashscreen.png");
     asset.options = {
         width: 300,
         height: 300,
         keepAspectRatio: true
     };
     let source = new ImageSource();
     source.fromAsset(asset).then((source) => {
         this.set("cameraImageAsset", asset);
         this.set("cameraImageSrc", source);
     }, (error) => {
         console.log(error);
     });
 }
開發者ID:NathanWalker,項目名稱:NativeScript,代碼行數:16,代碼來源:view-model.ts

示例5: _storeImageSource

  private static _storeImageSource(image: ImageSource): string {
    const folder: fs.Folder = fs.knownFolders.temp();
    const path = fs.path.join(folder.path, "temp.jpeg");

    if (image.saveToFile(path, "jpeg", 100)) {
      return path;
    }
    else {
      return null;
    }
  }
開發者ID:bthurlow,項目名稱:nativescript-imagecropper,代碼行數:11,代碼來源:imagecropper.android.ts

示例6: done

    imageSource.fromAsset(asset).then((source) => {
        TKUnit.assertEqual(source.width, scaleWidth);
        TKUnit.assertEqual(source.height, scaleHeight);

        const targetFilename = `splashscreenTemp.png`;
        const tempPath = fs.knownFolders.temp().path;
        const localFullPath = fs.path.join(tempPath, targetFilename);

        const fullImageSaved = source.saveToFile(localFullPath, "png");

        if (fullImageSaved) {
            let sourceImage = new imageSource.ImageSource();
            sourceImage.fromFile(localFullPath).then(() => {
                TKUnit.assertEqual(sourceImage.width, scaleWidth);
                TKUnit.assertEqual(sourceImage.height, scaleHeight);
                done();
            });
        } else {
            done(`Error saving photo to local temp folder: ${localFullPath}`);
        }
    }, (error) => {
開發者ID:NathanWalker,項目名稱:NativeScript,代碼行數:21,代碼來源:image-source-tests.ts

示例7: onSrcPropertySet

  public static onSrcPropertySet(nativeWrapper, value) {


    let image = nativeWrapper,
      placeholder = nativeWrapper.placeholder,
      placeholderImage = this.getPlaceholderUIImage(placeholder);
    if (types.isString(value)) {
      value = value.trim();
      if (0 === value.indexOf("http")) {
        image.isLoading = true;
        image.nativeView.sd_setImageWithURLPlaceholderImageCompleted(value, placeholderImage, function() {
          image.isLoading = false;

        });
      } else if (utils.isFileOrResourcePath(value)) {
        image.isLoading = true;
        let source: any = new imageSource.ImageSource();

        if (0 === value.indexOf(utils.RESOURCE_PREFIX)) {
          let path = value.substr(utils.RESOURCE_PREFIX.length);
          source.fromResource(path).then(function() {
            image.isLoading = false;
            image.nativeView.image = source.ios || source.nativeView;
          });
        } else {
          source.fromFile(value).then(function() {
            image.isLoading = false;
            image.nativeView.image = source.ios || source.nativeView;
          });
        }

      }
      image.requestLayout();
    }

  }
開發者ID:VideoSpike,項目名稱:nativescript-web-image-cache,代碼行數:36,代碼來源:helpers.ts


注:本文中的tns-core-modules/image-source.ImageSource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。