チェンジセット 1568
- コミット日時:
- 2008/10/10 21:18:06 (3 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
ruby/jsplash/trunk/rawswf.rb
r1534 r1568 1 1 module RawSWF 2 2 require 'base64' 3 require 'zlib' 3 4 4 5 def if_alpha(rgba) … … 22 23 23 24 return "#{hex2(red_val)}#{hex2(green_val)}#{hex2(blue_val)}" 25 end 26 27 class RawDefineBitsTag 28 def initialize(b64) 29 @raw = Base64.decode64(b64) 30 end 31 32 def table_data=(b64) 33 @raw_tbl = Base64.decode64(b64) 34 end 35 36 def export_file(fn) 37 tbl = @raw_tbl[2, @raw_tbl.length-4] 38 i = 0 39 40 File.open(fn, "w"){|f| 41 f.binmode 42 while(true) 43 f.putc(@raw[i]) 44 45 i += 1 46 47 break if @raw[i] == 0xff && (@raw[i+1] == 0xc0 || @raw[i+1] == 0xc1) 48 end 49 50 f.write(tbl) 51 f.write(@raw[i, @raw.length]) 52 } 53 end 54 end 55 56 class RawDefineBitsJPEG2Tag 57 def initialize(b64) 58 @raw = Base64.decode64(b64) 59 end 24 60 end 25 61 … … 195 231 s = nil 196 232 case stype 197 when 0 233 when 0x00 198 234 s = SwfFillStyle.new(SWFFILL_SOLID) 199 235 s.start_color = read_rgba 200 236 s.end_color = read_rgba 201 237 list << s 238 when 0x12 239 s = SwfFillStyle.new(SWFFILL_RADIAL_G) 240 read_matrix 241 read_matrix 242 raise "NOT IMPL" 202 243 else 203 244 raise "fill style type #{stype} is not supported" … … 206 247 207 248 return list 249 end 250 251 def read_matrix 252 @bs.align_byte 253 puts "--" 254 has_scale = (@bs.read_as_int(1) != 0) 255 if has_scale 256 s_bits = @bs.read_as_int(5) 257 sx = @bs.read_as_float(s_bits) 258 sy = @bs.read_as_float(s_bits) 259 260 STDERR.puts "S #{sx} #{sy}" 261 end 262 263 has_rotate = (@bs.read_as_int(1) != 0) 264 if has_rotate 265 r_bits = @bs.read_as_int(5) 266 kx = @bs.read_as_float(r_bits) 267 ky = @bs.read_as_float(r_bits) 268 269 STDERR.puts "K #{kx} #{ky}" 270 end 271 272 has_mov = (@bs.read_as_int(1) != 0) 273 if has_mov 274 m_bits = @bs.read_as_int(5) 275 mx = @bs.read_as_float(m_bits) 276 my = @bs.read_as_float(m_bits) 277 278 STDERR.puts "M #{mx} #{my}" 279 end 208 280 end 209 281 … … 370 442 end 371 443 444 def read_as_float(count) 445 sgn = read_as_int( 1 ) 446 v = read_as_int(count-1) 447 ival = ((v >> 16) & 0xffff).to_f 448 449 16.times {|i| 450 ival += 1.0 / (2**(i+1)).to_f if ((v << i) & 0x8000) != 0 451 } 452 453 return (sgn==0) ? ival : -ival 454 end 455 372 456 def read_short 373 457 read_as_int(8) | (read_as_int(8) << 8)

