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

TypeScript image-source.fromFile函数代码示例

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

本文整理汇总了TypeScript中tns-core-modules/image-source.fromFile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fromFile函数的具体用法?TypeScript fromFile怎么用?TypeScript fromFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fromFile函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: test_DummyTestForSnippetOnly

export function test_DummyTestForSnippetOnly() {
    // >> image-cache-request-images
    var cache = new imageCacheModule.Cache();
    cache.placeholder = imageSource.fromFile(fs.path.join(__dirname, "res/no-image.png"));
    cache.maxRequests = 5;
    
    // Enable download while not scrolling
    cache.enableDownload();
    
    var imgSouce: imageSource.ImageSource;
    var url = "https://github.com/NativeScript.png";
    // Try to read the image from the cache
    var image = cache.get(url);
    if (image) {
        // If present -- use it.
        imgSouce = imageSource.fromNativeSource(image);
    }
    else {
        // If not present -- request its download.
        cache.push({
            key: url,
            url: url,
            completed: (image: any, key: string) => {
                if (url === key) {
                    imgSouce = imageSource.fromNativeSource(image);
                }
            }
        });
    }

    // Disable download while scrolling
    cache.disableDownload();
    // << image-cache-request-images
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:34,代码来源:image-cache-tests.ts


示例2: testNativeFields

export function testNativeFields() {
    const img = imageSource.fromFile(imagePath);
    if (app.android) {
        TKUnit.assert(img.android != null, "Image.android not updated.");
    } else if (app.ios) {
        TKUnit.assert(img.ios != null, "Image.ios not updated.");
    }
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:8,代码来源:image-source-tests.ts


示例3: testSaveToFile_WithQuality

export function testSaveToFile_WithQuality() {
    const img = imageSource.fromFile(imagePath);
    const folder = fs.knownFolders.documents();
    const path = fs.path.join(folder.path, "test.png");
    const saved = img.saveToFile(path, "png", 70);
    TKUnit.assert(saved, "Image not saved to file");
    TKUnit.assert(fs.File.exists(path), "Image not saved to file");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:8,代码来源:image-source-tests.ts


示例4: testBase64Encode_PNG_WithQuality

export function testBase64Encode_PNG_WithQuality() {
    const img = imageSource.fromFile(smallImagePath);
    let base64String = img.toBase64String("png", 80);
    base64String = base64String.substr(0, expectedPngStart.length);
    TKUnit.assertEqual(
        base64String,
        expectedPngStart,
        "Base 64 encoded PNG");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:9,代码来源:image-source-tests.ts


示例5: testSaveToFile

export function testSaveToFile() {
    // >> imagesource-save-to
    const img = imageSource.fromFile(imagePath);
    const folder = fs.knownFolders.documents();
    const path = fs.path.join(folder.path, "test.png");
    const saved = img.saveToFile(path, "png");
    // << imagesource-save-to
    TKUnit.assert(saved, "Image not saved to file");
    TKUnit.assert(fs.File.exists(path), "Image not saved to file");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:10,代码来源:image-source-tests.ts


示例6: testBase64Encode_PNG

export function testBase64Encode_PNG() {
    const img = imageSource.fromFile(smallImagePath);
    let result = img.toBase64String("png");

    result = result.substr(0, expectedPngStart.length);
    TKUnit.assertEqual(
        result,
        expectedPngStart,
        "Base 64 encoded PNG");
}
开发者ID:triniwiz,项目名称:NativeScript,代码行数:10,代码来源:image-source-tests.ts


示例7: testBase64Encode_JPEG

export function testBase64Encode_JPEG() {
    const img = imageSource.fromFile(smallImagePath);

    let base64String = img.toBase64String("jpeg");
    base64String = base64String.substr(0, expectedJpegStart.length);

    TKUnit.assertEqual(
        base64String,
        expectedJpegStart,
        "Base 64 encoded JPEG");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:11,代码来源:image-source-tests.ts


示例8: testBase64Encode_JPEG

export function testBase64Encode_JPEG() {
    var img = imageSource.fromFile(smallImagePath);

    var result = img.toBase64String("jpeg");
    result = result.substr(0, expectedJpegStart.length);

    TKUnit.assertEqual(
        result,
        expectedJpegStart,
        "Base 64 encoded JPEG");
}
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:11,代码来源:image-source-tests.ts


示例9: testBase64Encode_PNG

export function testBase64Encode_PNG() {
    // >> imagesource-to-base-string
    const img = imageSource.fromFile(smallImagePath);
    let base64String = img.toBase64String("png");
    // << imagesource-to-base-string

    base64String = base64String.substr(0, expectedPngStart.length);
    TKUnit.assertEqual(
        base64String,
        expectedPngStart,
        "Base 64 encoded PNG");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:12,代码来源:image-source-tests.ts


示例10: testFromFile

export function testFromFile() {
    // >> imagesource-load-local
    const folder = fs.knownFolders.documents();
    const path = fs.path.join(folder.path, "test.png");
    const img = imageSource.fromFile(path);
    // << imagesource-load-local

    TKUnit.assert(img.height > 0, "image.fromResource failed");

    // remove the image from the file system
    const file = folder.getFile("test.png");
    file.remove();
    TKUnit.assert(!fs.File.exists(path), "test.png not removed");
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:14,代码来源:image-source-tests.ts



注:本文中的tns-core-modules/image-source.fromFile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript image-source.fromNativeSource函数代码示例发布时间:2022-05-25
下一篇:
TypeScript image-source.fromBase64函数代码示例发布时间: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