Project1

标题: CG保存为墙纸 [打印本页]

作者: dbshy    时间: 2008-10-3 00:05
标题: CG保存为墙纸
某天,RTS编的卡住了,就跑到论坛上来看看,
就看到提问区有人问到这个东西

完全没技术含量的东西,调试的时候犯了个很无语的错误,感谢IAMI和一路一风程的指教
用法是在是否截图的判断语句下加
Screen::shot
CWP::change
记得把SCREENSHOT.DLL放到游戏目录下,另外在API调用那里自己改图片地址

突然发现有个BUG,无法获得图片地址,大家可以用 Dir.getwd OR Dir.pwd
OR GetModuleFileName 来获得地址,我就懒得加了

  1. =begin

  2.    保存CG为WALLPAPER BY 水蓝
  3.    
  4.    用法是在是否截图的判断语句下加
  5.     Screen::shot
  6.     CWP::change
  7.     记得把SCREENSHOT.DLL放到游戏目录下

  8. =end


  9. module CWP


  10. SPI_SETDESKWALLPAPER = 20

  11. SPIF_UPDATEINIFILE = 0x1

  12. def self.change
  13.    
  14.   $spi = Win32API.new('user32', 'SystemParametersInfo','llpl', 'l')

  15.   $spi.call(SPI_SETDESKWALLPAPER, 0, 'D:\Project88\Graphics\Pictures\screenshot.bmp', SPIF_UPDATEINIFILE)
  16.   
  17. end

  18. end

  19. #==============================================================================
  20. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  21. #============================================================================== #
  22. # Screenshot V2
  23. #
  24. # Screenshot Script v1 & screenshot.dll v1            created by: Andreas21
  25. # Screenshot Script v2                                created/edit by: cybersam
  26. # the autor is found on a german board...
  27. # the comments are added by me...
  28. # since the autor didnt want to add any comment...
  29. # so thats it from here...
  30. # have fund with it... ^-^
  31. #
  32. # oh yea.. the needed command line is found in "Scene_Map" in "def update"
  33. #
  34. #===============================================================================
  35. module Screen  
  36.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  37.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
  38.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  39.   module_function
  40.   #-----------------------------------------------------------------------------
  41.   # here comes the stuff...
  42.   # i add here the stuff for automatic change of the number for the screenshot
  43.   # so it wont overrite the old one...
  44.   # if you want to change so stuff change them in this line below
  45.   # or you can change them in your command line... like
  46.   # Screen::shot("screenshot", 2)
  47.   # this change the name and the type of the screenshot
  48.   # (0 = bmp, 1 = jpg and 2 = png)
  49.   # ----------------------------------------------------------------------------
  50.   def shot(file = "screenshot", typ = 0)
  51.     # to add the right extension...
  52.     if typ == 0
  53.       typname = ".bmp"
  54.     elsif typ == 1
  55.       typname = ".jpg"
  56.     elsif typ == 2
  57.       typname = ".png"
  58.     end   
  59.     file_index = 0   
  60.     dir = "Graphics/Pictures/"   
  61.     # make the filename....
  62.     file_name = dir + file.to_s + typname.to_s   
  63.     # make the screenshot.... Attention dont change anything from here on....
  64.     @screen.call(0,0,640,480,file_name,handel,typ)
  65.   end
  66.   # find the game window...
  67.   def handel
  68.     game_name = "\0" * 256
  69.     @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  70.     game_name.delete!("\0")
  71.     return @findwindow.call('RGSS Player',game_name)
  72.   end
  73. end
复制代码






欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1