| 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 ICOInfoHeader { |
|---|
| 31 |
private const INFO_HEADER_SIZE:uint = 16; |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
private var _width:uint; |
|---|
| 35 |
public function get width():uint { return _width; } |
|---|
| 36 |
|
|---|
| 37 |
private var _height:uint; |
|---|
| 38 |
public function get height():uint { return _height; } |
|---|
| 39 |
|
|---|
| 40 |
private var _count:uint; |
|---|
| 41 |
public function get count():uint { return _count; } |
|---|
| 42 |
|
|---|
| 43 |
private var _xHotSpot:uint; |
|---|
| 44 |
public function get xHotSpot():uint { return _xHotSpot; } |
|---|
| 45 |
|
|---|
| 46 |
private var _yHotSpot:uint; |
|---|
| 47 |
public function get yHotSpot():uint { return _yHotSpot; } |
|---|
| 48 |
|
|---|
| 49 |
private var _size:uint; |
|---|
| 50 |
public function get size():uint { return _size; } |
|---|
| 51 |
|
|---|
| 52 |
private var _offset:uint; |
|---|
| 53 |
public function get offset():uint { return _offset; } |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
public function ICOInfoHeader( stream:ByteArray ) { |
|---|
| 57 |
var bytes:ByteArray = new ByteArray(); |
|---|
| 58 |
bytes.endian = Endian.LITTLE_ENDIAN; |
|---|
| 59 |
|
|---|
| 60 |
try { |
|---|
| 61 |
stream.readBytes( bytes, 0, INFO_HEADER_SIZE ); |
|---|
| 62 |
|
|---|
| 63 |
_width = bytes.readUnsignedByte() || 256; |
|---|
| 64 |
_height = bytes.readUnsignedByte() || 256; |
|---|
| 65 |
_count = bytes.readUnsignedByte() || 256; |
|---|
| 66 |
|
|---|
| 67 |
bytes.position += 1; // reserved |
|---|
| 68 |
|
|---|
| 69 |
_xHotSpot = bytes.readUnsignedShort(); |
|---|
| 70 |
_yHotSpot = bytes.readUnsignedShort(); |
|---|
| 71 |
_size = bytes.readUnsignedInt(); |
|---|
| 72 |
_offset = bytes.readUnsignedInt(); |
|---|
| 73 |
} catch ( e:IOError ) { |
|---|
| 74 |
trace("error: icon info header"); |
|---|
| 75 |
throw new VerifyError("invalid icon info header"); |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
} |
|---|
| 79 |
} |
|---|