Example #1
0
        public Shadow(PhotoshopFile.Layer.AdjustmentLayerInfo info)
        {
            this.m_data  = info.Data;
            this.m_key   = info.Key;
            this.m_layer = info.Layer;

            BinaryReverseReader r = this.DataReader;

            //string blendModeSignature = null;

            int version = r.ReadInt32();

            switch (version)
            {
            case 0:
                this.Blur      = r.ReadUInt32();
                this.Intensity = r.ReadUInt32();

                this.Angle    = r.ReadUInt32();
                this.Distance = r.ReadUInt32();

                this.Color = r.ReadPSDColor(16, true);

                this.BlendModeKey = this.ReadBlendKey(r);
                //this.BlendModeSignature = r.ReadUInt32();
                //this.BlendModeKey = r.ReadUInt32();
                this.Enabled        = r.ReadBoolean();
                this.UseGlobalAngle = r.ReadBoolean();
                this.Opacity        = r.ReadByte();
                break;

            case 2:
                this.Blur      = (uint)r.ReadUInt16();
                this.Intensity = r.ReadUInt32();

                this.Angle    = r.ReadUInt32();
                this.Distance = r.ReadUInt32();

                ushort something = r.ReadUInt16();    //TODO:?

                this.Color = r.ReadPSDColor(16, true);

                this.BlendModeKey   = this.ReadBlendKey(r);
                this.Enabled        = r.ReadBoolean();
                this.UseGlobalAngle = r.ReadBoolean();
                this.Opacity        = r.ReadByte();
                //TODO: 10 unknown bytes!
                break;
            }

            this.Data = null;
        }
Example #2
0
        public Bevel(PhotoshopFile.Layer.AdjustmentLayerInfo info)
        {
            this.m_data  = info.Data;
            this.m_key   = info.Key;
            this.m_layer = info.Layer;

            BinaryReverseReader r = this.DataReader;

            //string blendModeSignature = null;

            uint version = r.ReadUInt32();

            switch (version)
            {
            case 0:
                this.Blur = r.ReadUInt32();
                this.Data = null;
                break;

            case 2:
                this.Angle    = (uint)r.ReadUInt16();
                this.Strength = (uint)r.ReadUInt16();
                this.Blur     = (uint)r.ReadUInt16();

                this.Unknown1 = r.ReadByte();
                this.Unknown2 = r.ReadByte();
                this.Unknown3 = r.ReadUInt16();
                this.Unknown4 = r.ReadUInt16();

                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();

                System.Drawing.Color someColor  = r.ReadPSDColor(16, true);
                System.Drawing.Color someColor2 = r.ReadPSDColor(16, true);
                break;
            }
            this.Data = null;
        }
Example #3
0
        public TypeToolObject(PhotoshopFile.Layer.AdjustmentLayerInfo info)
        {
            this.m_data  = info.Data;
            this.m_key   = info.Key;
            this.m_layer = info.Layer;

            BinaryReverseReader r = this.DataReader;

            ushort PhotshopVersion = r.ReadUInt16();   //2 bytes, =1 Photoshop 6 (not 5)

            this.Transform = new Matrix2D(r);          //six doubles (48 bytes)

            ushort TextVersion       = r.ReadUInt16(); //2 bytes, =50. For Photoshop 6.0.
            uint   DescriptorVersion = r.ReadUInt32(); //4 bytes,=16. For Photoshop 6.0.


            this.TxtDescriptor = DynVal.ReadDescriptor(r); //Text descriptor

            ushort WarpVersion           = r.ReadUInt16(); //2 bytes, =1. For Photoshop 6.0.
            uint   WarpDescriptorVersion = r.ReadUInt32(); //4 bytes, =16. For Photoshop 6.0.

            engineData       = (Dictionary <string, object>)TxtDescriptor.Children.Find(c => c.Name == "EngineData").Value;
            StylesheetReader = new TdTaStylesheetReader(engineData);

            //string desc = this.TxtDescriptor.getString();

            this.WarpDescriptor = DynVal.ReadDescriptor(r);       //Warp descriptor
            this.Data           = r.ReadBytes((int)r.BytesToEnd); //17 bytes???? All zeroes?
            if (Data.Length != 17 || !(Array.TrueForAll(Data, b => b == 0)))
            {
                string s = ReadableBinary.CreateHexEditorString(Data);
                Debug.Write(s);
            }

            //this.WarpRect = new RectangleF();
            //WarpRect.X = (float)r.ReadDouble();
            //WarpRect.Y = (float)r.ReadDouble();
            //this.Data.
            //WarpRect.Width = (float)r.ReadDouble() - WarpRect.X;
            //WarpRect.Height = (float)r.ReadDouble() - WarpRect.Y;

            //this.Data = r.ReadBytes((int)r.BytesToEnd);
        }
