接下来的Color mode Data跟Image Resources经过研究,在这里,这部分数据没有用到,所以直接把他们所占用的字节长度给读取出来过滤掉:
Color mode data:
public final class PsdColorModeDataVo { public var len:int; public var data:ByteArray; public function parse(ba:FileStream):void { data = new ByteArray(); len = ba.readInt(); //rgb是0 if(0 != len) { ba.readBytes(data, 0, len); } } }
Image Resources:
public final class PsdImageResourcesVo { public var len:int; public var data:ByteArray; private var osType:String; private var id:Number; private var pName:String; private var size:int; public function parse(ba:FileStream):void { data = new ByteArray(); len = ba.readInt(); if(0 != len) { ba.readBytes(data, 0, len); osType = data.readUTFBytes(4); id = data.readShort(); pName = data.readUTF(); size = data.readInt(); } } }
Layer and Mask才是我们要重点关注的部分,这部分包含了所有的图层信息,后面也只是对这部分的数据进行操作,所以这里先把它的数据读取出来,存着:
public final class PsdLayerAndMaskVo { public var len:int; public var data:ByteArray; public function parse(ba:FileStream):void { data = new ByteArray(); len = ba.readInt(); if(0 != len) { ba.readBytes(data, 0, len); } } }
经过上面的几次读取,剩下来的就是Image data部分,这部分也不管它。