| 1 |
/** |
|---|
| 2 |
* com.voidelement.images.psd.PSDParser Class for ActionScript 3.0 |
|---|
| 3 |
* |
|---|
| 4 |
* @author Copyright (c) 2007 munegon |
|---|
| 5 |
* @version 0.2 |
|---|
| 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 |
package com.voidelement.images.psd.compression { |
|---|
| 25 |
import com.voidelement.images.psd.compression.proto.RLEParser; |
|---|
| 26 |
|
|---|
| 27 |
import flash.utils.ByteArray; |
|---|
| 28 |
|
|---|
| 29 |
public class ImageRLEParser extends RLEParser { |
|---|
| 30 |
private var _channelsData:Array = new Array(); |
|---|
| 31 |
public function get channelsData():Array { return _channelsData; } |
|---|
| 32 |
|
|---|
| 33 |
public function ImageRLEParser( channels:int, width:int, height:int, stream:ByteArray ) { |
|---|
| 34 |
var lines:Array = new Array( height * channels ); |
|---|
| 35 |
var i:int; |
|---|
| 36 |
|
|---|
| 37 |
for ( i = 0; i < height * channels; ++i ) { |
|---|
| 38 |
lines[i] = stream.readUnsignedShort(); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
for ( var channel:int = 0; channel < channels; ++channel ){ |
|---|
| 42 |
var data:ByteArray = new ByteArray(); |
|---|
| 43 |
|
|---|
| 44 |
for ( i = 0; i < height; ++i ) { |
|---|
| 45 |
var line:ByteArray = new ByteArray(); |
|---|
| 46 |
stream.readBytes( line, 0, lines[channel*height+i] ); |
|---|
| 47 |
data.writeBytes( unpack( line ) ); |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
channelsData[channel] = data; |
|---|
| 51 |
} |
|---|
| 52 |
} |
|---|
| 53 |
} |
|---|
| 54 |
} |
|---|