• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript image-source.ImageSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript timer.clearInterval函数代码示例发布时间:2022-05-25
下一篇:
TypeScript image-source.fromResource函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap