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;
}
我有其他的四個專業編碼器與官方文檔一起研究這個代碼,而且他們都沒有發現任何問題。
感謝您的任何幫助。