Example #1
0
        public Glow(BinaryPSDReader reader)
            : base(reader)
        {
            BinaryPSDReader r = base.GetDataReader();

            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, true);

                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, true);
                this.Data         = r.ReadBytes((int)r.BytesToEnd);
                break;
            }
        }
Example #2
0
        public IPTC_NAA(ImageResource imgRes)
            : base(imgRes)
        {
            BinaryPSDReader reader = imgRes.GetDataReader();

            reader.ReadByte();
            reader.ReadUInt16();
            reader.ReadUInt16();
            reader.ReadUInt16();

            this.Entries = new List <IPTCEntry>();
            while (reader.BytesToEnd > 0)
            {
                byte starter = reader.ReadByte();
                if (starter != 0x1c)
                {
                    throw new Exception("IPTC error");
                }

                IPTCEntry entry = new IPTCEntry();
                entry.Id = (TypeId)reader.ReadUInt16();
                reader.ReadByte();
                entry.Name = reader.ReadPascalStringUnpadded();
                this.Entries.Add(entry);
            }

            reader.Close();
        }
Example #3
0
        public SheetColor(BinaryPSDReader reader)
            : base(reader)
        {
            BinaryPSDReader r = this.GetDataReader();

            this.Color = System.Drawing.Color.FromArgb(
                r.ReadByte(),
                r.ReadByte(),
                r.ReadByte(),
                r.ReadByte());
            this.Data = null;
        }
Example #4
0
        public PrintFlagsInfo(ImageResource imgRes)
            : base(imgRes)
        {
            BinaryPSDReader reader  = imgRes.GetDataReader();
            ushort          version = reader.ReadUInt16();

            this.CenterCrop = reader.ReadByte();
            reader.ReadByte(); //padding?
            this.BleedWidthValue = reader.ReadUInt32();
            this.BleedWidthScale = reader.ReadUInt16();

            reader.Close();
        }
Example #5
0
        public Shadow(BinaryPSDReader reader)
            : base(reader)
        {
            BinaryPSDReader r = base.GetDataReader();

            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;
        }
            public Descriptor(BinaryPSDReader r)
            {
                uint version = r.ReadUInt32();    //?

                r.BaseStream.Position += 6;       //?
                string type     = new string(r.ReadPSDChars(4));
                uint   unknown1 = r.ReadUInt32(); //?
                uint   unknown2 = r.ReadUInt32(); //?
                string resType1 = new string(r.ReadPSDChars(4));
                string resType2 = new string(r.ReadPSDChars(4));

                string uniName = r.ReadPSDUnicodeString();

                while (r.ReadByte() != 0x2f)
                {
                    ;
                }
                this.Items = new List <Item>();
                while (true)
                {
                    Item item = new Item();
                    this.Items.Add(item);
                    if (item.Read(r) == false)
                    {
                        break;
                    }
                }
            }
                public bool Read(BinaryPSDReader r)
                {
                    this.ID = "";
                    while (true)
                    {
                        char c = r.ReadChar();
                        if (c == 0x0a)
                        {
                            break;
                        }
                        this.ID += c;
                    }
                    byte[] buffer     = new byte[255];
                    int    bufPos     = 0;
                    int    nearEndCnt = 0;

                    while (true)
                    {
                        byte b = r.ReadByte();
                        buffer[bufPos++] = b;
                        if (b == 0x2f)
                        {
                            break;
                        }
                        if (b <= 0x00)
                        {
                            nearEndCnt++;
                            if (nearEndCnt == 12)
                            {
                                break;
                            }
                        }
                        else
                        {
                            nearEndCnt = 0;
                        }
                    }

                    if (this.ID.Contains(" "))
                    {
                        int index = this.ID.IndexOf(" ");
                        this.Value = this.ID.Substring(index + 1);
                        this.ID    = this.ID.Remove(index);
                    }

                    int endPos = bufPos - nearEndCnt - 1;

                    //See if it's only 0x09's:
                    for (int i = 0; i < endPos; i++)
                    {
                        if (buffer[i] != 0x09)
                        {
                            this.Data = Endogine.Serialization.ReadableBinary.CreateHexEditorString(buffer, 0, endPos);
                            break;
                        }
                    }

                    return(nearEndCnt == 0);
                }
