Exemplo n.º 1
0
 public override void Load(Bytes.Buffer buffer)
 {
     buffer.Seek(Table.Offset);
     buffer.ReadUnsignedInt();
     buffer.ReadUnsignedInt();
     Value = System.Text.Encoding.ASCII.GetString(buffer.ReadBytes((int)Table.ElementSize - 8));
 }
Exemplo n.º 2
0
 public override void Load(Bytes.Buffer buffer)
 {
     buffer.Seek(Table.Offset);
     buffer.ReadUnsignedInt();
     buffer.ReadUnsignedInt();
     Value.Load(buffer);
 }
Exemplo n.º 3
0
 public override void Load(Bytes.Buffer buffer)
 {
     buffer.Seek(Table.Offset);
     buffer.ReadUnsignedInt();
     buffer.ReadUnsignedInt();
     Illuminant.Load(buffer);
     Surround.Load(buffer);
     MeasurmentType = buffer.ReadUnsignedInt();
 }
Exemplo n.º 4
0
        public override void Load(Bytes.Buffer buffer)
        {
            buffer.Seek(Table.Offset);
            buffer.ReadUnsignedInt();
            buffer.ReadUnsignedInt();
            var count = (int)Table.ElementSize - 8;

            Value = buffer.ReadBytes(count);
        }
Exemplo n.º 5
0
 public override void Load(Bytes.Buffer buffer)
 {
     buffer.Seek(Table.Offset);
     buffer.ReadUnsignedInt();
     buffer.ReadUnsignedInt();
     VendorSpecificFlag = buffer.ReadUnsignedInt();
     Count = buffer.ReadUnsignedInt();
     Prefix = System.Text.Encoding.ASCII.GetString(buffer.ReadNullTermitaded());
     Suffix = System.Text.Encoding.ASCII.GetString(buffer.ReadNullTermitaded());
     FirstColor = System.Text.Encoding.ASCII.GetString(buffer.ReadNullTermitaded());
     //....color coordinates. Color space of data
 }
Exemplo n.º 6
0
 public override void Load(Bytes.Buffer buffer)
 {
     buffer.Seek(Table.Offset);
     buffer.ReadUnsignedInt();
     buffer.ReadUnsignedInt();
     DataFlag  = buffer.ReadUnsignedInt();
     ByteValue = new byte[Table.ElementSize - 12];
     if (DataFlag == 0x00000000)
     {
         StringValue = System.Text.Encoding.ASCII.GetString(ByteValue);
     }
 }
Exemplo n.º 7
0
        public static ICCProfile Load(byte[] data)
        {
            var profile = new ICCProfile();
            var header  = new ICCHeader();
            var buffer  = new Bytes.Buffer(data);

            header.ProfileSize                  = buffer.ReadUnsignedInt();
            header.CMMTypeSignature             = buffer.ReadUnsignedInt();
            header.ProfileVersionNumber.Major   = (byte)buffer.ReadByte();
            header.ProfileVersionNumber.Minor   = (byte)buffer.ReadByte();
            header.ProfileVersionNumber.Reserv1 = (byte)buffer.ReadByte();
            header.ProfileVersionNumber.Reserv2 = (byte)buffer.ReadByte();
            header.ProfileDeviceClassSignature  = (ICCProfileDeviceSignatures)buffer.ReadUnsignedInt();
            header.ColorSpaceOfData             = (ICCColorSpaceSignatures)buffer.ReadUnsignedInt();
            header.ProfileConnectionSpace       = (ICCColorSpaceSignatures)buffer.ReadUnsignedInt();
            header.DateCreated.Load(buffer);
            header.acsp = buffer.ReadUnsignedInt();
            header.PrimaryPlatformSignature = (ICCPrimaryPlatformSignatures)buffer.ReadUnsignedInt();
            header.Flags = (ICCProfileFlags)buffer.ReadUnsignedInt();
            header.DeviceManufacturer = buffer.ReadUnsignedInt();
            header.DeviceModel        = buffer.ReadUnsignedInt();
            header.DeviceAttributes.Load(buffer);
            header.RenderingIntent.Intents  = buffer.ReadUnsignedShort();
            header.RenderingIntent.Reserved = buffer.ReadUnsignedShort();
            header.XYZ.Load(buffer);
            header.ProfileCreatorSignature = buffer.ReadUnsignedInt();
            header.FutureUse = new byte[44];
            buffer.Read(header.FutureUse);
            profile.Header = header;
            var tagCount = buffer.ReadUnsignedInt();

            for (int i = 0; i < tagCount; i++)
            {
                var tag = new ICCTagTable();
                tag.Signature               = (ICCTagTypes)buffer.ReadUnsignedInt();
                tag.Offset                  = buffer.ReadUnsignedInt();
                tag.ElementSize             = buffer.ReadUnsignedInt();
                profile.Tags[tag.Signature] = tag;
            }
            foreach (var tagTable in profile.Tags.Values)
            {
                buffer.Seek(tagTable.Offset);
                var key = buffer.ReadUnsignedInt();
                if (Types.TryGetValue(key, out var type))
                {
                    tagTable.Tag         = (ICCTag)Activator.CreateInstance(type, tagTable);
                    tagTable.Tag.Profile = profile;
                    tagTable.Tag.Load(buffer);
                }
            }
            return(profile);
        }
