示例#1
0
        private void ReadPSDChannelTag(BinaryReverseReader reader)
        {
            string sHeader = new string(reader.ReadChars(4));
            if (sHeader != "8BIM")
            {
                reader.BaseStream.Position-=4; //back it up before throwing exception
                throw(new Exception("Effect header incorrect"));
            }

            string sKey = new string(reader.ReadChars(4));
            uint nLength = reader.ReadUInt32();
            long nPosStart = reader.BaseStream.Position;

            switch (sKey)
            {
                case "lyid":
                    this.LayerID = (int)reader.ReadUInt32();
                    break;

                case "fxrp":
                    this.ReferencePoint = new EPointF();
                    this.ReferencePoint.X = reader.ReadPSD8BitSingle();
                    this.ReferencePoint.Y = reader.ReadPSD8BitSingle();
                    break;

                case "clbl":
                    //blend clipping
                    this.BlendClipping = reader.ReadBoolean();
                    reader.BaseStream.Position+=3; //padding
                    break;

                case "infx":
                    //blend interior elements
                    this.Blend = reader.ReadBoolean();
                    reader.BaseStream.Position+=3; //padding
                    break;

                case "knko":
                    //Knockout setting
                    this.Knockout = reader.ReadBoolean();
                    reader.BaseStream.Position+=3; //padding
                    break;

                case "lspf":
                    //Protected settings
                    //TODO:
                    reader.ReadBytes(4); //nLength?
                    //bits 0-2 = Transparency, composite and position
                    break;

                case "lclr":
                    //Sheet Color setting
                    this.SheetColor = System.Drawing.Color.FromArgb(
                        reader.ReadByte(),
                        reader.ReadByte(),
                        reader.ReadByte(),
                        reader.ReadByte());
                    reader.BaseStream.Position+=2; //padding
                    break;

                case "lnsr":
                    //Layer Name Source setting
                    string sWhatIsThis = new string(reader.ReadChars((int)nLength));
                    //this.NameSourceSetting = reader.ReadUInt32();
                    break;

                case "luni":
                    //Unicode Layer name
                    uint nUnicodeLength = reader.ReadUInt32();
                    this.UnicodeName = new string(reader.ReadChars((int)nUnicodeLength*2));
                    break;

                case "lrFX":
                    //Effects Layer info
                    reader.BaseStream.Position+=2; //unused
                    ushort nNumEffects = reader.ReadUInt16();
                    //      aEffectsInfo = []
                    //      paInfo[#EffectsInfo] = aEffectsInfo
                    for (int nEffectNum = 0; nEffectNum < nNumEffects; nEffectNum++)
                    {
                        sHeader = new string(reader.ReadChars(4));
                        if (sHeader != "8BIM")
                            throw(new Exception("Effect header incorrect"));

                        EffectLayers.Effect effectForReading = new Endogine.Serialization.Photoshop.EffectLayers.Effect(reader);
                        //reader.JumpToEvenNthByte(2);
                        EffectLayers.Effect effect = null;
                        //long nEffectEndPos = reader.BaseStream.Position + effect.Size;
                        switch (effectForReading.Name)
                        {
                            case "cmnS": //common state
                                BinaryReverseReader subreader = effectForReading.GetDataReader();
                                bool bVisible = subreader.ReadBoolean();
                                //reader.BaseStream.Position+=2; //unused
                                break;

                            case "dsdw":
                            case "isdw":
                                //drop/inner shadow
                                if (effectForReading.Version == 0)
                                    effect = new Endogine.Serialization.Photoshop.EffectLayers.Shadow(effectForReading);
                                else
                                {
                                    //TODO:
                                }
                                break;

                            case "oglw":
                            case "iglw":
                                //outer/inner glow
                                if (effectForReading.Version == 0)
                                    effect = new Endogine.Serialization.Photoshop.EffectLayers.Glow(effectForReading);
                                else
                                {
                                    //TODO:
                                }

                                break;
                            case "bevl": //bevel
                                if (effectForReading.Version == 0)
                                    effect = new Endogine.Serialization.Photoshop.EffectLayers.Bevel(effectForReading);
                                else
                                {
                                    //TODO:
                                }
                                break;

                            case "sofi": //unknown
                                break;
                        }
                        this.Effects.Add(effect);
                        //reader.BaseStream.Position = nEffectEndPos;
                    }
                    break;

                case "lsct":
                    //TODO: what is this?
                    reader.BaseStream.Position+=4;
                    break;

                case "TySh":
                case "lfx2":
                    //TODO: what are these?
                    break;

                default:
                    string sMsg = "Unknown layer setting: " + sKey + " Length:" + nLength.ToString() + " Pos: "+reader.BaseStream.Position.ToString();
                    //EH.Put(sMsg);
                    break;
            }
            //add to nLength so it's padded to 4
            int nLengthMod = (int)(nLength % (long)4);
            if (nLengthMod > 0)
                nLength+= 4-(uint)nLengthMod;

            reader.BaseStream.Position = nPosStart + nLength;
            reader.JumpToEvenNthByte(2);
        }
