txp 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/txp +15 -0
  2. data/lib/txp.rb +37 -0
  3. data/txp.gemspec +13 -0
  4. metadata +80 -0
data/bin/txp ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'txp.rb'
4
+
5
+ if ARGV.size == 2 and ARGV[0] == 'txp2png'
6
+ NIS::TXP.txp2png(ARGV[1])
7
+ elsif ARGV.size == 2 and ARGV[0] == 'png2txp'
8
+ NIS::TXP.png2txp(ARGV[1])
9
+ else
10
+ puts 'TXP<->PNG Graphics Converter'
11
+ puts 'Author: tonypolik 02/11/2010'
12
+ puts 'Usage:'
13
+ puts ' ' + File.basename($0) + ' txp2png txpname'
14
+ puts ' ' + File.basename($0) + ' png2txp pngname'
15
+ end
data/lib/txp.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'nis_gfx'
2
+
3
+
4
+ module NIS
5
+ module TXP
6
+
7
+ include NIS::Graphics
8
+
9
+ def self.get_info_from_txp txpname
10
+ txp = File.new(txpname, "rb")
11
+ w, h, num_colors = txp.read(6).unpack('v3')
12
+ bpp = case num_colors
13
+ when 0x10 ; 4
14
+ when 0x100; 8
15
+ else raise "Wrong number of colors"
16
+ end
17
+ txp.pos = 0x0C
18
+ tiled = (txp.getbyte == 0) ? false : true
19
+ o_pal = 0x10
20
+ o_data = File.size(txp)-(w*h*bpp/8)
21
+ txp.close
22
+ return [w, h, bpp, tiled, o_pal, o_data]
23
+ end
24
+
25
+ def self.txp2png txpname
26
+ w, h, bpp, tiled, o_pal, o_data = get_info_from_txp(txpname)
27
+ NIS::Graphics.nis2png(txpname, w, h, bpp, tiled, o_pal, o_data)
28
+ end
29
+
30
+ def self.png2txp pngname
31
+ w, h, bpp, tiled, o_pal, o_data = get_info_from_txp(pngname.chomp(".png"))
32
+ NIS::Graphics.png2nis(pngname, bpp, tiled, o_pal, o_data)
33
+ end
34
+
35
+
36
+ end
37
+ end
data/txp.gemspec ADDED
@@ -0,0 +1,13 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "txp"
3
+ s.version = "0.1"
4
+ s.author = "tonypolik"
5
+ s.email = "tonypolik@fastwebnet.it"
6
+ s.homepage = "http://www.cetramod.it"
7
+ s.description = "Graphics utilities for TXP files"
8
+ s.files = Dir.glob('**/*')
9
+ s.required_ruby_version = ">= 1.9"
10
+ s.executable = "txp"
11
+ s.add_dependency("nis_gfx",">=0.2")
12
+ s.summary = "Graphics utilities for TXP files"
13
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: txp
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ version: "0.1"
9
+ platform: ruby
10
+ authors:
11
+ - tonypolik
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2010-11-02 00:00:00 +01:00
17
+ default_executable:
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: nis_gfx
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 2
30
+ version: "0.2"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: Graphics utilities for TXP files
34
+ email: tonypolik@fastwebnet.it
35
+ executables:
36
+ - txp
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - bin/txp
43
+ - lib/txp.rb
44
+ - txp.gemspec
45
+ - txp-0.1.gem
46
+ has_rdoc: true
47
+ homepage: http://www.cetramod.it
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 1
62
+ - 9
63
+ version: "1.9"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project:
75
+ rubygems_version: 1.3.7
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Graphics utilities for TXP files
79
+ test_files: []
80
+