【问题标题】:stbi_load Method isn't accepting my parametersstbi_load 方法不接受我的参数
【发布时间】:2021-12-01 12:17:05
【问题描述】:
bi = ImageIO.read(new File(filename));
width = bi.getWidth();
height = bi.getHeight();
            
ByteBuffer data = stbi_load("/sprites/" + filename, width, height, 0, 0);

出于某种原因,stbi_load 不接受方法中的第二个、第三个和第四个参数,即使它们都是有效的整数。它给出了以下错误

The method stbi_load(ByteBuffer, IntBuffer, IntBuffer, IntBuffer, int) in the type STBImage is not applicable for the arguments (String, int, int, int, int).

任何想法为什么会发生这种情况?任何答案表示赞赏

【问题讨论】:

  • 如果我没记错的话你必须使用文件系统路径而不是 claspath

标签: java lwjgl stb-image


【解决方案1】:

能否请您出示stbi_load 方法签名。

也许它需要ByteBufferIntBuffer 类型的参数,而不是您提供的Stringint 类型。

【讨论】:

  • STBImage 类型中的方法 stbi_load(ByteBuffer, IntBuffer, IntBuffer, IntBuffer, int) 不适用于参数(String, int, int, int, int)。那是方法签名,所以它确实需要上面提到的类型,但为什么它要求那些而不是常规字符串和整数?
  • 因为STBImage class 就是这样设计的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-09
  • 2010-09-19
  • 2011-10-01
相关资源
最近更新 更多