赞 | 0 |
VIP | 8 |
好人卡 | 27 |
积分 | 55 |
经验 | 41413 |
最后登录 | 2012-10-21 |
在线时间 | 833 小时 |
Lv4.逐梦者 弓箭手?剑兰
- 梦石
- 0
- 星屑
- 5464
- 在线时间
- 833 小时
- 注册时间
- 2010-11-17
- 帖子
- 1140
|
david50407 发表于 2011-6-11 16:27
自己刻的Shadow 应该VX一样Bitmap#blur
其实 @default_shadow 应否用类变量呢?(貌似会省下一些内存...不知道= =)
Bitmap 貌似是这个:- http://rpg.blue/article-40940.html
复制代码 是吗?
Bitmap.mem_new 不知为啥会出错,看 12 楼那个无误获取字符串内存地址的办法,
我(Vista)出错,RGE::BaseError Create bitmap error with(Address:0x???????, Length:905216),
脚本如下(呼叫zh来看= =):- #==============================================================================
- # ■ Graphics
- #------------------------------------------------------------------------------
- # 进行有关全体图像处理的模块。
- # RGE 的 Graphics.snap_to_bitmap。(和 XP 版有分别)
- #==============================================================================
- module Graphics
- #--------------------------------------------------------------------------
- # ● API 函数
- #--------------------------------------------------------------------------
- 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")
- DeleteDC = Win32API.new("gdi32", "DeleteDC", "l", "l")
- DeleteObject = Win32API.new("gdi32", "DeleteObject", "l", "l")
- SRCCOPY = 0xCC0020
- RtlMoveMemory_pi = Win32API.new("kernel32", "RtlMoveMemory", "pii", "i")
- HWnd = Win32API.new("user32", "GetActiveWindow", nil, 'l').call
- DwCount = (Frame.width * Frame.height * 4)# * 2
- @@lpBits = "\000" * DwCount
- #--------------------------------------------------------------------------
- # ● snap_to_bitmap (RGE版)
- #--------------------------------------------------------------------------
- def self.snap_to_bitmap
- hScrDC = CreateDC.call("DISPLAY", "", "", 0)
- hMemDC = CreateCompatibleDC.call(hScrDC)
- hBitmap = CreateCompatibleBitmap.call(hScrDC, width, height)
- hOldBitmap = SelectObject.call(hMemDC, hBitmap)
- win_pos = "\0\0\0\0\0\0\0\0"
- ScreenToClient.call(HWnd, win_pos)
- win_pos = win_pos.unpack("LL")
- BitBlt.call(hMemDC, win_pos[0], win_pos[1], width*2, height*2, hScrDC, 0, 0, SRCCOPY)
- hBitmap2 = SelectObject.call(hMemDC, hOldBitmap)
- GetBitmapBits.call(hBitmap2, DwCount, @@lpBits)
- # 释放所有东西
- DeleteDC.call(hScrDC)
- DeleteDC.call(hMemDC)
- DeleteObject.call(hBitmap)
- DeleteObject.call(hOldBitmap)
- DeleteObject.call(hBitmap2)
- rgbs = @@lpBits
- len = width * 4
- for y in 0...height
- break if 2 * y >= height - 1
- nth1 = y * len
- nth2 = (height - 1 - y) * len
- tStr = rgbs[nth1,len]
- rgbs[nth1, len] = rgbs[nth2, len]
- rgbs[nth2, len] = tStr
- end
- # 找 String 的内存地址
- rgbs_address = "xxxx" # 分配指针 4 个字节
- RtlMoveMemory_pi.call(rgbs_address, rgbs.object_id * 2 + 12, 4)
- rgbs_address = rgbs_address.unpack("L")[0]
- bitmap = Bitmap.mem_new(rgbs_address, Frame.width * Frame.height * 4)
- return bitmap
- end
- end
复制代码 |
|