Esempio n. 1
0
        /// <summary>
        /// A peculiar type of ascii string frequently used throughout the Descriptor data structure.
        /// First 4 bytes are length (in bytes), followed by string. If length is 0, length is assumed to be 4. No idea why they did this... RLE compression?
        /// </summary>
        /// <param name="r"></param>
        /// <returns></returns>
        public static string ReadSpecialString(BinaryReverseReader r)
        {
            uint length = r.ReadUInt32();

            if (length == 0)
            {
                length = 4;
            }
            return(new string(r.ReadPSDChars((int)length)));
        }
Esempio n. 2
0
        public static DynVal ReadValue(BinaryReverseReader r, bool skipKey)
        {
            DynVal vt = new DynVal();

            if (!skipKey)
            {
                vt.Name = GetMeaningOfFourCC(ReadSpecialString(r));
            }

            //TODO: should be assigned a sequential number?
            vt.Type = parseTypeString(new string(r.ReadPSDChars(4)));
            switch (vt.Type)
            {
            case  OSType.tdta:

                uint       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(new string(r.ReadPSDChars(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.ReadPSDUnicodeString();
                break;

            default:
                throw new Exception("Unhandled type: " + vt.Type);
            }
            return(vt);
        }
Esempio n. 3
0
        public static DynVal ReadValue(BinaryReverseReader r, bool skipKey)
        {
            DynVal vt = new DynVal();
            if (!skipKey)
                vt.Name = GetMeaningOfFourCC(ReadSpecialString(r));

            //TODO: should be assigned a sequential number?
            vt.Type = parseTypeString(new string(r.ReadPSDChars(4)));
            switch (vt.Type)
            {
                case  OSType.tdta:

                    uint 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(new string(r.ReadPSDChars(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.ReadPSDUnicodeString();
                    break;

                default:
                    throw new Exception("Unhandled type: " + vt.Type);
            }
            return vt;
        }
Esempio n. 4
0
 /// <summary>
 /// A peculiar type of ascii string frequently used throughout the Descriptor data structure.
 /// First 4 bytes are length (in bytes), followed by string. If length is 0, length is assumed to be 4. No idea why they did this... RLE compression?
 /// </summary>
 /// <param name="r"></param>
 /// <returns></returns>
 public static string ReadSpecialString(BinaryReverseReader r)
 {
     uint length = r.ReadUInt32();
     if (length == 0)
         length = 4;
     return new string(r.ReadPSDChars((int)length));
 }