public BevelEffect(PsdBinaryReader r, string key) { m_key = key; uint version = r.ReadUInt32(); this.Angle = r.ReadUInt32(); this.Strength = r.ReadUInt32(); this.Blur = r.ReadUInt32(); this.BlendModeKey = this.ReadBlendKey(r); this.ShadowBlendModeKey = this.ReadBlendKey(r); this.Color = r.ReadPSDColor(16, true); this.ShadowColor = r.ReadPSDColor(16, true); this.BevelStyle = r.ReadByte(); this.Opacity = r.ReadByte(); this.ShadowOpacity = r.ReadByte(); this.Enabled = r.ReadBoolean(); this.UseGlobalAngle = r.ReadBoolean(); this.Inverted = r.ReadBoolean(); switch (version) { case 0: break; case 2: Color someColor = r.ReadPSDColor(16, true); Color someColor2 = r.ReadPSDColor(16, true); break; } }
public GlowEffect(PsdBinaryReader r, string key) { m_key = key; uint version = r.ReadUInt32(); //two version this.Blur = r.ReadUInt32(); this.Intensity = r.ReadUInt32(); Color golwColor = readColor(r); this.BlendModeKey = this.ReadBlendKey(r); this.Enabled = r.ReadBoolean(); this.Opacity = r.ReadByte(); this.Color = Util.FromArgb(Opacity, golwColor); switch (version) { case 0: break; case 2: //TODO! if (this.Inner) { this.Unknown = r.ReadByte(); } this.UnknownColor = r.ReadPSDColor(16, true); //unknown color // byte[] Data = r.ReadBytes((int)r.BytesToEnd); break; } }
public VersionInfo(PsdBinaryReader reader, string name) : base(name) { Version = reader.ReadUInt32(); HasRealMergedData = reader.ReadBoolean(); ReaderName = reader.ReadUnicodeString(); WriterName = reader.ReadUnicodeString(); FileVersion = reader.ReadUInt32(); }
public VersionInfo(PsdBinaryReader reader, string name) : base(name) { Version = reader.ReadUInt32(); HasRealMergedData = reader.ReadBoolean(); ReaderName = reader.ReadUnicodeString(); WriterName = reader.ReadUnicodeString(); FileVersion = reader.ReadUInt32(); }
public ShadowEffect(PsdBinaryReader r, string key) { m_key = key; int version = r.ReadInt32(); this.Blur = r.ReadUInt32(); this.Intensity = r.ReadUInt32(); this.Angle = r.ReadUInt32(); this.Distance = r.ReadUInt32(); Color shadowColor = r.ReadPSDColor(16, true); this.BlendModeKey = this.ReadBlendKey(r); this.Enabled = r.ReadBoolean(); this.UseGlobalAngle = r.ReadBoolean(); this.Opacity = r.ReadByte(); NativeColor = r.ReadPSDColor(16, true); this.Color = Util.FromArgb(Opacity, shadowColor); }
public GradientMap(PsdBinaryReader r, string key) { m_key = key; uint version = r.ReadUInt32(); //Is gradient reversed bool isReversed = r.ReadBoolean(); bool isDithered = r.ReadBoolean(); string gradientName = r.ReadUnicodeString(); ushort numColors = r.ReadUInt16(); ColorStops = new List <ColorStop>(numColors); for (int i = 0; i < numColors; i++) { ColorStops.Add(new ColorStop(r)); } }
public Metadata(PsdBinaryReader reader) { string signature = reader.ReadAsciiChars(4); if (signature != "8BIM") { throw new PsdInvalidException("Could not read LayerInfo due to signature mismatch." + signature); } Key = reader.ReadAsciiChars(4); bool sheetCopy = reader.ReadBoolean(); byte[] padding = reader.ReadBytes(3); uint length = reader.ReadUInt32(); byte[] datas = reader.ReadBytes((int)length); }
public Layer(PsdBinaryReader reader, PsdFile psdFile) : this(psdFile) { Util.DebugMessage(reader.BaseStream, "Load, Begin, Layer"); Rect = reader.ReadRectangle(); //----------------------------------------------------------------------- // Read channel headers. Image data comes later, after the layer header. int numberOfChannels = reader.ReadUInt16(); for (int channel = 0; channel < numberOfChannels; channel++) { var ch = new Channel(reader, this); Channels.Add(ch); } //----------------------------------------------------------------------- // var signature = reader.ReadAsciiChars(4); if (signature != "8BIM") { throw (new PsdInvalidException("Invalid signature in layer header.")); } BlendModeKey = reader.ReadAsciiChars(4); Opacity = reader.ReadByte(); Clipping = reader.ReadBoolean(); var flagsByte = reader.ReadByte(); flags = new BitVector32(flagsByte); reader.ReadByte(); //padding //----------------------------------------------------------------------- // This is the total size of the MaskData, the BlendingRangesData, the // Name and the AdjustmentLayerInfo. var extraDataSize = reader.ReadUInt32(); var extraDataStartPosition = reader.BaseStream.Position; Masks = new MaskInfo(reader, this); BlendingRangesData = new BlendingRanges(reader, this); Name = reader.ReadPascalString(4); //----------------------------------------------------------------------- // Process Additional Layer Information long adjustmentLayerEndPos = extraDataStartPosition + extraDataSize; while (reader.BaseStream.Position < adjustmentLayerEndPos) { var layerInfo = LayerInfoFactory.Load(reader, psdFile: this.PsdFile, globalLayerInfo: false); AdditionalInfo.Add(layerInfo); } foreach (var adjustmentInfo in AdditionalInfo) { switch (adjustmentInfo.Key) { case "luni": Name = ((LayerUnicodeName)adjustmentInfo).Name; break; } } Util.DebugMessage(reader.BaseStream, "Load, End, Layer, {0}", Name); PsdFile.LoadContext.OnLoadLayerHeader(this); }
public BooleanStructure(PsdBinaryReader reader) { Value = reader.ReadBoolean(); }
public static DynVal ReadValue(PsdBinaryReader r, bool skipKey) { DynVal vt = new DynVal(); if (!skipKey) { vt.Name = GetMeaningOfFourCC(ReadSpecialString(r)); } //TODO: should be assigned a sequential number? vt.Type = parseTypeString(r.ReadAsciiChars(4)); switch (vt.Type) { case OSType.tdta: // unknown r.ReadUInt32(); TdTaParser p = new TdTaParser(r); object o = p.ParseOneTree(); vt.Value = o; break; case OSType.Reference: vt.References = ReadValues(r, true); break; case OSType.Descriptor: vt.Value = DynVal.ReadDescriptor(r); break; case OSType.List: vt.Children = ReadValues(r, true); break; case OSType.Double: vt.Value = r.ReadDouble(); break; case OSType.UnitFloat: //Unif float string tst = GetMeaningOfFourCC(r.ReadAsciiChars(4)); //#Prc #Pxl #Ang = percent / pixels / angle? double d = r.ReadDouble(); tst += ": " + d; vt.Value = tst; break; case OSType.Enumerated: string typeID = ReadSpecialString(r); string enumVal = ReadSpecialString(r); vt.Value = GetMeaningOfFourCC(typeID) + "." + GetMeaningOfFourCC(enumVal); break; case OSType.Integer: vt.Value = r.ReadInt32(); //4 byte integer break; case OSType.Boolean: vt.Value = r.ReadBoolean(); break; case OSType.String: vt.Value = r.ReadUnicodeString(); //r.ReadPSDUnicodeString(); break; case OSType.LargeInteger: vt.Value = r.ReadInt64(); break; case OSType.Class: vt.Value = ReadClass(r); break; case OSType.Alias: vt.Value = ReadAlias(r); break; case OSType.PropertyRef: vt.Value = ReadProperty(r); break; case OSType.EnumeratedRef: vt.Value = ReadEnumeratedRef(r); break; case OSType.OffestRef: vt.Value = ReadOffset(r); break; case OSType.IdentifierRef: vt.Value = r.ReadAsciiChars(4); break; case OSType.IndexRef: vt.Value = r.ReadUInt16(); break; case OSType.NameRef: vt.Value = r.ReadAsciiChars(4); break; default: throw new Exception("Unhandled type: " + vt.Type); } return(vt); }
public static DynVal ReadValue(PsdBinaryReader r, bool skipKey) { DynVal vt = new DynVal(); if (!skipKey) { vt.Name = GetMeaningOfFourCC(ReadSpecialString(r)); } //TODO: should be assigned a sequential number? vt.Type = parseTypeString(System.Text.Encoding.ASCII.GetString(r.ReadBytes(4))); switch (vt.Type) { case OSType.tdta: // unknown r.ReadUInt32(); TdTaParser p = new TdTaParser(r); object o = p.ParseOneTree(); vt.Value = o; break; case OSType.Descriptor: vt = DynVal.ReadDescriptor(r); break; case OSType.List: vt.Children = ReadValues(r, true); break; case OSType.Double: vt.Value = r.ReadDouble(); break; case OSType.UnitFloat: //Unif float //TODO: need a specific type for this, with a double and a type (percent/pixel)? string tst = GetMeaningOfFourCC(System.Text.Encoding.ASCII.GetString(r.ReadBytes(4))); //#Prc #Pxl #Ang = percent / pixels / angle? double d = r.ReadDouble(); tst += ": " + d; vt.Value = tst; break; case OSType.Enumerated: string namesp = ReadSpecialString(r); string item = ReadSpecialString(r); //vt.Value = namesp + "." + item; //TODO: cast to real enum vt.Value = GetMeaningOfFourCC(namesp) + "." + GetMeaningOfFourCC(item); break; case OSType.Integer: vt.Value = r.ReadInt32(); //4 byte integer break; case OSType.Boolean: vt.Value = r.ReadBoolean(); break; case OSType.String: vt.Value = r.ReadUnicodeString(); //r.ReadPSDUnicodeString(); break; default: throw new Exception("Unhandled type: " + vt.Type); } return(vt); }
public Layer(PsdBinaryReader reader, PsdFile psdFile) : this(psdFile) { Rect = reader.ReadRectangle(); //----------------------------------------------------------------------- // Read channel headers. Image data comes later, after the layer header. int numberOfChannels = reader.ReadUInt16(); for (int channel = 0; channel < numberOfChannels; channel++) { var ch = new Channel(reader, this); Channels.Add(ch); } //----------------------------------------------------------------------- // var signature = reader.ReadAsciiChars(4); if (signature != "8BIM") throw (new PsdInvalidException("Invalid signature in layer header.")); BlendModeKey = reader.ReadAsciiChars(4); Opacity = reader.ReadByte(); Clipping = reader.ReadBoolean(); var flagsByte = reader.ReadByte(); flags = new BitVector32(flagsByte); reader.ReadByte(); //padding //----------------------------------------------------------------------- // This is the total size of the MaskData, the BlendingRangesData, the // Name and the AdjustmentLayerInfo. var extraDataSize = reader.ReadUInt32(); var extraDataStartPosition = reader.BaseStream.Position; Masks = new MaskInfo(reader, this); BlendingRangesData = new BlendingRanges(reader, this); Name = reader.ReadPascalString(4); //----------------------------------------------------------------------- // Process Additional Layer Information long adjustmentLayerEndPos = extraDataStartPosition + extraDataSize; while (reader.BaseStream.Position < adjustmentLayerEndPos) { var layerInfo = LayerInfoFactory.Load(reader); AdditionalInfo.Add(layerInfo); } foreach (var adjustmentInfo in AdditionalInfo) { switch (adjustmentInfo.Key) { case "luni": Name = ((LayerUnicodeName)adjustmentInfo).Name; break; } } }
public Layer(PsdBinaryReader reader, PsdFile psdFile) : this(psdFile) { IsText = false; Rect = reader.ReadRectangle(); //----------------------------------------------------------------------- // Read channel headers. Image data comes later, after the layer header. int numberOfChannels = reader.ReadUInt16(); for (int channel = 0; channel < numberOfChannels; channel++) { var ch = new Channel(reader, this); Channels.Add(ch); } //----------------------------------------------------------------------- // var signature = reader.ReadAsciiChars(4); if (signature != "8BIM") { throw (new PsdInvalidException("Invalid signature in layer header.")); } BlendModeKey = reader.ReadAsciiChars(4); Opacity = reader.ReadByte(); Clipping = reader.ReadBoolean(); var flagsByte = reader.ReadByte(); flags = new BitVector32(flagsByte); reader.ReadByte(); //padding //----------------------------------------------------------------------- // This is the total size of the MaskData, the BlendingRangesData, the // Name and the AdjustmentLayerInfo. var extraDataSize = reader.ReadUInt32(); var extraDataStartPosition = reader.BaseStream.Position; Masks = new MaskInfo(reader, this); BlendingRangesData = new BlendingRanges(reader, this); Name = reader.ReadPascalString(4); //----------------------------------------------------------------------- // Process Additional Layer Information long adjustmentLayerEndPos = extraDataStartPosition + extraDataSize; while (reader.BaseStream.Position < adjustmentLayerEndPos) { var layerInfo = LayerInfoFactory.Load(reader); AdditionalInfo.Add(layerInfo); } foreach (var adjustmentInfo in AdditionalInfo) { switch (adjustmentInfo.Key) { case "luni": Name = ((LayerUnicodeName)adjustmentInfo).Name; break; case "TySh": IsText = true; LayerText = (LayerText)adjustmentInfo; break; case "lrFX": Effects = (EffectsLayer)adjustmentInfo; break; case "lfx2": BaseEffect = (ObjectBasedEffect)adjustmentInfo; break; } } }