赞 | 0 |
VIP | 133 |
好人卡 | 5 |
积分 | 1 |
经验 | 15036 |
最后登录 | 2017-9-12 |
在线时间 | 190 小时 |
Lv1.梦旅人 彩色的银子
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 190 小时
- 注册时间
- 2006-6-13
- 帖子
- 1361
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
!!!呃``啊``好象发错区了```帮忙转一下``= =```
- #==============================================================================
- # ■ Graphics
- #------------------------------------------------------------------------------
- # 进行有关全体图像处理的模块。
- # RMXP 版的 Graphics.snap_to_bitmap
- #==============================================================================
- class << Graphics
- GetWindowDC = Win32API.new("user32", "GetWindowDC", "l", "l")
- GetDC = Win32API.new("user32", "GetDC", "l", "l")
- GetPrivateProfileString = Win32API.new("kernel32", "GetPrivateProfileStringA", "pppplp", "l")
- FindWindow = Win32API.new("user32", "FindWindowA", "pp", "l" )
- CreateDC = Win32API.new("gdi32", "CreateDC", "pppl", "l")
- CreateCompatibleBitmap = Win32API.new("gdi32", "CreateCompatibleBitmap", "lll", "l")
- CreateCompatibleDC = Win32API.new("gdi32", "CreateCompatibleDC", "l", "l")
- SelectObject = Win32API.new("gdi32", "SelectObject", "ll", "l")
- BitBlt = Win32API.new("gdi32", "BitBlt", "lllllllll", "l")
- GetBitmapBits = Win32API.new("gdi32", "GetBitmapBits", "llp", "l")
- ScreenToClient = Win32API.new("user32", "ScreenToClient", "ip", "i")
- SRCCOPY = 0xCC0020
- #--------------------------------------------------------------------------
- # ● snap_to_bitmap
- # 将当前画面转换为Bitmap对象
- #--------------------------------------------------------------------------
- def snap_to_bitmap
- hb = Bitmap.new(640,480)
- rgbs = self.bitmap_data
- x=y=0
- indexs = [0]
- t1 = Time.now
- for i in indexs
- break if rgbs[i].nil?
- break if rgbs[i+1].nil?
- break if rgbs[i+2].nil?
- break if rgbs[i+3].nil?
- color = Color.new(rgbs[i+2],rgbs[i+1],rgbs[i],rgbs[i+3])
- hb.set_pixel(x,y,color)
- x += 1
- if x == 640
- x = 0
- y += 1
- end
- indexs << i + 4
- end
- t2 = Time.now
- #p t2 - t1
- return hb
- end
- #--------------------------------------------------------------------------
- # ● bitmap_data
- # 获取当前画面的数据部分```
- # RGB依然是调转过来了`= =``
- #--------------------------------------------------------------------------
- def bitmap_data
- hScrDC = CreateDC.call("DISPLAY", "", "", 0)
- hMemDC = CreateCompatibleDC.call(hScrDC)
- hBitmap = CreateCompatibleBitmap.call(hScrDC, 640, 480)
- #BitBlt.call(hDC, 0, 0, 640, 480, hDC(0), 0, 0, SRCCOPY)
- hOldBitmap = SelectObject.call(hMemDC, hBitmap)
- BitBlt.call(hMemDC, xsrc, ysrc, 640*2, 480*2, hScrDC, 0, 0, SRCCOPY)
- hBitmap = SelectObject.call(hMemDC, hOldBitmap)
- dwCount = (640 * 480 * 4) * 2
- lpBits = "\000" * dwCount
- GetBitmapBits.call(hBitmap, dwCount, lpBits)
- lpBits.delete!("\000")
- return lpBits.unpack("C*")
- end
- #--------------------------------------------------------------------------
- # ● 获取DC场景...
- #--------------------------------------------------------------------------
- def hDC(*h)
- if h == []
- return GetWindowDC.call(hWnd)
- else
- return GetDC.call(*h)
- end
- end
- #--------------------------------------------------------------------------
- # ● 用户窗口的位置
- #--------------------------------------------------------------------------
- def xsrc
- return self.point[0]
- end
- #--------------------------------------------------------------------------
- # ● 用户窗口的位置
- #--------------------------------------------------------------------------
- def ysrc
- return self.point[1]
- end
- #--------------------------------------------------------------------------
- # ● 那个点`= =``
- #--------------------------------------------------------------------------
- def point
- point = [0,0].pack("LL")
- ScreenToClient.call(hWnd, point)
- return point.unpack("LL")
- end
- #--------------------------------------------------------------------------
- # ● 窗口句柄
- #--------------------------------------------------------------------------
- def hWnd
- game_name = "\0" * 256
- GetPrivateProfileString.call("Game","Title","",game_name,255,".\\Game.ini")
- game_name.delete!("\0")
- return FindWindow.call("RGSS Player",game_name)
- end
- end
复制代码
看到之前有人问能不能在XP下实现VX的Graphics.snap_to_bitmap
试了一下..然后.这东西就出来了``
就这样吧```
= =```只是理论出品...
因为set_pixel的惊人速度...所以平均一次要4.5秒左右才出来 |
|