用ruby处理显示图像

时间:2015-01-04 07:21:35

标签: ruby processing

所以我在github和其他地方看到的所有样本看起来都很简单,但遗憾的是我无法通过ruby处理显示一个简单的图像。任何帮助将不胜感激。

我的代码:

attr_reader :img

def setup
  size(600, 600)
  @img = loadImage("chess.jpg")
end

def draw
  image(@img, 10, 10)
end

代码在〜/ RP-image / scratchpad.rb中jpg位于〜/ RP-image / data / chess.jpg 我已经尝试了load_image loadimage loadImage等的每个排列,我在终端得到了响应:

The file "chess.jpg" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
Java::JavaLang::NullPointerException

processing.core.PGraphics.image(processing/core/PGraphics.java:3572)
processing.core.PApplet.image(processing/core/PApplet.java:12773)
java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:483)
RUBY.draw(image-scratchpad.rb:8)
processing.core.PApplet.handleDraw(processing/core/PApplet.java:2386)
processing.core.PGraphicsJava2D.requestDraw(processing/core/PGraphicsJava2D.java:240)
processing.core.PApplet.run(processing/core/PApplet.java:2256)
java.lang.Thread.run(java/lang/Thread.java:745)

据我所知,除了使用loadimage命令加载图像外,您不需要“向草图添加图像”。

0 个答案:

没有答案