赞 | 287 |
VIP | 11 |
好人卡 | 74 |
积分 | 227 |
经验 | 281171 |
最后登录 | 2024-11-22 |
在线时间 | 9418 小时 |
Lv5.捕梦者 (暗夜天使) 只有笨蛋才会看到
- 梦石
- 1
- 星屑
- 21666
- 在线时间
- 9418 小时
- 注册时间
- 2012-6-19
- 帖子
- 7118
|
- # 保存屏幕截图
- module M5SS20141231
- def self.shot
- $snap_shot.dispose if $snap_shot
- $snap_shot = Graphics.snap_to_bitmap
- end
- end
- # 快速储存Bitmap的Marshal By 柳之一
- class Font
- def marshal_dump
- end
- def marshal_load(obj)
- end
- end
- class Bitmap
- RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
- RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
- def _dump(limit)
- data = "rgba" * width * height
- RtlMoveMemory_pi.call(data, address, data.length)
- [width, height, Zlib::Deflate.deflate(data)].pack("LLa*")
- end
- def self._load(str)
- w, h, zdata = str.unpack("LLa*")
- b = self.new(w, h)
- RtlMoveMemory_ip.call(b.address, Zlib::Inflate.inflate(zdata), w * h * 4)
- return b
- end
- def address
- buffer, ad = "rgba", object_id * 2 + 16
- RtlMoveMemory_pi.call(buffer, ad, 4)
- ad = buffer.unpack("L")[0] + 8
- RtlMoveMemory_pi.call(buffer, ad, 4)
- ad = buffer.unpack("L")[0] + 16
- RtlMoveMemory_pi.call(buffer, ad, 4)
- return buffer.unpack("L")[0]
- end
- end
- # 截图保存到存档中
- class << DataManager
- alias m5_20121231_load_normal_database load_normal_database
- def load_normal_database
- m5_20121231_load_normal_database
- $snap_shot = nil
- end
- alias m5_20141231_make_save_contents make_save_contents
- def make_save_contents
- contents = m5_20141231_make_save_contents
- contents[:snapshot] = $snap_shot
- contents
- end
- alias m5_20141231_extract_save_contents extract_save_contents
- def extract_save_contents(contents)
- m5_20141231_extract_save_contents(contents)
- $snap_shot = contents[:snapshot]
- end
- end
- # 测试脚本效果的界面
- class Scene_Snap_Test < Scene_Base
- def start
- super
- @sprite = Sprite.new
- bitmap = $snap_shot || Bitmap.new(1,1)
- @sprite.bitmap = bitmap.clone
- @sprite.x -= 10
- end
- def update
- super
- return_scene if Input.trigger?(:B)
- end
- def terminate
- super
- @sprite.dispose
- end
- end
- # F5截图,F6打开测试界面
- class << Graphics
- alias m5_20141231_update update
- def update
- m5_20141231_update
- if Input.press?(:F5)
- M5SS20141231.shot
- elsif Input.trigger?(:F6)
- return if SceneManager.scene.is_a? Scene_Snap_Test
- SceneManager.call(Scene_Snap_Test)
- end
- end
- end
复制代码 RMVA用 |
|