Module: NIS::TXP
- Includes:
- Graphics
- Defined in:
- lib/txp.rb
Class Method Summary collapse
Class Method Details
.get_info_from_txp(txpname) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/txp.rb', line 9 def self.get_info_from_txp txpname txp = File.new(txpname, "rb") w, h, num_colors = txp.read(6).unpack('v3') bpp = case num_colors when 0x10 ; 4 when 0x100; 8 else raise "Wrong number of colors" end txp.pos = 0x0C tiled = (txp.getbyte == 0) ? false : true o_pal = 0x10 o_data = File.size(txp)-(w*h*bpp/8) txp.close return [w, h, bpp, tiled, o_pal, o_data] end |
.png2txp(pngname) ⇒ Object
30 31 32 33 |
# File 'lib/txp.rb', line 30 def self.png2txp pngname w, h, bpp, tiled, o_pal, o_data = get_info_from_txp(pngname.chomp(".png")) NIS::Graphics.png2nis(pngname, bpp, tiled, o_pal, o_data) end |
.txp2png(txpname) ⇒ Object
25 26 27 28 |
# File 'lib/txp.rb', line 25 def self.txp2png txpname w, h, bpp, tiled, o_pal, o_data = get_info_from_txp(txpname) NIS::Graphics.nis2png(txpname, w, h, bpp, tiled, o_pal, o_data) end |