#gem install RMagick
Installing RMagick for Ruby 1.8.4 on Windows XP
在Windows XP直接 gem install RMagick 會產生錯誤,解決方法:
1. 到 http://rubyforge.org/projects/rmagick/ 直接下載 rmagick-win32 最新版 (ex.RMagick-2.0.0-ImageMagick-6.3.7-8-Q8.zip)
2. 解壓縮後,命令列切換到解壓縮目錄下執行 local gem install (gem install rmagick --local)
3. 安裝DLL檔,執行解壓縮目錄下dll.exe (ex.ImageMagick-6.3.7-8-Q8-windows-dll.exe)
4. 可到 C:\ruby\lib\ruby\gems\1.8\gems\rmagick-2.0.0-win32\examples 下測試是否安裝成功
require 'wx'
require 'RMagick'
include Magick
include Wx
class MyFrame < Wx::Frame
def initialize(title)
super(nil, -1, title, Point.new(-1,1), Size.new(500,500))
evt_paint { on_paint }
img_file = File.join( File.dirname(__FILE__), 'tmp_new.bmp')
# first load the image into an Image object
image = Wx::Image.new(img_file)
# then create a Bitmap suitable for drawing
@bitmap = Wx::Bitmap.new(image)
end
def on_paint
paint do | dc |
dc.clear
dc.draw_bitmap(@bitmap, 0, 0, false)
end
end
end
class ImagesApp < Wx::App
def on_init
frame = MyFrame.new('Title')
frame.show
end
end
a = ImagesApp.new;
a.main_loop();
消息來源
0 意見:
張貼留言