【问题标题】:how to use MTKTextureLoader newTextureWithContentsOfURL to retrieve an image from the web?如何使用 MTKTextureLoader newTextureWithContentsOfURL 从网上检索图像?
【发布时间】:2020-02-11 12:35:42
【问题描述】:

是否可以使用MTKTextureLoader.newTextureWithContentsOfURL 从网络检索图像(例如:https://i.stack.imgur.com/EwPfY.jpg?s=48&g=1)?我尝试了但我没有成功,所以也许我做错了什么

【问题讨论】:

    标签: ios objective-c macos metal metalkit


    【解决方案1】:

    -newTextureWithContentsOfURL:... 方法旨在用于文件 URL,而不是 Web URL。

    如果你想从网上加载图片,你应该先使用NSURLSessionNSURLDataTask来下载图片内容(异步),然后使用MTKTextureLoader-newTextureWithData:options:error:方法或者它的异步对应方法创建一个MTLTexture

    【讨论】:

      猜你喜欢
      • 2018-12-20
      • 2018-09-08
      • 2020-07-12
      • 1970-01-01
      • 2014-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多