I'm basing this off the official PSD File Format documentation
I can read raw data just fine, and none of my files have ZIP compression. All I need is to get the RLE stuff to work.
Right now, I'm not interested in decompressing the information. I just want to read it in and store it in memory in its compressed form. I'll deal with decompressing later.
All I'm doing is computing the size of the RLE data, and reading it in bulk, chann开发者_StackOverflowel by channel. This is the function I'm using to compute the size of the channel data:
Written in ActionScript 3.0
////////////////////////////////////////////////////////////////////
// Compute RLE Data Size
////////////////////////////////////////////////////////////////////
protected function _computeRLESize( data_ : ByteArray, record_ : PSDLayerRecord ) : int
{
var numScanlines : int;
var ii : int;
var size : int;
var totalSize : int;
var pad : int;
// Compute our total time
totalSize = ( record_.bottom - record_.top ) * ( record_.right - record_.left );
// Find our number of scanlines
numScanlines = record_.bottom - record_.top;
// Initialize our size
size = 0;
// Loop through each line to see how many bytes we have
trace( "Num Scanlines: " + numScanlines );
for ( ii = 0; ii < numScanlines; ii++ )
{
pad = data_.readShort();
if ( pad % 2 != 0 ) pad++;
size += pad;
}
// Output our compression
trace( "Image is at " + size + " / " + totalSize + " compression" );
// When we're done, back up to the beginning so we can read it
data_.position -= numScanlines * 2;
// Return our size
return size + numScanlines * 2;
}
I've had four other professional coders study this code together with the official documentation, and none of them could find anything wrong with it.
Thanks for any help.
Do you just want to know the channel pixel data size (regarding of RLE or RAW compression)? You can get the size from the channels info in layer record.
精彩评论