//public string GetIdAsFOURCC() //{ // return "" + (char)((this.ID >> 24) & 0xff) + (char)((this.ID >> 16) & 0xff) + (char)((this.ID >> 8) & 0xff) + (char)(this.ID & 0xff); //} public void Write(BinaryPSDWriter writer) { writer.Write("8BIM"); writer.Write(this.ID); writer.WritePascalString(this.Name); writer.StartLengthBlock(typeof(uint)); this.SubWrite(writer); writer.EndLengthBlock(); writer.PadToNextMultiple(2); //if (writer.GetCurrentBlockLength() % 2 == 1) // writer.Write((byte)0); }
public void Write(BinaryPSDWriter writer) { writer.WritePSDRectangle(this._rect); // new Rectangle(this._rect).Write(writer); writer.Write((ushort)this._channels.Count); foreach (Channel channel in this._channels.Values) { channel.Write(writer); } writer.Write("8BIM"); BlendKeys bk = (BlendKeys)Enum.Parse(typeof(BlendKeys), this.BlendKey); _blendKeysPsd bkPsd = (_blendKeysPsd)(int)bk; writer.Write(bkPsd.ToString()); writer.Write(this.Opacity); writer.Write(this.Clipping); writer.Write(this.Flags); writer.Write((byte)0); //padding writer.StartLengthBlock(typeof(uint)); if (this._mask != null || (this._blendRanges != null && this._blendRanges.Count > 0) || !string.IsNullOrEmpty(this.Name)) { if (this._mask != null) this._mask.Write(writer); else writer.Write((uint)0); //TODO: should be a static of Mask..? //blending ranges writer.Write((uint)this._blendRanges.Count * 4); foreach (System.Drawing.Color clr in this._blendRanges) writer.Write((uint)clr.ToArgb()); //why is there padding here? Seems unnecessary. long namePosition = writer.BaseStream.Position; writer.WritePascalString(this.Name); int paddingBytes = (int)((writer.BaseStream.Position - namePosition) % 4); for (int i = 0; i < paddingBytes; i++) writer.Write((byte)0); foreach (LayerResource res in this._resources.Values) { res.Write(writer); } } writer.EndLengthBlock(); }
public void Write(BinaryPSDWriter writer) { writer.WritePSDRectangle(this._rect); // new Rectangle(this._rect).Write(writer); writer.Write((ushort)this._channels.Count); foreach (Channel channel in this._channels.Values) { channel.Write(writer); } writer.Write("8BIM"); BlendKeys bk = (BlendKeys)Enum.Parse(typeof(BlendKeys), this.BlendKey); _blendKeysPsd bkPsd = (_blendKeysPsd)(int)bk; writer.Write(bkPsd.ToString()); writer.Write(this.Opacity); writer.Write(this.Clipping); writer.Write(this.Flags); writer.Write((byte)0); //padding writer.StartLengthBlock(typeof(uint)); if (this._mask != null || (this._blendRanges != null && this._blendRanges.Count > 0) || !string.IsNullOrEmpty(this.Name)) { if (this._mask != null) { this._mask.Write(writer); } else { writer.Write((uint)0); //TODO: should be a static of Mask..? } //blending ranges writer.Write((uint)this._blendRanges.Count * 4); foreach (System.Drawing.Color clr in this._blendRanges) { writer.Write((uint)clr.ToArgb()); } //why is there padding here? Seems unnecessary. long namePosition = writer.BaseStream.Position; writer.WritePascalString(this.Name); int paddingBytes = (int)((writer.BaseStream.Position - namePosition) % 4); for (int i = 0; i < paddingBytes; i++) { writer.Write((byte)0); } foreach (LayerResource res in this._resources.Values) { res.Write(writer); } } writer.EndLengthBlock(); }