root/as3/ICODecoder/src/com/voidelement/images/ico/ICOFileHeader.as

リビジョン 244, 1.7 kB (コミッタ: munegon, コミット時期: 1 年 前)

--

Line 
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.errors.IOError;
27         import flash.utils.ByteArray;
28         import flash.utils.Endian;
29        
30         public class ICOFileHeader {
31                 private const FILE_HEADER_SIZE:uint = 6;
32                
33                
34                 private var _type:uint;
35                 public function get type():uint { return _type; }
36                
37                 private var _num:uint;
38                 public function get num():uint { return _num; }
39                
40                
41                 public function ICOFileHeader( stream:ByteArray ) {
42                         var bytes:ByteArray = new ByteArray();
43                         bytes.endian = Endian.LITTLE_ENDIAN;
44                        
45                         try {
46                                 stream.readBytes( bytes, 0, FILE_HEADER_SIZE );
47                                
48                                 if ( bytes.readShort() != 0x00 ){
49                                         throw new VerifyError("invalid icon file header signature");
50                                 }
51                                
52                                 _type = bytes.readUnsignedShort();
53                                 _num = bytes.readUnsignedShort();
54                         } catch ( e:IOError ) {
55                                 throw new VerifyError("invalid file icon header size");
56                         }
57                 }
58         }
59 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。