mikunyan 3.9.2 → 3.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0674f5a0c11d5d34d86e845f11aaddbf72256047
4
- data.tar.gz: 5ebf875cc82f0b2678092aa87171c2fb96a134df
3
+ metadata.gz: f06ec3ed2d2eaaea9e59be6ff6ffa0622e2b20b6
4
+ data.tar.gz: c293990ac585f20bdd3ee041367fb6b92ba26a05
5
5
  SHA512:
6
- metadata.gz: f586f5241de8531bd25c27a04e4c8e6b26e50075aba2a816ff41b9b4e3dae1da178f1f4e91d5524d36429f15229b9079f11ed03eb694f632755d4692545c9c08
7
- data.tar.gz: 39358b3351addc3ea54b93f23712b46184b006e56c8894971839b903620a07b9ae243739ff2f3db614f09e4f36659e12b8ca16a49e00830f44c5460fc3b6fb20
6
+ metadata.gz: 0511ea6b9a57d4623946497a5485f4c31b5f63094d8087f5e432cf63987866c2a48e7fb795472fe1d0929f0f423fa5635f5464632016560db40d2417ba0c55ec
7
+ data.tar.gz: 85628047ca5c0ab33497ec82eac07992fde156352fec1afa6fc2eeb8c9a698dc205b1fac7d4b10183a72f3386bb045e60661ccf7738ca1d4de33044ad790ea36
data/README.md CHANGED
@@ -104,7 +104,7 @@ obj.key
104
104
 
105
105
  You can get png file directly from Texture2D asset. Output object's class is `ChunkyPNG::Image`.
106
106
 
107
- Some basic texture formats (1--5, 7, 9, 13--20, 22, 62, and 63), ETC_RGB4 (34), ETC2 (45, 47), and ASTC (48--59) are available.
107
+ Some basic texture formats (15, 7, 9, 1320, 22, 62, and 63), ETC_RGB4 (34), ETC2 (45, 47), and ASTC (4859) are available.
108
108
 