Example #4
0
        public Effects(PhotoshopFile.Layer.AdjustmentLayerInfo info)
        {
            this.m_data  = info.Data;
            this.m_key   = info.Key;
            this.m_layer = info.Layer;

            BinaryReverseReader r = this.DataReader;

            r.BaseStream.Position += 2; //unused
            ushort nNumEffects = r.ReadUInt16();

            this._resources = new Dictionary <string, PhotoshopFile.Layer.AdjustmentLayerInfo>();
            for (int nEffectNum = 0; nEffectNum < nNumEffects; nEffectNum++)
            {
                PhotoshopFile.Layer.AdjustmentLayerInfo res = new PhotoshopFile.Layer.AdjustmentLayerInfo(r, info.Layer);
                //if (res.Tag != "cmnS")
                //  continue;
                this._resources.Add(res.Key, res);
                //    case "sofi": //unknown
            }

            this.Data = null;
        }
Example #5
0
        public Glow(PhotoshopFile.Layer.AdjustmentLayerInfo info)
        {
            this.m_data  = info.Data;
            this.m_key   = info.Key;
            this.m_layer = info.Layer;

            BinaryReverseReader r = this.DataReader;

            //string blendModeSignature = null;
            uint version = r.ReadUInt32(); //two version specifications?!?

            switch (version)
            {
            case 0:
                this.Blur = r.ReadUInt32();
                this.Data = null;
                break;

            case 2:
                this.Blur      = (uint)r.ReadUInt16();
                this.Intensity = r.ReadUInt32();
                ushort something = r.ReadUInt16();
                this.Color = r.ReadPSDColor(16, false);     //Inner color (no alpha)

                this.BlendModeKey = this.ReadBlendKey(r);
                this.Enabled      = r.ReadBoolean();
                this.Opacity      = r.ReadByte();
                //TODO!
                if (this.Inner)
                {
                    this.Unknown = r.ReadByte();
                }
                this.UnknownColor = r.ReadPSDColor(16, false);     //unknown color(no alpha)
                this.Data         = r.ReadBytes((int)r.BytesToEnd);
                break;
            }
        }
Example #6
0
        private Layer AddNewLayer(PsdFile psdFile, int index)
        {
            PhotoshopFile.Layer psdLayer = new PhotoshopFile.Layer(psdFile)
            {
                BlendModeKey = "norm",
                Visible      = true,

                // Set layer metadata
                Rect    = new System.Drawing.Rectangle(0, 0, psdFile.Columns, psdFile.Rows),
                Name    = "Layer " + index,
                Opacity = 255
            };
            psdLayer.Visible            = true;
            psdLayer.MaskData           = new PhotoshopFile.Layer.Mask(psdLayer);
            psdLayer.BlendingRangesData = new PhotoshopFile.Layer.BlendingRanges(psdLayer);

            // Preserve Unicode layer name as Additional Layer Information
            var luniLayerInfo = new PhotoshopFile.Layer.AdjustmentLayerInfo("luni");
            var luniData      = Encoding.BigEndianUnicode.GetBytes("\u0000\u0000" + psdLayer.Name);

            Util.SetBigEndianInt32(luniData, 0, psdLayer.Name.Length);
            luniLayerInfo.Data = luniData;
            psdLayer.AdjustmentInfo.Add(luniLayerInfo);

            // Store channel metadata
            int layerSize = psdLayer.Rect.Width * psdLayer.Rect.Height;

            for (int i = -1; i < 3; i++)
            {
                PhotoshopFile.Layer.Channel ch = new PhotoshopFile.Layer.Channel((short)i, psdLayer)
                {
                    ImageCompression = ImageCompression.Rle,
                    ImageData        = new byte[layerSize]
                };
            }
            return(psdLayer);
        }
