discreet_proxy 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +9 -1
- data/discreet_proxy.gemspec +9 -5
- data/lib/discreet_proxy.rb +24 -48
- data/test/test_discreet_proxy.rb +13 -6
- data/test/test_proxy_out/Kanaty.stabilizer.p +0 -0
- metadata +13 -14
- data/test/converted_png_proxies/Portretten_Erasmusbrug_Pts.stabilizer.p.p.png +0 -0
- data/test/test_proxies/Portretten_Erasmusbrug_Pts.stabilizer.p +0 -0
data/README.rdoc
CHANGED
@@ -7,11 +7,19 @@ To read every .p file on your Flame system and write it out as a PNG preview to
|
|
7
7
|
Dir.glob("/usr/discreet/project/**/*.p").each do | icon_path |
|
8
8
|
proxy = DiscreetProxy.from_file(icon_path)
|
9
9
|
dest_path = "/tmp/" + File.basename(icon_path) + ".png"
|
10
|
-
proxy.save_png(
|
10
|
+
proxy.save_png(dest_path)
|
11
11
|
end
|
12
12
|
|
13
13
|
Also you can use the builtin `flame_proxy_icon` binary to convert to and from the format.
|
14
14
|
|
15
|
+
$flame_proxy_icon --from-png my_icon.png
|
16
|
+
|
17
|
+
will create "my_icon.p", and the reverse
|
18
|
+
|
19
|
+
$flame_proxy_icon --from-icon SuperSetup.batch.p
|
20
|
+
|
21
|
+
will create a SuperSetup.batch.png file that you can massage in, say, Photoshop.
|
22
|
+
|
15
23
|
== Contributing to discreet_proxy
|
16
24
|
|
17
25
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/discreet_proxy.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "discreet_proxy"
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Julik Tarkhanov"]
|
12
|
-
s.date = "2011-12-
|
12
|
+
s.date = "2011-12-13"
|
13
13
|
s.email = "me@julik.nl"
|
14
14
|
s.executables = ["flame_proxy_icon"]
|
15
15
|
s.extra_rdoc_files = [
|
@@ -23,10 +23,10 @@ Gem::Specification.new do |s|
|
|
23
23
|
"README.rdoc",
|
24
24
|
"Rakefile",
|
25
25
|
"bin/flame_proxy_icon",
|
26
|
+
"discreet_proxy.gemspec",
|
26
27
|
"lib/discreet_proxy.rb",
|
27
28
|
"test/converted_png_proxies/Kanaty.stabilizer.p.p.png",
|
28
29
|
"test/converted_png_proxies/Medianize.stabilizer.p.p.png",
|
29
|
-
"test/converted_png_proxies/Portretten_Erasmusbrug_Pts.stabilizer.p.p.png",
|
30
30
|
"test/converted_png_proxies/Ripples.glsl.p.p.png",
|
31
31
|
"test/converted_png_proxies/Tezt_flame_5_trackers.stabilizer.p.p.png",
|
32
32
|
"test/converted_png_proxies/doberman.batch.p.p.png",
|
@@ -36,10 +36,10 @@ Gem::Specification.new do |s|
|
|
36
36
|
"test/converted_png_proxies/spontaan2.stabilizer.p.p.png",
|
37
37
|
"test/converted_png_proxies/t2.batch.p.p.png",
|
38
38
|
"test/helper.rb",
|
39
|
+
"test/test_cli.rb",
|
39
40
|
"test/test_discreet_proxy.rb",
|
40
41
|
"test/test_proxies/Kanaty.stabilizer.p",
|
41
42
|
"test/test_proxies/Medianize.stabilizer.p",
|
42
|
-
"test/test_proxies/Portretten_Erasmusbrug_Pts.stabilizer.p",
|
43
43
|
"test/test_proxies/Ripples.glsl.p",
|
44
44
|
"test/test_proxies/Tezt_flame_5_trackers.stabilizer.p",
|
45
45
|
"test/test_proxies/doberman.batch.p",
|
@@ -47,7 +47,8 @@ Gem::Specification.new do |s|
|
|
47
47
|
"test/test_proxies/e292_v02shadow.batch.p",
|
48
48
|
"test/test_proxies/spontaan.stabilizer.p",
|
49
49
|
"test/test_proxies/spontaan2.stabilizer.p",
|
50
|
-
"test/test_proxies/t2.batch.p"
|
50
|
+
"test/test_proxies/t2.batch.p",
|
51
|
+
"test/test_proxy_out/Kanaty.stabilizer.p"
|
51
52
|
]
|
52
53
|
s.homepage = "http://github.com/julik/discreet_proxy"
|
53
54
|
s.licenses = ["MIT"]
|
@@ -63,17 +64,20 @@ Gem::Specification.new do |s|
|
|
63
64
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
64
65
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
65
66
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
67
|
+
s.add_development_dependency(%q<cli_test>, [">= 0"])
|
66
68
|
else
|
67
69
|
s.add_dependency(%q<chunky_png>, [">= 0"])
|
68
70
|
s.add_dependency(%q<rake>, [">= 0"])
|
69
71
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
70
72
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
73
|
+
s.add_dependency(%q<cli_test>, [">= 0"])
|
71
74
|
end
|
72
75
|
else
|
73
76
|
s.add_dependency(%q<chunky_png>, [">= 0"])
|
74
77
|
s.add_dependency(%q<rake>, [">= 0"])
|
75
78
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
76
79
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
80
|
+
s.add_dependency(%q<cli_test>, [">= 0"])
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
data/lib/discreet_proxy.rb
CHANGED
@@ -2,7 +2,7 @@ require "chunky_png"
|
|
2
2
|
|
3
3
|
# The whole module for making and reading Flame proxy icon files
|
4
4
|
module DiscreetProxy
|
5
|
-
VERSION = "0.0
|
5
|
+
VERSION = "1.0.0"
|
6
6
|
|
7
7
|
# Parse a .p file and return a Proxy
|
8
8
|
def self.from_file(path)
|
@@ -43,36 +43,15 @@ module DiscreetProxy
|
|
43
43
|
VERSION_BSWAP = "\x00\x00?\x8C\xCC\xCD"
|
44
44
|
DEFAULT_WIDTH = 126
|
45
45
|
DEFAULT_HEIGHT = 92
|
46
|
-
|
47
|
-
#
|
48
|
-
#
|
49
|
-
# You can use Flame to create a proxy of your effect, but if you don't have access to Flame,
|
50
|
-
# or want to create proxies programmatically, you
|
51
|
-
# can use the following header (byteswap). The standard width and height of the proxy is 126x92, and the
|
52
|
-
# file is RGB 8-bit. Save your proxy files as .p, and place them in the same folder as your .glsl and .xml
|
53
|
-
# files of the same name.
|
54
|
-
#
|
55
|
-
#typedef struct {
|
56
|
-
# unsigned short Magic;
|
57
|
-
# float Version; // 6 bytes long
|
58
|
-
# short Width;
|
59
|
-
# short Height;
|
60
|
-
# short Depth;
|
61
|
-
# float Unused [ 6 ];
|
62
|
-
#} LibraryProxyHeaderStruct;
|
63
|
-
# and this bitch is 6 bytes aligned
|
64
|
-
#
|
65
|
-
##define MAGIC 0xfaf0
|
66
|
-
##define PROXY_VERSION 1.1f
|
67
|
-
##define PROXY_DEPTH 130
|
68
|
-
#
|
69
|
-
# This class represents such a proxy.
|
46
|
+
|
47
|
+
# This class represents a proxy.
|
70
48
|
class Proxy
|
71
49
|
|
72
50
|
# Image dimensions, standard is 126x92
|
73
51
|
attr_reader :width, :height
|
74
52
|
|
75
|
-
# Array of rows with each row being an array of
|
53
|
+
# Array of rows with each row being an array of packed color
|
54
|
+
# integers (you can unpack them with ChunkyPNG::Color)
|
76
55
|
attr_reader :rows
|
77
56
|
|
78
57
|
def initialize(w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT)
|
@@ -84,11 +63,11 @@ module DiscreetProxy
|
|
84
63
|
def to_png
|
85
64
|
png = ChunkyPNG::Image.new(@width, @height)
|
86
65
|
png.metadata["Software"] = "Ruby DiscreetProxy converter/chunky_png"
|
87
|
-
@rows.each_with_index do | row,
|
88
|
-
|
89
|
-
png[col_idx, row_idx] = pix
|
90
|
-
end
|
66
|
+
@rows.each_with_index do | row, y |
|
67
|
+
png.replace_row!(y, row)
|
91
68
|
end
|
69
|
+
# Bump it to the default icon size
|
70
|
+
png.resample_bilinear!(DEFAULT_WIDTH, DEFAULT_HEIGHT)
|
92
71
|
png
|
93
72
|
end
|
94
73
|
|
@@ -123,8 +102,9 @@ module DiscreetProxy
|
|
123
102
|
buf.seek(40)
|
124
103
|
|
125
104
|
# Now... all the reverses come in reverse
|
126
|
-
|
127
|
-
|
105
|
+
(0...@rows.length).each do | row_offset |
|
106
|
+
row_idx = (@rows.length - 1) - row_offset
|
107
|
+
@rows[row_idx].each do | pix |
|
128
108
|
rgb = unpack_rgb(pix).pack("CCC")
|
129
109
|
buf.write(rgb)
|
130
110
|
end
|
@@ -140,34 +120,30 @@ module DiscreetProxy
|
|
140
120
|
def fill_pixbuf(io)
|
141
121
|
@rows = []
|
142
122
|
|
143
|
-
# Data comes in row per row, starting on
|
144
|
-
# the values in the row being mirrored
|
123
|
+
# Data comes in row per row, starting on bottom left because of endianness
|
145
124
|
per_row = (@width.to_i + row_pad) * 3
|
146
|
-
total_size = (per_row * @height) + 1
|
147
|
-
|
148
|
-
# the bottom, so...
|
149
|
-
blob = StringIO.new(io.read(total_size).reverse)
|
125
|
+
total_size = ((per_row + row_pad) * @height) + 1
|
126
|
+
blob = StringIO.new(io.read(total_size))
|
150
127
|
|
151
128
|
@height.times do
|
152
|
-
# At the end of each row (thus at the beginning byteswap),
|
153
|
-
# 2 bytes contain garbage since rows are aligned
|
154
|
-
# to start at 8-complement byte offsets. If they are not discarded this disturbs
|
155
|
-
# the RGB cadence of the other values.
|
156
|
-
skip = blob.read(row_pad)
|
157
|
-
|
158
129
|
row = []
|
159
130
|
row_data = blob.read(@width.to_i * 3)
|
160
131
|
row_data = StringIO.new(row_data.to_s)
|
161
132
|
|
162
133
|
# Read 3x8bit for each pixel
|
163
134
|
@width.times do
|
164
|
-
|
165
|
-
rgb = (row_data.read(3) || "AAA").unpack("CCC").reverse
|
135
|
+
rgb = (row_data.read(3) || "AAA").unpack("CCC")
|
166
136
|
row.push(pack_rgb(*rgb))
|
167
137
|
end
|
168
138
|
|
169
|
-
#
|
170
|
-
|
139
|
+
# At the end of each row (thus at the beginning byteswap),
|
140
|
+
# 2 bytes contain garbage since rows are aligned
|
141
|
+
# to start at 8-complement byte offsets. If they are not discarded this disturbs
|
142
|
+
# the RGB cadence of the other values.
|
143
|
+
blob.seek(blob.pos + row_pad)
|
144
|
+
|
145
|
+
# Since the file is actually BE, the rows are ordered top to bottom in the file
|
146
|
+
@rows.unshift(row)
|
171
147
|
end
|
172
148
|
end
|
173
149
|
|
data/test/test_discreet_proxy.rb
CHANGED
@@ -49,8 +49,7 @@ class TestDiscreetProxy < Test::Unit::TestCase
|
|
49
49
|
Dir.glob(File.dirname(__FILE__) + "/test_proxies/*.p").each do | f |
|
50
50
|
proxy = DiscreetProxy.from_file(f)
|
51
51
|
png_path = File.dirname(__FILE__) + "/converted_png_proxies/%s.p.png" % File.basename(f)
|
52
|
-
|
53
|
-
assert_equal chunky_png, ChunkyPNG::Image.from_file(png_path)
|
52
|
+
assert_same_png ChunkyPNG::Image.from_file(png_path), proxy.to_png
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
@@ -58,10 +57,7 @@ class TestDiscreetProxy < Test::Unit::TestCase
|
|
58
57
|
f = File.dirname(__FILE__) + "/converted_png_proxies/Kanaty.stabilizer.p.p.png"
|
59
58
|
png = ChunkyPNG::Image.from_file(f)
|
60
59
|
proxy = DiscreetProxy.from_png(png)
|
61
|
-
|
62
|
-
|
63
|
-
dest = '/tmp/foo_%s' % File.basename(f)
|
64
|
-
assert_equal png, roundtrip_png
|
60
|
+
assert_same_png png, proxy.to_png
|
65
61
|
end
|
66
62
|
|
67
63
|
TEST_OUTPUT = "./test.p"
|
@@ -75,9 +71,11 @@ class TestDiscreetProxy < Test::Unit::TestCase
|
|
75
71
|
|
76
72
|
def test_save
|
77
73
|
path = File.dirname(__FILE__) + "/test_proxies/Kanaty.stabilizer.p"
|
74
|
+
ref_output = File.dirname(__FILE__) + "/test_proxy_out/Kanaty.stabilizer.p"
|
78
75
|
proxy = DiscreetProxy.from_file(path)
|
79
76
|
proxy.save(TEST_OUTPUT)
|
80
77
|
assert File.exist?(TEST_OUTPUT)
|
78
|
+
assert_equal File.read(TEST_OUTPUT), File.read(ref_output)
|
81
79
|
end
|
82
80
|
|
83
81
|
def test_save_png
|
@@ -87,4 +85,13 @@ class TestDiscreetProxy < Test::Unit::TestCase
|
|
87
85
|
assert File.exist?(TEST_PNG)
|
88
86
|
assert_equal ChunkyPNG::Image.from_file(TEST_PNG), proxy.to_png
|
89
87
|
end
|
88
|
+
|
89
|
+
def assert_same_png(ref, actual)
|
90
|
+
if ref != actual
|
91
|
+
ref.save("/tmp/REF.png")
|
92
|
+
actual.save("/tmp/ACTUAL.png")
|
93
|
+
`open /tmp/REF.png /tmp/ACTUAL.png`
|
94
|
+
assert_equal ref, actual, "The PNG files were not the same"
|
95
|
+
end
|
96
|
+
end
|
90
97
|
end
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discreet_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chunky_png
|
16
|
-
requirement: &
|
16
|
+
requirement: &10672110 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10672110
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &10671820 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *10671820
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &10671440 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *10671440
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &10671100 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *10671100
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: cli_test
|
60
|
-
requirement: &
|
60
|
+
requirement: &10670720 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *10670720
|
69
69
|
description:
|
70
70
|
email: me@julik.nl
|
71
71
|
executables:
|
@@ -85,7 +85,6 @@ files:
|
|
85
85
|
- lib/discreet_proxy.rb
|
86
86
|
- test/converted_png_proxies/Kanaty.stabilizer.p.p.png
|
87
87
|
- test/converted_png_proxies/Medianize.stabilizer.p.p.png
|
88
|
-
- test/converted_png_proxies/Portretten_Erasmusbrug_Pts.stabilizer.p.p.png
|
89
88
|
- test/converted_png_proxies/Ripples.glsl.p.p.png
|
90
89
|
- test/converted_png_proxies/Tezt_flame_5_trackers.stabilizer.p.p.png
|
91
90
|
- test/converted_png_proxies/doberman.batch.p.p.png
|
@@ -99,7 +98,6 @@ files:
|
|
99
98
|
- test/test_discreet_proxy.rb
|
100
99
|
- test/test_proxies/Kanaty.stabilizer.p
|
101
100
|
- test/test_proxies/Medianize.stabilizer.p
|
102
|
-
- test/test_proxies/Portretten_Erasmusbrug_Pts.stabilizer.p
|
103
101
|
- test/test_proxies/Ripples.glsl.p
|
104
102
|
- test/test_proxies/Tezt_flame_5_trackers.stabilizer.p
|
105
103
|
- test/test_proxies/doberman.batch.p
|
@@ -108,6 +106,7 @@ files:
|
|
108
106
|
- test/test_proxies/spontaan.stabilizer.p
|
109
107
|
- test/test_proxies/spontaan2.stabilizer.p
|
110
108
|
- test/test_proxies/t2.batch.p
|
109
|
+
- test/test_proxy_out/Kanaty.stabilizer.p
|
111
110
|
homepage: http://github.com/julik/discreet_proxy
|
112
111
|
licenses:
|
113
112
|
- MIT
|
Binary file
|
Binary file
|