Exemplo n.º 8
0
        public override void Load(Bytes.Buffer buffer)
        {
            buffer.Seek(Table.Offset);
            buffer.ReadUnsignedInt();
            buffer.ReadUnsignedInt();
            var count = (Table.ElementSize - 8) / 4;

            Value = new float[count];
            for (int i = 0; i < count; i++)
            {
                Value[i] = buffer.ReadFixed32();
            }
        }
Exemplo n.º 9
0
 public override void Load(Bytes.Buffer buffer)
 {
     buffer.Seek(Table.Offset);
     buffer.ReadUnsignedInt();
     buffer.ReadUnsignedInt();
     Count = buffer.ReadUnsignedInt();
     for (int i = 0; i < Count; i++)
     {
         var structure = new ICCProfileDescriptionStructure();
         structure.Load(buffer);
         Structures.Add(structure);
     }
 }
Exemplo n.º 10
0
 public override void Load(Bytes.Buffer buffer)
 {
     buffer.Seek(Table.Offset);
     buffer.ReadUnsignedInt();
     buffer.ReadUnsignedInt();
     Count           = buffer.ReadUnsignedInt();
     Description     = System.Text.Encoding.ASCII.GetString(buffer.ReadBytes((int)Count));
     UnicodeCode     = buffer.ReadUnsignedInt();
     UnicodeCount    = buffer.ReadUnsignedInt();
     ScriptcodeCode  = buffer.ReadUnsignedShort();
     ScriptcodeCount = (byte)buffer.ReadByte();
     MacDescription  = System.Text.Encoding.ASCII.GetString(buffer.ReadBytes(67));
 }
Exemplo n.º 11
0
 public override void Load(Bytes.Buffer buffer)
 {
     buffer.Seek(Table.Offset);
     buffer.ReadUnsignedInt();
     buffer.ReadUnsignedInt();
     Flag             = (ICCScreeningFlag)buffer.ReadUnsignedInt();
     NumberOfChannels = buffer.ReadUnsignedInt();
     Channels         = new ICCScreeningChannel[NumberOfChannels];
     for (int i = 0; i < NumberOfChannels; i++)
     {
         Channels[i].Load(buffer);
     }
 }
 public override void Load(Bytes.Buffer buffer)
 {
     buffer.Seek(Table.Offset);
     buffer.ReadUnsignedInt();
     buffer.ReadUnsignedInt();
     NumberOfChannels = buffer.ReadUnsignedShort();
     CountTypes       = buffer.ReadUnsignedShort();
     Offsets          = new uint[CountTypes];
     for (int i = 0; i < CountTypes; i++)
     {
         Offsets[i] = buffer.ReadUnsignedInt();
     }
     for (int i = 0; i < CountTypes; i++)
     {
         var structure = new ICCCurveStructure();
         structure.Load(buffer, NumberOfChannels);
         Structures.Add(structure);
     }
 }
