| 1 |
/** |
|---|
| 2 |
* com.voidelement.images.ico.ICODecoder Class for ActionScript 3.0 |
|---|
| 3 |
* |
|---|
| 4 |
* @author Copyright (c) 2008 munegon |
|---|
| 5 |
* @version 1.0 |
|---|
| 6 |
* |
|---|
| 7 |
* @link http://www.voidelement.com/ |
|---|
| 8 |
* @link http://void.heteml.jp/blog/ |
|---|
| 9 |
* |
|---|
| 10 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 11 |
* you may not use this file except in compliance with the License. |
|---|
| 12 |
* You may obtain a copy of the License at |
|---|
| 13 |
* |
|---|
| 14 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 15 |
* |
|---|
| 16 |
* Unless required by applicable law or agreed to in writing, software |
|---|
| 17 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 18 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|---|
| 19 |
* either express or implied. See the License for the specific language |
|---|
| 20 |
* governing permissions and limitations under the License. |
|---|
| 21 |
*/ |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
package com.voidelement.images.ico { |
|---|
| 26 |
import flash.display.BitmapData; |
|---|
| 27 |
import flash.errors.IOError; |
|---|
| 28 |
import flash.utils.ByteArray; |
|---|
| 29 |
import flash.utils.Endian; |
|---|
| 30 |
|
|---|
| 31 |
public class ICODecoder { |
|---|
| 32 |
private static var _verbose:Boolean = false; |
|---|
| 33 |
private static function get verbose():Boolean { return _verbose; } |
|---|
| 34 |
private static function set verbose( value:Boolean ):void { _verbose = value; } |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
private var _header:ICOFileHeader; |
|---|
| 38 |
public function get header():ICOFileHeader { return _header; } |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
/** |
|---|
| 42 |
* コンストラクタ |
|---|
| 43 |
*/ |
|---|
| 44 |
public function ICODecoder() { |
|---|
| 45 |
|
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
/** |
|---|
| 50 |
* デコード |
|---|
| 51 |
* |
|---|
| 52 |
* @param デコードしたいICOファイルのバイナリデータ |
|---|
| 53 |
*/ |
|---|
| 54 |
public function decode( stream:ByteArray ):Array { |
|---|
| 55 |
_header = new ICOFileHeader( stream ); |
|---|
| 56 |
|
|---|
| 57 |
var info_arr:Array = new Array(); |
|---|
| 58 |
for ( var i:int = 0; i < header.num; ++i ) { |
|---|
| 59 |
info_arr.push( new ICOInfoHeader( stream ) ); |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
var image_arr:Array = new Array(); |
|---|
| 63 |
for ( var j:int = 0; j < header.num; ++j ) { |
|---|
| 64 |
image_arr.push( new ICOImageData( stream ) ); |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
return image_arr; |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
/** |
|---|
| 72 |
* ログ出力 |
|---|
| 73 |
*/ |
|---|
| 74 |
public static function log( message:String ):void { |
|---|
| 75 |
if ( verbose ) { |
|---|
| 76 |
trace( message ); |
|---|
| 77 |
} |
|---|
| 78 |
} |
|---|
| 79 |
} |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|