module Graphics
RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
BitBlt = Win32API.new('gdi32', 'BitBlt', 'iiiiiiiii', 'i')
CreateCompatibleBitmap = Win32API.new('gdi32', 'CreateCompatibleBitmap', 'iii', 'i')
CreateCompatibleDC = Win32API.new('gdi32', 'CreateCompatibleDC', 'i', 'i')
DeleteObject = Win32API.new('gdi32', 'DeleteObject', 'i', 'i')
GetDIBits = Win32API.new('gdi32', 'GetDIBits', 'iiiiipi', 'i')
SelectObject = Win32API.new('gdi32', 'SelectObject', 'ii', 'i')
SetDIBits = Win32API.new('gdi32', 'SetDIBits', 'iiiiipi', 'i')
hWnd = Win32API.new('user32', 'FindWindow', 'pp', 'i').call('RGSS Player', 0)
DC = Win32API.new('user32', 'GetDC', 'i', 'i').call(hWnd)
def self.snap_to_bitmap
bitmap = Bitmap.new(width=640, height=480)
RtlMoveMemory.call(address="\0"*4, bitmap.__id__*2+16, 4)
RtlMoveMemory.call(address, address.unpack('L')[0]+8, 4)
RtlMoveMemory.call(address, address.unpack('L')[0]+16, 4)
address = address.unpack('L')[0]
info = [40,width,height,1,32,0,0,0,0,0,0].pack('LllSSLLllLL')
hDC = CreateCompatibleDC.call(DC)
hBM = CreateCompatibleBitmap.call(DC, width, height)
DeleteObject.call(SelectObject.call(hDC, hBM))
SetDIBits.call(hDC, hBM, 0, height, address, info, 0)
BitBlt.call(hDC, 0, 0, width, height, DC, 0, 0, 0xCC0020)
GetDIBits.call(hDC, hBM, 0, height, address, info, 0)
DeleteObject.call(hBM)
DeleteObject.call(hDC)
bitmap
end
end
module Graphics
RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
BitBlt = Win32API.new('gdi32', 'BitBlt', 'iiiiiiiii', 'i')
CreateCompatibleBitmap = Win32API.new('gdi32', 'CreateCompatibleBitmap', 'iii', 'i')
CreateCompatibleDC = Win32API.new('gdi32', 'CreateCompatibleDC', 'i', 'i')
DeleteObject = Win32API.new('gdi32', 'DeleteObject', 'i', 'i')
GetDIBits = Win32API.new('gdi32', 'GetDIBits', 'iiiiipi', 'i')
SelectObject = Win32API.new('gdi32', 'SelectObject', 'ii', 'i')
SetDIBits = Win32API.new('gdi32', 'SetDIBits', 'iiiiipi', 'i')
hWnd = Win32API.new('user32', 'FindWindow', 'pp', 'i').call('RGSS Player', 0)
DC = Win32API.new('user32', 'GetDC', 'i', 'i').call(hWnd)
def self.snap_to_bitmap
bitmap = Bitmap.new(width=640, height=480)
RtlMoveMemory.call(address="\0"*4, bitmap.__id__*2+16, 4)
RtlMoveMemory.call(address, address.unpack('L')[0]+8, 4)
RtlMoveMemory.call(address, address.unpack('L')[0]+16, 4)
address = address.unpack('L')[0]
info = [40,width,height,1,32,0,0,0,0,0,0].pack('LllSSLLllLL')
hDC = CreateCompatibleDC.call(DC)
hBM = CreateCompatibleBitmap.call(DC, width, height)
DeleteObject.call(SelectObject.call(hDC, hBM))
SetDIBits.call(hDC, hBM, 0, height, address, info, 0)
BitBlt.call(hDC, 0, 0, width, height, DC, 0, 0, 0xCC0020)
GetDIBits.call(hDC, hBM, 0, height, address, info, 0)
DeleteObject.call(hBM)
DeleteObject.call(hDC)
bitmap
end
end