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

リビジョン 244, 2.9 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 BitmapInfoHeader {
31                 private const BITMAP_INFO_HEADER_SIZE:uint = 40;
32                
33                
34                 private var _width:int;
35                 public function get width():int { return _width; }
36                
37                 private var _height:int;
38                 public function get height():int { return _height; }
39                
40                 private var _planes:uint;
41                 public function get planes():uint { return _planes; }
42                
43                 private var _bitsPerPixel:uint;
44                 public function get bitsPerPixel():uint { return _bitsPerPixel; }
45                
46                 private var _compression:uint;
47                 public function get compression():uint { return _compression; }
48                
49                 private var _sizeImage:uint;
50                 public function get sizeImage():uint { return _sizeImage; }
51                
52                 private var _xPixPerMeter:int;
53                 public function get xPixPerMeter():int { return _xPixPerMeter; }
54                
55                 private var _yPixPerMeter:int;
56                 public function get yPixPerMeter():int { return _yPixPerMeter; }
57                
58                 private var _colorUsed:uint;
59                 public function get colorUsed():uint { return _colorUsed; }
60                
61                 private var _colorImportant:uint;
62                 public function get colorImportant():uint { return _colorImportant; }
63                
64                
65                 public function BitmapInfoHeader( stream:ByteArray ) {
66                         var bytes:ByteArray = new ByteArray();
67                         bytes.endian = Endian.LITTLE_ENDIAN;
68                        
69                         try {
70                                 stream.readBytes( bytes, 0, BITMAP_INFO_HEADER_SIZE );
71                                
72                                 if ( bytes.readUnsignedInt() != BITMAP_INFO_HEADER_SIZE ) {
73                                         throw new VerifyError("invalid bitmap info header size");
74                                 }
75                                
76                                 _width  = bytes.readInt();
77                                 _height = bytes.readInt() / 2;
78                                 _planes = bytes.readUnsignedShort();
79                                 _bitsPerPixel = bytes.readUnsignedShort();
80                                
81                                 _compression = bytes.readUnsignedInt();
82                                 _sizeImage = bytes.readUnsignedInt();
83                                 _xPixPerMeter = bytes.readInt();
84                                 _yPixPerMeter = bytes.readInt();
85                                 _colorUsed = bytes.readUnsignedInt();
86                                 _colorImportant = bytes.readUnsignedInt();
87                         } catch ( e:IOError ) {
88                                 throw new VerifyError("invalid bitmap info header");
89                         }
90                 }
91         }
92 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。