Example #7
0
        public Effects(PhotoshopFile.Layer.AdjustmentLayerInfo info)
        {
            this.m_data = info.Data;
            this.m_key = info.Key;
            this.m_layer = info.Layer;

            BinaryReverseReader r = this.DataReader;

            r.BaseStream.Position += 2; //unused
            ushort nNumEffects = r.ReadUInt16();
            this._resources = new Dictionary<string, PhotoshopFile.Layer.AdjustmentLayerInfo>();
            for (int nEffectNum = 0; nEffectNum < nNumEffects; nEffectNum++)
            {
                PhotoshopFile.Layer.AdjustmentLayerInfo res = new PhotoshopFile.Layer.AdjustmentLayerInfo(r, info.Layer);
                //if (res.Tag != "cmnS")
                //  continue;
                this._resources.Add(res.Key, res);
                //    case "sofi": //unknown
            }

            this.Data = null;
        }
Example #8
0
        public TypeTool(PhotoshopFile.Layer.AdjustmentLayerInfo info)
        {
            this.m_data  = info.Data;
            this.m_key   = info.Key;
            this.m_layer = info.Layer;

            BinaryReverseReader reader = this.DataReader;
            ushort Version             = reader.ReadUInt16(); //1= Photoshop 5.0


            //2D transform matrix (6 doubles)
            Transform = new Matrix2D(reader);



            //Font info:
            ushort FontVersion = reader.ReadUInt16(); //6 = Photoshop 5.0
            ushort FaceCount   = reader.ReadUInt16();

            this.FontInfos = new List <FontInfo>();
            for (int i = 0; i < FaceCount; i++)
            {
                this.FontInfos.Add(new FontInfo(reader));
            }

            //TODO: make classes of styles as well...
            ushort StyleCount = reader.ReadUInt16();

            for (int i = 0; i < StyleCount; i++)
            {
                ushort Mark      = reader.ReadUInt16();
                ushort FaceMark  = reader.ReadUInt16();
                uint   Size      = reader.ReadUInt32();
                uint   Tracking  = reader.ReadUInt32();
                uint   Kerning   = reader.ReadUInt32();
                uint   Leading   = reader.ReadUInt32();
                uint   BaseShift = reader.ReadUInt32();

                byte AutoKern = reader.ReadByte();
                byte Extra    = 0;
                if (Version <= 5)
                {
                    Extra = reader.ReadByte();
                }
                byte Rotate = reader.ReadByte();
            }

            //Text information
            ushort Type           = reader.ReadUInt16();
            uint   ScalingFactor  = reader.ReadUInt32();
            uint   CharacterCount = reader.ReadUInt32();

            uint HorizontalPlacement = reader.ReadUInt32();
            uint VerticalPlacement   = reader.ReadUInt32();

            uint SelectStart = reader.ReadUInt32();
            uint SelectEnd   = reader.ReadUInt32();

            ushort LineCount = reader.ReadUInt16();

            for (int i = 0; i < LineCount; i++)
            {
                uint   CharacterCountLine = reader.ReadUInt32();
                ushort Orientation        = reader.ReadUInt16();
                ushort Alignment          = reader.ReadUInt16();

                ushort DoubleByteChar = reader.ReadUInt16();
                ushort Style          = reader.ReadUInt16();
            }

            ushort ColorSpace = reader.ReadUInt16();

            for (int i = 0; i < 4; i++)
            {
                reader.ReadUInt16(); //Color compensation
            }
            byte AntiAlias = reader.ReadByte();
        }