mikunyan 3.9.3 → 3.9.4
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.
- checksums.yaml +5 -5
- data/README.md +89 -2
- data/exe/mikunyan-image +92 -0
- data/lib/mikunyan/decoders/image_decoder.rb +18 -18
- data/lib/mikunyan/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3fa0e08afb0e0451f374cf94e9980f6f3b2a7ad279440b8d7d4e8a26426384f6
|
4
|
+
data.tar.gz: 31032deca5a1c100086c78c67a3c3b3bc899b66d08c97ab12fcb19980a2e70f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bb6fdd93d68c6816d37f8cc6ab988672b2b2b6eab969faa71d79e98261e79c4a0376ab5d2989895537d54985426c1269eda763d13e9b73a452b72d7d626e3bc
|
7
|
+
data.tar.gz: 8f9816d0bdf13fb919257c853f45591a2e668d89c0800387d00ff778b567071187982d861cbffeb3b11930dc19be9ebb5c08de5e0e0d091b530f80692966a9e4
|
data/README.md
CHANGED
@@ -121,7 +121,7 @@ img.save('mikunyan.png')
|
|
121
121
|
|
122
122
|
Mikunyan cannot decode ASTC with HDR data. Use `Mikunyan::ImageDecoder.create_astc_file` instead.
|
123
123
|
|
124
|
-
### Json / YAML
|
124
|
+
### Json / YAML Outputter
|
125
125
|
|
126
126
|
`mikunyan-json` is an executable command for converting unity3d to json.
|
127
127
|
|
@@ -130,9 +130,96 @@ Mikunyan cannot decode ASTC with HDR data. Use `Mikunyan::ImageDecoder.create_as
|
|
130
130
|
Available options:
|
131
131
|
|
132
132
|
- `--as-asset` (`-a`): interpret input file as not AssetBudnle but Asset
|
133
|
-
- `--pretty` (`-p`): prettify output json
|
133
|
+
- `--pretty` (`-p`): prettify output json
|
134
134
|
- `--yaml` (`-y`): YAML mode
|
135
135
|
|
136
|
+
### Image Outputter
|
137
|
+
|
138
|
+
`mikunyan-image` is an executable command for unpacking images from unity3d.
|
139
|
+
|
140
|
+
$ mikunyan-image bundle.unity3d
|
141
|
+
|
142
|
+
The console log is json data of output textures as below.
|
143
|
+
|
144
|
+
```json
|
145
|
+
[
|
146
|
+
{
|
147
|
+
"name": "bg_b",
|
148
|
+
"width": 1024,
|
149
|
+
"height": 1024,
|
150
|
+
"path_id": -744818715421265689
|
151
|
+
},
|
152
|
+
{
|
153
|
+
"name": "bg_a",
|
154
|
+
"width": 1024,
|
155
|
+
"height": 1024,
|
156
|
+
"path_id": 5562124901460497987
|
157
|
+
}
|
158
|
+
]
|
159
|
+
```
|
160
|
+
|
161
|
+
If the option `--sprite` specified, `mikunyan-image` will output sprites. The log json also contains sprite information.
|
162
|
+
|
163
|
+
```json
|
164
|
+
[
|
165
|
+
{
|
166
|
+
"name": "bg_a",
|
167
|
+
"width": 1024,
|
168
|
+
"height": 1024,
|
169
|
+
"path_id": 5562124901460497987,
|
170
|
+
"sprites": [
|
171
|
+
{
|
172
|
+
"name": "bg_a_0",
|
173
|
+
"x": 1.0,
|
174
|
+
"y": 303.0,
|
175
|
+
"width": 1022.0,
|
176
|
+
"height": 720.0,
|
177
|
+
"path_id": -7546240288260780845
|
178
|
+
},
|
179
|
+
{
|
180
|
+
"name": "bg_a_1",
|
181
|
+
"x": 1.0,
|
182
|
+
"y": 1.0,
|
183
|
+
"width": 720.0,
|
184
|
+
"height": 258.0,
|
185
|
+
"path_id": -5293490190204738553
|
186
|
+
}
|
187
|
+
]
|
188
|
+
},
|
189
|
+
{
|
190
|
+
"name": "bg_b",
|
191
|
+
"width": 1024,
|
192
|
+
"height": 1024,
|
193
|
+
"path_id": -744818715421265689,
|
194
|
+
"sprites": [
|
195
|
+
{
|
196
|
+
"name": "bg_b_1",
|
197
|
+
"x": 1.0,
|
198
|
+
"y": 1.0,
|
199
|
+
"width": 720.0,
|
200
|
+
"height": 258.0,
|
201
|
+
"path_id": 4884595733995530103
|
202
|
+
},
|
203
|
+
{
|
204
|
+
"name": "bg_b_0",
|
205
|
+
"x": 1.0,
|
206
|
+
"y": 303.0,
|
207
|
+
"width": 1022.0,
|
208
|
+
"height": 720.0,
|
209
|
+
"path_id": 7736251300187116441
|
210
|
+
}
|
211
|
+
]
|
212
|
+
}
|
213
|
+
]
|
214
|
+
```
|
215
|
+
|
216
|
+
Available options:
|
217
|
+
|
218
|
+
- `--as-asset` (`-a`): interpret input file as not AssetBudnle but Asset
|
219
|
+
- `--outputdir` (`-o`): output directory (default is a basename of input file without an extention)
|
220
|
+
- `--sprite` (`-s`): output sprites instead of textures
|
221
|
+
- `--pretty` (`-p`): prettify output json
|
222
|
+
|
136
223
|
## Dependencies
|
137
224
|
|
138
225
|
- [json](https://rubygems.org/gems/json)
|
data/exe/mikunyan-image
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'mikunyan'
|
3
|
+
require 'mikunyan/decoders'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
opts = {:as_asset => false, :outputdir => nil, :sprite => false, :pretty => false}
|
8
|
+
arg = nil
|
9
|
+
i = 0
|
10
|
+
while i < ARGV.count
|
11
|
+
if ARGV[i].start_with?('-')
|
12
|
+
case ARGV[i]
|
13
|
+
when '--as-asset', '-a'
|
14
|
+
opts[:as_asset] = true
|
15
|
+
when '--outputdir', '-o'
|
16
|
+
i += 1
|
17
|
+
opts[:outputdir] = ARGV[i]
|
18
|
+
when '--sprite', '-s'
|
19
|
+
opts[:sprite] = true
|
20
|
+
when '--pretty', '-p'
|
21
|
+
opts[:pretty] = true
|
22
|
+
else
|
23
|
+
warn("Unknown option: #{ARGV[i]}")
|
24
|
+
end
|
25
|
+
else
|
26
|
+
arg = ARGV[i] unless arg
|
27
|
+
end
|
28
|
+
i += 1
|
29
|
+
end
|
30
|
+
|
31
|
+
unless arg
|
32
|
+
warn("Input file is not specified")
|
33
|
+
exit(1)
|
34
|
+
end
|
35
|
+
|
36
|
+
unless File.file?(arg)
|
37
|
+
warn("File not found: #{arg}")
|
38
|
+
exit(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
assets = []
|
42
|
+
|
43
|
+
if opts[:as_asset]
|
44
|
+
assets = [Mikunyan::Asset.file(arg, File.basename(arg, '.*'))]
|
45
|
+
else
|
46
|
+
assets = Mikunyan::AssetBundle.file(arg).assets
|
47
|
+
end
|
48
|
+
|
49
|
+
outdir = opts[:outputdir] || File.basename(arg, '.*')
|
50
|
+
FileUtils.mkpath(outdir)
|
51
|
+
|
52
|
+
assets.each do |asset|
|
53
|
+
if opts[:sprite]
|
54
|
+
json = {}
|
55
|
+
textures = {}
|
56
|
+
|
57
|
+
asset.path_ids.select{|path_id| asset.object_type(path_id) == 'Sprite'}.each do |path_id|
|
58
|
+
obj = asset.parse_object(path_id)
|
59
|
+
name = obj.m_Name.value
|
60
|
+
tex_id = obj.m_RD.texture.m_PathID.value
|
61
|
+
|
62
|
+
unless textures[tex_id]
|
63
|
+
tex_obj = asset.parse_object(tex_id)
|
64
|
+
textures[tex_id] = Mikunyan::ImageDecoder.decode_object(tex_obj) if tex_obj
|
65
|
+
json[tex_id] = {:name => tex_obj.m_Name.value, :width => textures[tex_id].width, :height => textures[tex_id].height, :path_id => tex_id, :sprites => []}
|
66
|
+
end
|
67
|
+
|
68
|
+
if textures[tex_id]
|
69
|
+
x = obj.m_Rect.x.value
|
70
|
+
y = obj.m_Rect.y.value
|
71
|
+
width = obj.m_Rect.width.value
|
72
|
+
height = obj.m_Rect.height.value
|
73
|
+
|
74
|
+
json[tex_id][:sprites] << {:name => name, :x => x, :y => y, :width => width, :height => height, :path_id => path_id}
|
75
|
+
textures[tex_id].crop(x.round, (textures[tex_id].height - height - y).round, width.round, height.round).save("#{outdir}/#{name}.png")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
puts opts[:pretty] ? JSON.pretty_generate(json.values) : JSON.generate(json.values)
|
79
|
+
else
|
80
|
+
json = []
|
81
|
+
asset.path_ids.select{|path_id| asset.object_type(path_id) == 'Texture2D'}.each do |path_id|
|
82
|
+
obj = asset.parse_object(path_id)
|
83
|
+
name = obj.m_Name.value
|
84
|
+
image = Mikunyan::ImageDecoder.decode_object(obj)
|
85
|
+
if image
|
86
|
+
json << {:name => name, :width => image.width, :height => image.height, :path_id => path_id}
|
87
|
+
image.save("#{outdir}/#{name}.png")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
puts opts[:pretty] ? JSON.pretty_generate(json) : JSON.generate(json)
|
91
|
+
end
|
92
|
+
end
|
@@ -97,7 +97,7 @@ module Mikunyan
|
|
97
97
|
c = ((c & 0xf000) << 12) | ((c & 0x0f00) << 8) | ((c & 0x00f0) << 4) | (c & 0x000f)
|
98
98
|
BinUtils.append_int32_be!(mem, c << 4 | c)
|
99
99
|
end
|
100
|
-
ChunkyPNG::Image.from_rgba_stream(width, height, mem)
|
100
|
+
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
101
101
|
end
|
102
102
|
|
103
103
|
# Decode image from ARGB4444 binary
|
@@ -113,7 +113,7 @@ module Mikunyan
|
|
113
113
|
c = ((c & 0x0f00) << 16) | ((c & 0x00f0) << 12) | ((c & 0x000f) << 8) | ((c & 0xf000) >> 12)
|
114
114
|
BinUtils.append_int32_be!(mem, c << 4 | c)
|
115
115
|
end
|
116
|
-
ChunkyPNG::Image.from_rgba_stream(width, height, mem)
|
116
|
+
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
117
117
|
end
|
118
118
|
|
119
119
|
# Decode image from RGB565 binary
|
@@ -131,7 +131,7 @@ module Mikunyan
|
|
131
131
|
b = (c & 0x001f) << 3
|
132
132
|
BinUtils.append_int8!(mem, r | r >> 5, g | g >> 6, b | b >> 5)
|
133
133
|
end
|
134
|
-
ChunkyPNG::Image.from_rgb_stream(width, height, mem)
|
134
|
+
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
135
135
|
end
|
136
136
|
|
137
137
|
# Decode image from A8 binary
|
@@ -145,7 +145,7 @@ module Mikunyan
|
|
145
145
|
c = BinUtils.get_int8(bin, i)
|
146
146
|
BinUtils.append_int8!(mem, c, c, c)
|
147
147
|
end
|
148
|
-
ChunkyPNG::Image.from_rgb_stream(width, height, mem)
|
148
|
+
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
149
149
|
end
|
150
150
|
|
151
151
|
# Decode image from R8 binary
|
@@ -154,7 +154,7 @@ module Mikunyan
|
|
154
154
|
# @param [String] bin binary to decode
|
155
155
|
# @return [ChunkyPNG::Image] decoded image
|
156
156
|
def self.decode_r8(width, height, bin)
|
157
|
-
decode_a8(width, height, bin)
|
157
|
+
decode_a8(width, height, bin).flip
|
158
158
|
end
|
159
159
|
|
160
160
|
# Decode image from RG16 binary
|
@@ -167,7 +167,7 @@ module Mikunyan
|
|
167
167
|
(width * height).times do |i|
|
168
168
|
BinUtils.append_int16_int8_be!(mem, BinUtils.get_int16_be(bin, i*2), 0)
|
169
169
|
end
|
170
|
-
ChunkyPNG::Image.from_rgb_stream(width, height, mem)
|
170
|
+
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
171
171
|
end
|
172
172
|
|
173
173
|
# Decode image from RGB24 binary
|
@@ -176,7 +176,7 @@ module Mikunyan
|
|
176
176
|
# @param [String] bin binary to decode
|
177
177
|
# @return [ChunkyPNG::Image] decoded image
|
178
178
|
def self.decode_rgb24(width, height, bin)
|
179
|
-
ChunkyPNG::Image.from_rgb_stream(width, height, bin)
|
179
|
+
ChunkyPNG::Image.from_rgb_stream(width, height, bin).flip
|
180
180
|
end
|
181
181
|
|
182
182
|
# Decode image from RGBA32 binary
|
@@ -185,7 +185,7 @@ module Mikunyan
|
|
185
185
|
# @param [String] bin binary to decode
|
186
186
|
# @return [ChunkyPNG::Image] decoded image
|
187
187
|
def self.decode_rgba32(width, height, bin)
|
188
|
-
ChunkyPNG::Image.from_rgba_stream(width, height, bin)
|
188
|
+
ChunkyPNG::Image.from_rgba_stream(width, height, bin).flip
|
189
189
|
end
|
190
190
|
|
191
191
|
# Decode image from ARGB32 binary
|
@@ -199,7 +199,7 @@ module Mikunyan
|
|
199
199
|
c = BinUtils.get_int32_be(bin, i*4)
|
200
200
|
BinUtils.append_int32_be!(mem, ((c & 0x00ffffff) << 8) | ((c & 0xff000000) >> 24))
|
201
201
|
end
|
202
|
-
ChunkyPNG::Image.from_rgba_stream(width, height, mem)
|
202
|
+
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
203
203
|
end
|
204
204
|
|
205
205
|
# Decode image from BGRA32 binary
|
@@ -213,7 +213,7 @@ module Mikunyan
|
|
213
213
|
c = BinUtils.get_int32_le(bin, i*4)
|
214
214
|
BinUtils.append_int32_be!(mem, ((c & 0x00ffffff) << 8) | ((c & 0xff000000) >> 24))
|
215
215
|
end
|
216
|
-
ChunkyPNG::Image.from_rgba_stream(width, height, mem)
|
216
|
+
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
217
217
|
end
|
218
218
|
|
219
219
|
# Decode image from R16 binary
|
@@ -229,7 +229,7 @@ module Mikunyan
|
|
229
229
|
c = f2i(r / 65535.0)
|
230
230
|
BinUtils.append_int8!(mem, c, c, c)
|
231
231
|
end
|
232
|
-
ChunkyPNG::Image.from_rgb_stream(width, height, mem)
|
232
|
+
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
233
233
|
end
|
234
234
|
|
235
235
|
# Decode image from RGB9e5 binary
|
@@ -251,7 +251,7 @@ module Mikunyan
|
|
251
251
|
b = (b / 512r + 1) * (2**(e-15))
|
252
252
|
BinUtils.append_int8!(mem, f2i(r), f2i(g), f2i(b))
|
253
253
|
end
|
254
|
-
ChunkyPNG::Image.from_rgb_stream(width, height, mem)
|
254
|
+
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
255
255
|
end
|
256
256
|
|
257
257
|
# Decode image from R Half-float binary
|
@@ -266,7 +266,7 @@ module Mikunyan
|
|
266
266
|
c = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i*2) : BinUtils.get_int16_be(bin, i*2)))
|
267
267
|
BinUtils.append_int8!(mem, c, c, c)
|
268
268
|
end
|
269
|
-
ChunkyPNG::Image.from_rgb_stream(width, height, mem)
|
269
|
+
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
270
270
|
end
|
271
271
|
|
272
272
|
# Decode image from RG Half-float binary
|
@@ -282,7 +282,7 @@ module Mikunyan
|
|
282
282
|
g = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i*4+2) : BinUtils.get_int16_be(bin, i*4+2)))
|
283
283
|
BinUtils.append_int8!(mem, r, g, 0)
|
284
284
|
end
|
285
|
-
ChunkyPNG::Image.from_rgb_stream(width, height, mem)
|
285
|
+
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
286
286
|
end
|
287
287
|
|
288
288
|
# Decode image from RGBA Half-float binary
|
@@ -300,7 +300,7 @@ module Mikunyan
|
|
300
300
|
a = f2i(n2f(endian == :little ? BinUtils.get_int16_le(bin, i*8+6) : BinUtils.get_int16_be(bin, i*8+6)))
|
301
301
|
BinUtils.append_int8!(mem, r, g, b, a)
|
302
302
|
end
|
303
|
-
ChunkyPNG::Image.from_rgba_stream(width, height, mem)
|
303
|
+
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
304
304
|
end
|
305
305
|
|
306
306
|
# Decode image from R float binary
|
@@ -316,7 +316,7 @@ module Mikunyan
|
|
316
316
|
c = f2i(bin.byteslice(i*4, 4).unpack(unpackstr)[0])
|
317
317
|
BinUtils.append_int8!(mem, c, c, c)
|
318
318
|
end
|
319
|
-
ChunkyPNG::Image.from_rgb_stream(width, height, mem)
|
319
|
+
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
320
320
|
end
|
321
321
|
|
322
322
|
# Decode image from RG float binary
|
@@ -332,7 +332,7 @@ module Mikunyan
|
|
332
332
|
r, g = bin.byteslice(i*8, 8).unpack(unpackstr)
|
333
333
|
BinUtils.append_int8!(mem, f2i(r), f2i(g), 0)
|
334
334
|
end
|
335
|
-
ChunkyPNG::Image.from_rgb_stream(width, height, mem)
|
335
|
+
ChunkyPNG::Image.from_rgb_stream(width, height, mem).flip
|
336
336
|
end
|
337
337
|
|
338
338
|
# Decode image from RGBA float binary
|
@@ -348,7 +348,7 @@ module Mikunyan
|
|
348
348
|
r, g, b, a = bin.byteslice(i*16, 16).unpack(unpackstr)
|
349
349
|
BinUtils.append_int8!(mem, f2i(r), f2i(g), f2i(b), f2i(a))
|
350
350
|
end
|
351
|
-
ChunkyPNG::Image.from_rgba_stream(width, height, mem)
|
351
|
+
ChunkyPNG::Image.from_rgba_stream(width, height, mem).flip
|
352
352
|
end
|
353
353
|
|
354
354
|
# Decode image from ETC1 compressed binary
|
data/lib/mikunyan/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mikunyan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.9.
|
4
|
+
version: 3.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ishotihadus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: extlz4
|
@@ -98,6 +98,7 @@ description: Library to deserialize Unity assetbundles and assets.
|
|
98
98
|
email:
|
99
99
|
- hanachan.pao@gmail.com
|
100
100
|
executables:
|
101
|
+
- mikunyan-image
|
101
102
|
- mikunyan-json
|
102
103
|
extensions: []
|
103
104
|
extra_rdoc_files: []
|
@@ -110,6 +111,7 @@ files:
|
|
110
111
|
- Rakefile
|
111
112
|
- bin/console
|
112
113
|
- bin/setup
|
114
|
+
- exe/mikunyan-image
|
113
115
|
- exe/mikunyan-json
|
114
116
|
- lib/mikunyan.rb
|
115
117
|
- lib/mikunyan/asset.rb
|
@@ -1033,7 +1035,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1033
1035
|
version: '0'
|
1034
1036
|
requirements: []
|
1035
1037
|
rubyforge_project:
|
1036
|
-
rubygems_version: 2.
|
1038
|
+
rubygems_version: 2.7.3
|
1037
1039
|
signing_key:
|
1038
1040
|
specification_version: 4
|
1039
1041
|
summary: Unity asset deserializer for Ruby
|