示例#2
0
        private void ReadPSDChannelTag(BinaryReverseReader reader)
        {
            string sHeader = new string(reader.ReadChars(4));

            if (sHeader != "8BIM")
            {
                reader.BaseStream.Position -= 4;               //back it up before throwing exception
                throw(new Exception("Effect header incorrect"));
            }

            string sKey      = new string(reader.ReadChars(4));
            uint   nLength   = reader.ReadUInt32();
            long   nPosStart = reader.BaseStream.Position;

            switch (sKey)
            {
            case "lyid":
                this.LayerID = (int)reader.ReadUInt32();
                break;

            case "fxrp":
                this.ReferencePoint   = new EPointF();
                this.ReferencePoint.X = reader.ReadPSD8BitSingle();
                this.ReferencePoint.Y = reader.ReadPSD8BitSingle();
                break;

            case "clbl":
                //blend clipping
                this.BlendClipping          = reader.ReadBoolean();
                reader.BaseStream.Position += 3;                       //padding
                break;

            case "infx":
                //blend interior elements
                this.Blend = reader.ReadBoolean();
                reader.BaseStream.Position += 3;                       //padding
                break;

            case "knko":
                //Knockout setting
                this.Knockout = reader.ReadBoolean();
                reader.BaseStream.Position += 3;                       //padding
                break;

            case "lspf":
                //Protected settings
                //TODO:
                reader.ReadBytes(4);                         //nLength?
                //bits 0-2 = Transparency, composite and position
                break;

            case "lclr":
                //Sheet Color setting
                this.SheetColor = System.Drawing.Color.FromArgb(
                    reader.ReadByte(),
                    reader.ReadByte(),
                    reader.ReadByte(),
                    reader.ReadByte());
                reader.BaseStream.Position += 2;                       //padding
                break;

            case "lnsr":
                //Layer Name Source setting
                string sWhatIsThis = new string(reader.ReadChars((int)nLength));
                //this.NameSourceSetting = reader.ReadUInt32();
                break;

            case "luni":
                //Unicode Layer name
                uint nUnicodeLength = reader.ReadUInt32();
                this.UnicodeName = new string(reader.ReadChars((int)nUnicodeLength * 2));
                break;

            case "lrFX":
                //Effects Layer info
                reader.BaseStream.Position += 2;                       //unused
                ushort nNumEffects = reader.ReadUInt16();
                //      aEffectsInfo = []
                //      paInfo[#EffectsInfo] = aEffectsInfo
                for (int nEffectNum = 0; nEffectNum < nNumEffects; nEffectNum++)
                {
                    sHeader = new string(reader.ReadChars(4));
                    if (sHeader != "8BIM")
                    {
                        throw(new Exception("Effect header incorrect"));
                    }

                    EffectLayers.Effect effectForReading = new Endogine.Serialization.Photoshop.EffectLayers.Effect(reader);
                    //reader.JumpToEvenNthByte(2);
                    EffectLayers.Effect effect = null;
                    //long nEffectEndPos = reader.BaseStream.Position + effect.Size;
                    switch (effectForReading.Name)
                    {
                    case "cmnS":                                     //common state
                        BinaryReverseReader subreader = effectForReading.GetDataReader();
                        bool bVisible = subreader.ReadBoolean();
                        //reader.BaseStream.Position+=2; //unused
                        break;

                    case "dsdw":
                    case "isdw":
                        //drop/inner shadow
                        if (effectForReading.Version == 0)
                        {
                            effect = new Endogine.Serialization.Photoshop.EffectLayers.Shadow(effectForReading);
                        }
                        else
                        {
                            //TODO:
                        }
                        break;

                    case "oglw":
                    case "iglw":
                        //outer/inner glow
                        if (effectForReading.Version == 0)
                        {
                            effect = new Endogine.Serialization.Photoshop.EffectLayers.Glow(effectForReading);
                        }
                        else
                        {
                            //TODO:
                        }

                        break;

                    case "bevl":                                     //bevel
                        if (effectForReading.Version == 0)
                        {
                            effect = new Endogine.Serialization.Photoshop.EffectLayers.Bevel(effectForReading);
                        }
                        else
                        {
                            //TODO:
                        }
                        break;

                    case "sofi":                                     //unknown
                        break;
                    }
                    this.Effects.Add(effect);
                    //reader.BaseStream.Position = nEffectEndPos;
                }
                break;

            case "lsct":
                //TODO: what is this?
                reader.BaseStream.Position += 4;
                break;

            case "TySh":
            case "lfx2":
                //TODO: what are these?
                break;

            default:
                string sMsg = "Unknown layer setting: " + sKey + " Length:" + nLength.ToString() + " Pos: " + reader.BaseStream.Position.ToString();
                //EH.Put(sMsg);
                break;
            }
            //add to nLength so it's padded to 4
            int nLengthMod = (int)(nLength % (long)4);

            if (nLengthMod > 0)
            {
                nLength += 4 - (uint)nLengthMod;
            }

            reader.BaseStream.Position = nPosStart + nLength;
            reader.JumpToEvenNthByte(2);
        }