【问题标题】:How to set imageview.toImage() as html image src in webview?如何在 webview 中将 imageview.toImage() 设置为 html 图像 src?
【发布时间】:2013-06-24 11:05:44
【问题描述】:

在 webview 的 html 中将 imageview.toImage() 设置为 img src 的任何想法。

假设我有一个 imageview(其中有一些图像)。好吧 imageview.toimage() 被视为钛中的图像对象。现在我需要的是我想设置

webview.html='<html><img src="here i want to put obove imageview.toimage()"></html>';

我尝试了很多方法,请有经验的人指导我。

问候:阿里

【问题讨论】:

    标签: android iphone image webview titanium


    【解决方案1】:

    将其保存到文件并分配文件的 url 路径或 base64Encode 图像并将其作为 src 参数的值提供

    【讨论】:

    • 嗨 Aron 我做了这样的事情。 var img= Titanium.Filesystem.applicationDataDirectory + Ti.Filesystem.separator + 'newflower.jpg'; aWebView.html='';但它显示 webview 为空。但是当我将 img 分配给图像视图时工作正常。请指导我是什么问题。谢谢。
    • 尝试把图片和html文件放在同一个目录下看看是否可行,完全不要设置路径
    【解决方案2】:

    您可以尝试将图像转换为 base64 blob 文本并将其用作 css 背景图像数据:

    background-image:url('data:image/png;base64,'+Ti.Utils.base64encode(imageview.toImage()).getText()+'\');
    

    【讨论】:

      猜你喜欢
      • 2013-10-08
      • 1970-01-01
      • 2012-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-29
      • 1970-01-01
      • 2013-04-23
      相关资源
      最近更新 更多