Example #8
0
        public Bevel(BinaryPSDReader reader)
            : base(reader)
        {
            BinaryPSDReader r = this.GetDataReader();

            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 #9
0
        public CopyrightInfo(ImageResource imgRes)
            : base(imgRes)
        {
            BinaryPSDReader reader = imgRes.GetDataReader();

            this.Value = reader.ReadByte() == 0 ? false : true;
            reader.Close();
        }
Example #10
0
        public DisplayInfo(ImageResource imgRes)
            : base(imgRes)
        {
            BinaryPSDReader reader = imgRes.GetDataReader();

            this.ColorSpace = (ColorModes)reader.ReadInt16();
            for (int i = 0; i < 4; i++)
            {
                this.Color[i] = reader.ReadInt16();
            }

            this.Opacity = (short)Math.Max(0, Math.Min(100, (int)reader.ReadInt16()));
            this.kind    = reader.ReadByte() == 0?false:true;

            reader.Close();
        }
Example #11
0
        public AlphaChannelNames(ImageResource imgRes)
            : base(imgRes)
        {
            BinaryPSDReader reader = imgRes.GetDataReader();

            while (reader.BytesToEnd > 0)
            {
                //no padding in these strings!
                byte   length = reader.ReadByte();
                string name   = new string(reader.ReadPSDChars(length));
                if (name.Length > 0)
                {
                    this._names.Add(name);
                }
            }
            reader.Close();
        }
Example #12
0
        public Curves(BinaryPSDReader reader)
            : base(reader)
        {
            BinaryPSDReader r = this.GetDataReader();

            byte   unknown       = r.ReadByte();
            ushort version       = r.ReadUInt16();
            uint   definedCurves = r.ReadUInt32();

            this.Records = new List <Curve>();
            int channelNum = -1;

            while (definedCurves > 0)
            {
                if ((definedCurves & 1) > 0)
                {
                    Curve curve = new Curve(r);
                    curve.Channel = channelNum;
                    this.Records.Add(curve);
                }
                channelNum++;
                definedCurves >>= 1;
            }

            if (r.BytesToEnd > 0)
            {
                //Same again? Clear Records and begin anew? Brrr... Adobe, argh!
                string head = new string(r.ReadPSDChars(4));
                version = r.ReadUInt16(); //version??
                uint numCurves = r.ReadUInt32();

                for (int i = 0; i < numCurves; i++)
                {
                    ushort channelId = r.ReadUInt16();
                    Curve  curve     = new Curve(r);
                    curve.Channel = (int)channelId - 1;
                }
            }

            this.Data = null;
        }
Example #13
0
            public Pattern(BinaryPSDReader r)
            {
                long startPos = r.BaseStream.Position;

                uint length  = r.ReadUInt32();
                uint version = r.ReadUInt32();

                this.ColorMode = (ColorModes)r.ReadUInt32();
                this.Loc       = new EPoint(r.ReadUInt16(), r.ReadUInt16()); //TODO: signed??
                this.Name      = r.ReadPSDUnicodeString();
                this.Id        = r.ReadPascalString();                       //?
                if (this.ColorMode == ColorModes.Indexed)
                {
                    this.PaletteForXml = "";
                    for (int i = 0; i < 256; i++)
                    {
                        string s = "";
                        for (int j = 0; j < 3; j++)
                        {
                            s += r.ReadByte().ToString("X");
                        }
                        this.PaletteForXml += s;
                    }
                }
                byte[] imageData = r.ReadBytes((int)(length - (int)r.BaseStream.Position - startPos));
                //TODO: what is the format?
                //System.IO.MemoryStream stream = new System.IO.MemoryStream(imageData);
                //System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream);
                //this.ImageData = Endogine.Serialization.ReadableBinary.CreateHexEditorString(imageData);

                //TODO: length isn't correct! By 6 bytes always??
                if (r.BytesToEnd < 20)
                {
                    r.BaseStream.Position = r.BaseStream.Length;
                }
            }
Example #14
0
        public TypeTool(BinaryPSDReader areader)
            : base(areader)
        {
            BinaryPSDReader reader  = this.GetDataReader();
            ushort          Version = reader.ReadUInt16(); //1= Photoshop 5.0

            for (int i = 0; i < 6; i++)                    //2D transform matrix
            {
                reader.ReadPSDDouble();
            }


            //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();
        }
Example #15
0
                public bool Read(BinaryPSDReader r)
                {
                    this.ID = "";
                    while (true)
                    {
                        char c = r.ReadChar();
                        if (c == 0x0a)
                            break;
                        this.ID += c;
                    }
                    byte[] buffer = new byte[255];
                    int bufPos = 0;
                    int nearEndCnt = 0;
                    while (true)
                    {
                        byte b = r.ReadByte();
                        buffer[bufPos++] = b;
                        if (b == 0x2f)
                            break;
                        if (b <= 0x00)
                        {
                            nearEndCnt++;
                            if (nearEndCnt == 12)
                                break;
                        }
                        else
                            nearEndCnt = 0;
                    }

                    if (this.ID.Contains(" "))
                    {
                        int index = this.ID.IndexOf(" ");
                        this.Value = this.ID.Substring(index + 1);
                        this.ID = this.ID.Remove(index);
                    }

                    int endPos = bufPos - nearEndCnt - 1;
                    //See if it's only 0x09's:
                    for (int i = 0; i < endPos; i++)
                    {
                        if (buffer[i] != 0x09)
                        {
                            this.Data = Endogine.Serialization.ReadableBinary.CreateHexEditorString(buffer, 0, endPos);
                            break;
                        }
                    }

                    return (nearEndCnt == 0);
                }
Example #16
0
            public Descriptor(BinaryPSDReader r)
            {
                uint version = r.ReadUInt32(); //?
                r.BaseStream.Position += 6; //?
                string type = new string(r.ReadPSDChars(4));
                uint unknown1 = r.ReadUInt32(); //?
                uint unknown2 = r.ReadUInt32(); //?
                string resType1 = new string(r.ReadPSDChars(4));
                string resType2 = new string(r.ReadPSDChars(4));

                string uniName = r.ReadPSDUnicodeString();
                while (r.ReadByte() != 0x2f)
                    ;
                this.Items = new List<Item>();
                while (true)
                {
                    Item item = new Item();
                    this.Items.Add(item);
                    if (item.Read(r) == false)
                        break;
                }
            }
Example #17
0
            public Pattern(BinaryPSDReader r)
            {
                long startPos = r.BaseStream.Position;

                uint length = r.ReadUInt32();
                uint version = r.ReadUInt32();
                this.ColorMode = (ColorModes)r.ReadUInt32();
                this.Loc = new EPoint(r.ReadUInt16(), r.ReadUInt16()); //TODO: signed??
                this.Name = r.ReadPSDUnicodeString();
                this.Id = r.ReadPascalString(); //?
                if (this.ColorMode == ColorModes.Indexed)
                {
                    this.PaletteForXml = "";
                    for (int i = 0; i < 256; i++)
                    {
                        string s = "";
                        for (int j = 0; j < 3; j++)
                            s += r.ReadByte().ToString("X");
                        this.PaletteForXml += s;
                    }
                }
                byte[] imageData = r.ReadBytes((int)(length - (int)r.BaseStream.Position - startPos));
                //TODO: what is the format?
                //System.IO.MemoryStream stream = new System.IO.MemoryStream(imageData);
                //System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream);
                //this.ImageData = Endogine.Serialization.ReadableBinary.CreateHexEditorString(imageData);

                //TODO: length isn't correct! By 6 bytes always??
                if (r.BytesToEnd < 20)
                    r.BaseStream.Position = r.BaseStream.Length;
            }