Exemplo n.º 13
0
        public override void Load(Bytes.Buffer buffer)
        {
            buffer.Seek(Table.Offset);
            buffer.ReadUnsignedInt();
            buffer.ReadUnsignedInt();

            CountUCRCurves = buffer.ReadUnsignedInt();
            UCRCurves      = new ushort[CountUCRCurves];
            for (int i = 0; i < CountUCRCurves; i++)
            {
                UCRCurves[i] = buffer.ReadUnsignedShort();
            }

            CountBGCurves = buffer.ReadUnsignedInt();
            BGCurves      = new ushort[CountBGCurves];
            for (int i = 0; i < CountBGCurves; i++)
            {
                BGCurves[i] = buffer.ReadUnsignedShort();
            }

            Charactes = System.Text.Encoding.ASCII.GetString(buffer.ReadNullTermitaded());
        }
Exemplo n.º 14
0
        /**
         * Reads a single token.
         * @param prevToken the previous token
         */
        private Token ReadToken(Token prevToken)
        {
            bool skip;

            do
            {
                skip = false;
                while (buffer.Position < buffer.Length)
                {
                    char c = GetChar();

                    // delimiters
                    if (c == '%')
                    {
                        // comment
                        ReadComment();
                    }
                    else if (c == '(')
                    {
                        return(ReadString());
                    }
                    else if (c == ')')
                    {
                        // not allowed outside a string context
                        throw new IOException("unexpected closing parenthesis");
                    }
                    else if (c == '[')
                    {
                        return(new Token(c, TokenKind.START_ARRAY));
                    }
                    else if (c == '{')
                    {
                        return(new Token(c, TokenKind.START_PROC));
                    }
                    else if (c == ']')
                    {
                        return(new Token(c, TokenKind.END_ARRAY));
                    }
                    else if (c == '}')
                    {
                        return(new Token(c, TokenKind.END_PROC));
                    }
                    else if (c == '/')
                    {
                        return(new Token(ReadRegular(), TokenKind.LITERAL));
                    }
                    else if (c == '<')
                    {
                        char c2 = GetChar();
                        if (c2 == c)
                        {
                            return(new Token("<<", TokenKind.START_DICT));
                        }
                        else
                        {
                            // code may have to be changed in something better, maybe new token type
                            buffer.Seek(buffer.Position - 1);
                            return(new Token(c, TokenKind.NAME));
                        }
                    }
                    else if (c == '>')
                    {
                        char c2 = GetChar();
                        if (c2 == c)
                        {
                            return(new Token(">>", TokenKind.END_DICT));
                        }
                        else
                        {
                            // code may have to be changed in something better, maybe new token type
                            buffer.Seek(buffer.Position - 1);
                            return(new Token(c, TokenKind.NAME));
                        }
                    }
                    else if (char.IsWhiteSpace(c))
                    {
                        skip = true;
                    }
                    else if (c == 0)
                    {
                        Debug.WriteLine("warn: NULL byte in font, skipped");
                        skip = true;
                    }
                    else
                    {
                        buffer.Seek(buffer.Position - 1);

                        // regular character: try parse as number
                        Token number = TryReadNumber();
                        if (number != null)
                        {
                            return(number);
                        }
                        else
                        {
                            // otherwise this must be a name
                            string name = ReadRegular();
                            if (name == null)
                            {
                                // the stream is corrupt
                                throw new DamagedFontException("Could not read token at position " +
                                                               buffer.Position);
                            }

                            if (string.Equals(name, "RD", StringComparison.Ordinal) ||
                                string.Equals(name, "-|", StringComparison.Ordinal))
                            {
                                // return the next CharString instead
                                if (prevToken != null && prevToken.Kind == TokenKind.INTEGER)
                                {
                                    return(ReadCharString(prevToken.IntValue));
                                }
                                else
                                {
                                    throw new IOException("expected INTEGER before -| or RD");
                                }
                            }
                            else
                            {
                                return(new Token(name, TokenKind.NAME));
                            }
                        }
                    }
                }
            }while (skip);
            return(null);
        }