0
我立足这一关the official PSD File Format documentation读一个Photoshop(PSD)的RLE压缩图层文件
我可以读取原始数据就好了,没有我的档案有ZIP压缩。所有我需要的是让RLE东西的工作。
现在,我没有兴趣在解压缩的信息。我只是想读取它并将其存储在内存中的压缩形式。我稍后会处理解压缩。
我正在做的所有事情是计算RLE数据的大小,然后逐个通道地批量读取它。这是我使用来计算通道数据的大小的功能: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;
}
我有其他的四个专业编码器与官方文档一起研究这个代码,而且他们都没有发现任何问题。
感谢您的任何帮助。