109
109
  ```ruby
110
110
  require 'mikunyan/decoders'
@@ -345,24 +345,20 @@ module Mikunyan
345
345
  sh.reverse! if seed & 1 == 0
346
346
  seeds.map!.with_index{|e, i| e >> sh[i % 2]}
347
347
 
348
- @partition = Array.new(@bw * @bh)
349
-
350
- for y in 0...@bh
351
- for x in 0...@bw
352
- idx = x + y * @bw
353
-
354
- if small_block
355
- x <<= 1
356
- y <<= 1
357
- end
348
+ @partition = (0...@bw * @bh).map do |i|
349
+ x = i % @bw
350
+ y = i / @bw
351
+ if small_block
352
+ x <<= 1
353
+ y <<= 1
354
+ end
358
355
 
359
- a = (seeds[0] * x + seeds[1] * y + (rnum >> 14)) & 0x3f
360
- b = (seeds[2] * x + seeds[3] * y + (rnum >> 10)) & 0x3f
361
- c = @part_num < 3 ? 0 : (seeds[4] * x + seeds[5] * y + (rnum >> 6)) & 0x3f
362
- d = @part_num < 4 ? 0 : (seeds[6] * x + seeds[7] * y + (rnum >> 2)) & 0x3f
356
+ a = (seeds[0] * x + seeds[1] * y + (rnum >> 14)) & 0x3f
357
+ b = (seeds[2] * x + seeds[3] * y + (rnum >> 10)) & 0x3f
358
+ c = @part_num < 3 ? 0 : (seeds[4] * x + seeds[5] * y + (rnum >> 6)) & 0x3f
359
+ d = @part_num < 4 ? 0 : (seeds[6] * x + seeds[7] * y + (rnum >> 2)) & 0x3f
363
360
 
364
- @partition[idx] = 3 - [d, c, b, a].each_with_index.max[1]
365
- end
361
+ 3 - [d, c, b, a].each_with_index.max[1]
366
362
  end
367
363
  end
368
364
  end
@@ -359,14 +359,14 @@ module Mikunyan
359
359
  def self.decode_etc1(width, height, bin)
360
360
  bw = (width + 3) / 4
361
361
  bh = (height + 3) / 4
362
- ret = ChunkyPNG::Image.new(bw * 4, bh * 4)
362
+ ret = ChunkyPNG::Image.new(bh * 4, bw * 4)
363
363
  bh.times do |by|
364
364
  bw.times do |bx|
365
365
  block = decode_etc1_block(BinUtils.get_sint64_be(bin, (bx + by * bw) * 8))
366
- ret.replace!(ChunkyPNG::Image.from_rgb_stream(4, 4, block), bx * 4, by * 4)
366
+ ret.replace!(ChunkyPNG::Image.from_rgb_stream(4, 4, block), by * 4, bx * 4)
367
367
  end
368
368
  end
369
- ret.crop(0, 0, width, height)
369
+ ret.crop(0, 0, height, width).rotate_left
370
370
  end
371
371
 
372
372
  # Decode image from ETC2 compressed binary
@@ -377,14 +377,14 @@ module Mikunyan
377
377
  def self.decode_etc2rgb(width, height, bin)
378
378
  bw = (width + 3) / 4
379
379
  bh = (height + 3) / 4
380
- ret = ChunkyPNG::Image.new(bw * 4, bh * 4)
380
+ ret = ChunkyPNG::Image.new(bh * 4, bw * 4)
381
381
  bh.times do |by|
382
382
  bw.times do |bx|
383
383
  block = decode_etc2_block(BinUtils.get_sint64_be(bin, (bx + by * bw) * 8))
384
- ret.replace!(ChunkyPNG::Image.from_rgb_stream(4, 4, block), bx * 4, by * 4)
384
+ ret.replace!(ChunkyPNG::Image.from_rgb_stream(4, 4, block.join), by * 4, bx * 4)
385
385
  end
386
386
  end
387
- ret.crop(0, 0, width, height)
387
+ ret.crop(0, 0, height, width).rotate_left
388
388
  end
389
389
 
390
390
  # Decode image from ETC2 Alpha8 compressed binary
@@ -395,17 +395,17 @@ module Mikunyan
395
395
  def self.decode_etc2rgba8(width, height, bin)
396
396
  bw = (width + 3) / 4
397
397
  bh = (height + 3) / 4
398
- mem = Fiddle::Pointer.malloc(bw * bh * 64)
398
+ ret = ChunkyPNG::Image.new(bh * 4, bw * 4)
399
399
  bh.times do |by|
400
400
  bw.times do |bx|
401
401
  alpha = decode_etc2alpha_block(BinUtils.get_int64_be(bin, (bx + by * bw) * 16))
402
402
  block = decode_etc2_block(BinUtils.get_int64_be(bin, (bx + by * bw) * 16 + 8))
403
- 16.times do |i|
404
- mem[((i / 4 + bx * 4) + (i % 4 + by * 4) * bw * 4) * 4, 4] = block[i] + alpha[i]
405
- end
403
+ mem = String.new(capacity: 64)
404
+ 16.times{|i| mem << block[i] + alpha[i]}
405
+ ret.replace!(ChunkyPNG::Image.from_rgba_stream(4, 4, mem), by * 4, bx * 4)
406
406
  end
407
407
  end
408
- ChunkyPNG::Image.from_rgba_stream(bw * 4, bh * 4, mem.to_str).crop(0, 0, width, height)
408
+ ret.crop(0, 0, height, width).rotate_left
409
409
  end
410
410
 
411
411
  # Decode image from ASTC compressed binary
@@ -498,10 +498,12 @@ module Mikunyan
498
498
  colors[1] = colors[1] | (colors[1] >> 5 & 0x70707)
499
499
  end
500
500
 
501
- (0...16).map do |i|
501
+ mem = Fiddle::Pointer.malloc(48)
502
+ 16.times do |i|
502
503
  modifier = Etc1ModifierTable[codes[subblocks[i]]][bin[i]]
503
- etc1colormod(colors[subblocks[i]], bin[i + 16] == 0 ? modifier : -modifier)
504
+ mem[i * 3, 3] = etc1colormod(colors[subblocks[i]], bin[i + 16] == 0 ? modifier : -modifier)
504
505
  end
506
+ mem.to_str
505
507
  end
506
508
 
507
509
  def self.etc1colormod(color, modifier)
@@ -1,4 +1,4 @@
1
1
  module Mikunyan
2
2
  # version string
3
- VERSION = "3.9.2"
3
+ VERSION = "3.9.3"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mikunyan
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.2
4
+ version: 3.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ishotihadus