赞 | 287 |
VIP | 11 |
好人卡 | 74 |
积分 | 226 |
经验 | 281171 |
最后登录 | 2024-10-28 |
在线时间 | 9407 小时 |
Lv5.捕梦者 (暗夜天使) 只有笨蛋才会看到
- 梦石
- 1
- 星屑
- 21584
- 在线时间
- 9407 小时
- 注册时间
- 2012-6-19
- 帖子
- 7117
|
插入脚本,图片扔到游戏目录下的ICO文件夹中,文件名用英文或者数字,运行游戏,之后游戏目录下会生成合并好的文件- # PNG 保存 (CACAO http://cacaosoft.web.fc2.com/)
- class Bitmap
- def save_png(filename, alpha = false)
- sgnt = "\x89PNG\r\n\x1a\n"
- ihdr = _chunk('IHDR', [width,height,8,(alpha ? 6 : 2),0,0,0].pack('N2C5'))
- data = []
- height.times do |y|
- data << 0
- width.times do |x|
- color = self.get_pixel(x, y)
- data << color.red << color.green << color.blue
- data << color.alpha if alpha
- end
- end
- idat = _chunk('IDAT', Zlib::Deflate.deflate(data.pack('C*')))
- iend = _chunk('IEND', "")
- File.open(filename, 'wb') do |file|
- file.write(sgnt)
- file.write(ihdr)
- file.write(idat)
- file.write(iend)
- end
- end
- private
- def _chunk(name, data)
- return [data.size, name, data, Zlib.crc32(name + data)].pack('NA4A*N')
- end
- end
- def conv_2_24(num)
- loop do
- break if num % 24 == 0
- num += 1
- end
- return num
- end
- path = "ICO"
- bitmap_list = []
- Dir.foreach(path) do |file|
- filename = path + "/" + file
- if FileTest.file?(filename)
- bitmap_list << Bitmap.new(filename)
- end
- end
- height = 0
- bitmap_list.each {|bitmap| height += bitmap.height }
- height = conv_2_24(height)
- final_file = Bitmap.new(384,height)
- pos = 0
- bitmap_list.each do |bitmap|
- pos = conv_2_24(pos)
- rect = Rect.new(0,0,bitmap.width,bitmap.height)
- final_file.blt(0, pos, bitmap, rect)
- pos += bitmap.height
- end
- final_file.save_png("IconSet.png", true)
- exit
复制代码 |
评分
-
查看全部评分
|