#==============================================================================
# □ INI
#==============================================================================
module FSL
module ComicStyle_Window_message
module_function
#--------------------------------------------------------------------------
# ○ 常量
#--------------------------------------------------------------------------
RdINI = Win32API.new("kernel32","GetPrivateProfileStringA","pppplp","l")
WtINI = Win32API.new("kernel32","WritePrivateProfileStringA","pppp","l")
M2W = Win32API.new("kernel32","MultiByteToWideChar","ilpipi","l")
W2M = Win32API.new("kernel32","WideCharToMultiByte","ilpipipp","l")
#--------------------------------------------------------------------------
# ○ 读取配置
#--------------------------------------------------------------------------
def readini(app_name, key_name)
buff = "\0" * 256
RdINI.call(app_name,key_name,"",buff,buff.size,"./Skin.ini")
buff.delete!("\0")
return a2u(buff)
end
#--------------------------------------------------------------------------
# ○ 保存配置
#--------------------------------------------------------------------------
def writeini(app_name, key_name, value)
WtINI.call(app_name,key_name,u2a(value),"./Skin.ini")
end
#--------------------------------------------------------------------------
# ○ ASCII转UTF8
#--------------------------------------------------------------------------
def a2u(str)
len = M2W.call(0,0,str,-1,nil,0)
buf = "\0" * (len*2)
M2W.call(0,0,str,-1,buf,buf.size/2)
len = W2M.call(0xFDE9,0,buf,-1,nil,0,nil,nil)
ret = "\0" * len
W2M.call(0xFDE9,0,buf,-1,ret,ret.size,nil,nil)
return ret.delete!("\0")
end
#--------------------------------------------------------------------------
# ○ UTF8转ASCII
#--------------------------------------------------------------------------
def u2a(str)
len = M2W.call(0xFDE9,0,str,-1,nil,0)
buf = "\0" * (len*2)
M2W.call(0xFDE9,0,str,-1,buf,buf.size/2)
len = W2M.call(0,0,buf,-1,nil,0,nil,nil)
ret = "\0" * len
W2M.call(0,0,buf,-1,ret,ret.size,nil,nil)
return ret.delete!("\0")
end
end
end
#==============================================================================
# ■ Bitmap
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# ○ 平铺
#--------------------------------------------------------------------------
def tile(dest_rect, src_bitmap, src_rect, opacity = 255)
m = dest_rect.width / src_rect.width
n = dest_rect.height / src_rect.height
m += 1 if dest_rect.width % src_rect.width > 0
n += 1 if dest_rect.height % src_rect.height > 0
buf = Bitmap.new(dest_rect.width, dest_rect.height)
for i in 0...m
x = src_rect.width * i
for j in 0...n
y = src_rect.height * j
buf.blt(x, y, src_bitmap, src_rect)
end
end
src_rect = Rect.new(0, 0, dest_rect.width, dest_rect.height)
self.blt(dest_rect.x, dest_rect.y, buf, src_rect, opacity)
buf.dispose
end
end