【发布时间】:2020-10-29 22:12:51
【问题描述】:
我使用两种方法在金属中加载黑白图像纹理,如下所示:
//1.
mtltexture01 = [textureLoader newTextureWithName:@"texture02"
scaleFactor:1.0
bundle:nil
options:textureLoaderOptions
error:&error];
//2.
UIImage *img = [UIImage imageNamed:@"texture02"];
mtltexture01 = [textureLoader newTextureWithCGImage:img.CGImage options:textureLoaderOptions error:&error];
但是都崩溃了,错误日志是
"错误域=MTKTextureLoaderErrorDomain Code=0"图像解码 failed" UserInfo={NSLocalizedDescription=图像解码失败, MTKTextureLoaderErrorKey=图像解码失败}",
【问题讨论】:
-
建议将第 99 行和第 104 行相互交换(截图中的#)。在 99 中,您从包中加载纹理,然后加载 UIImage,然后再次加载纹理,但从堆栈中加载。你打算为你的加载器做任何一种回退机制吗?
标签: ios objective-c metal