Exemplo n.º 1
0
 public virtual void Load(InputStream res)
 {
     this._path = null;
     this._classType = null;
     this._source = null;
     this.currentDefinitionObject = null;
     this.isCurrentElementDefined = false;
     XMLParser.Parse(res, listener);
 }
Exemplo n.º 2
0
        public SequenceInputStream(InputStream s1, InputStream s2)
        {
            List<Stream> v = new List<Stream>(2);

            v.Add(s1);
            v.Add(s2);
            e = new Loon.Java.Generics.IteratorAdapter<Stream>(v.GetEnumerator());
            try
            {
                NextStream();
            }
            catch (IOException ex)
            {
                Console.Error.WriteLine("panic" + ex.Message);
            }
        }
Exemplo n.º 3
0
 public static byte[] GetDataSource(InputStream ins)
 {
     if (ins == null)
     {
         return null;
     }
     ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
     byte[] bytes = new byte[8192];
     try
     {
         int read;
         while ((read = ins.Read(bytes)) >= 0)
         {
             byteArrayOutputStream.Write(bytes, 0, read);
         }
         bytes = byteArrayOutputStream.ToByteArray();
     }
     catch (IOException)
     {
         return null;
     }
     finally
     {
         try
         {
             if (byteArrayOutputStream != null)
             {
                 byteArrayOutputStream.Flush();
                 byteArrayOutputStream = null;
             }
             if (ins != null)
             {
                 ins.Close();
                 ins = null;
             }
         }
         catch (IOException)
         {
         }
     }
     return bytes;
 }
Exemplo n.º 4
0
        void NextStream()
        {
            if (ins != null)
            {
                ins.Close();
            }
            if (e.HasNext())
            {
                ins = e.Next();
                if (ins == null)
                {
                    throw new Exception();
                }
            }
            else
            {
                ins = null;
            }

        }
Exemplo n.º 5
0
 static internal InputStream Wrap(Stream s)
 {
     InputStream stream = new InputStream();
     stream.Wrapped = s;
     return stream;
 }
Exemplo n.º 6
0
 public WrappedSystemStream(InputStream ist)
 {
     this.ist = ist;
 }
Exemplo n.º 7
0
 public static LImage CreateImage(InputStream ins)
 {
     LImage image = null;
     try
     {
         image = new LImage();
         image.m_data = Texture2D.FromStream(GL.device, ins);
         image.width = image.m_data.Width;
         image.height = image.m_data.Height;
         image.isExt = true;
         image.CheckAlpha();
     }
     catch (Exception ex)
     {
         Loon.Utils.Debug.Log.Exception(ex);
     }
     finally
     {
         if (ins != null)
         {
             try
             {
                 ins.Close();
                 ins = null;
             }
             catch (Exception)
             {
             }
         }
     }
     return image;
 }
Exemplo n.º 8
0
 private GLLoader(InputStream ins)
 {
     Create(LImage.CreateImage(ins));
     this.isExt = true;
 }
Exemplo n.º 9
0
 public static LTextureData GetTextureData(InputStream ins)
 {
     return new GLLoader(ins);
 }
Exemplo n.º 10
0
        public BitmapDecoder(InputStream ins,string file)
        {
            this.width = 0;
            this.height = 0;
            this.format = null;
            try
            {
                int c1 = ins.Read();
                int c2 = ins.Read();
                int c3 = ins.Read();

                // GIF
                if (c1 == 'G' && c2 == 'I' && c3 == 'F')
                {
                    ins.Skip(3);
                    this.width = this.ReadInt(ins, 2, false);
                    this.height = this.ReadInt(ins, 2, false);
                    this.format = "gif";
                    // JPG
                }
                else if (c1 == 0xFF && c2 == 0xD8)
                {
                    while (c3 == 255)
                    {
                        int marker = ins.Read();
                        int len = this.ReadInt(ins, 2, true);
                        if (marker == 192 || marker == 193 || marker == 194)
                        {
                            ins.Skip(1);
                            this.height = this.ReadInt(ins, 2, true);
                            this.width = this.ReadInt(ins, 2, true);
                            this.format = "jpeg";
                            break;
                        }
                        ins.Skip(len - 2);
                        c3 = ins.Read();
                    }
                    // PNG
                }
                else if (c1 == 137 && c2 == 80 && c3 == 78)
                {
                    ins.Skip(15);
                    this.width = this.ReadInt(ins, 2, true);
                    ins.Skip(2);
                    this.height = this.ReadInt(ins, 2, true);
                    this.format = "png";
                    // BMP
                }
                else if (c1 == 66 && c2 == 77)
                {
                    ins.Skip(15);
                    this.width = this.ReadInt(ins, 2, false);
                    ins.Skip(2);
                    this.height = this.ReadInt(ins, 2, false);
                    this.format = "bmp";
                }
                else
                {
                    int c4 = ins.Read();
                    //TIFF
                    if ((c1 == 'M' && c2 == 'M' && c3 == 0 && c4 == 42) || (c1 == 'I' && c2 == 'I' && c3 == 42 && c4 == 0))
                    {
                        bool bigEndian = c1 == 'M';
                        int ifd;
                        int entries;
                        int w = -1, h = -1;
                        ifd = this.ReadInt(ins, 4, bigEndian);
                        ins.Skip(ifd - 8);
                        entries = this.ReadInt(ins, 2, bigEndian);
                        for (int i = 1; i <= entries; i++)
                        {
                            int tag = this.ReadInt(ins, 2, bigEndian);
                            int fieldType = this.ReadInt(ins, 2, bigEndian);
                            long count = this.ReadInt(ins, 4, bigEndian);
                            int valOffset;
                            if ((fieldType == 3 || fieldType == 8))
                            {
                                valOffset = this.ReadInt(ins, 2, bigEndian);
                                ins.Skip(2);
                            }
                            else
                            {
                                valOffset = this.ReadInt(ins, 4, bigEndian);
                            }
                            if (tag == 256)
                            {
                                w = valOffset;
                            }
                            else if (tag == 257)
                            {
                                h = valOffset;
                            }
                            if (w != -1 && h != -1)
                            {
                                this.width = w;
                                this.height = h;
                                this.format = "tiff";
                                break;
                            }
                        }
                    }
                    else
                    {
                        this.format = null;
                        this.width = 0;
                        this.height = 0;
                    }
                }
                ins.Close();
            }
            catch (FileNotFoundException)
            {
                Log.DebugWrite("File not found:" + file);
            }
            catch (IOException)
            {
                Log.DebugWrite("Error on reading:" + file);
            }
            if (this.format == null)
            {
                Log.DebugWrite("Unsuported format !");
            }
        }
Exemplo n.º 11
0
 public BitmapDecoder(InputStream ins)
     : this(ins, null)
 {
 }
Exemplo n.º 12
0
 private int ReadInt(InputStream ins, int noOfBytes, bool bigEndian)
 {
     int ret = 0;
     int sv = bigEndian ? ((noOfBytes - 1) * 8) : 0;
     int cnt = bigEndian ? -8 : 8;
     for (int i = 0; i < noOfBytes; i++)
     {
         ret |= ins.Read() << sv;
         sv += cnt;
     }
     return ret;
 }
Exemplo n.º 13
0
 public IlFilterInputStream(Stream stream)
 {
     this.ins0 = stream;
 }
Exemplo n.º 14
0
        private void Parse(InputStream file)
        {
            if (displays == null)
            {
                displays = new ArrayMap(DEFAULT_MAX_CHAR);
            }
            else
            {
                displays.Clear();
            }
            try
            {
                StreamReader ins = new StreamReader(file,
                        System.Text.Encoding.UTF8);
                info = ins.ReadLine();
                common = ins.ReadLine();
                page = ins.ReadLine();

                ArrayMap kerning = new ArrayMap(
                        64);
                List<CharDef> charDefs = new List<CharDef>(
                        DEFAULT_MAX_CHAR);

                int maxChar = 0;
                bool done = false;
                for (; !done; )
                {
                    string line = ins.ReadLine();
                    if (line == null)
                    {
                        done = true;
                    }
                    else
                    {
                        if (line.StartsWith("chars c"))
                        {
                        }
                        else if (line.StartsWith("char"))
                        {
                            CharDef def = ParseChar(line);
                            if (def != null)
                            {
                                maxChar = MathUtils.Max(maxChar, def.id);
                                charDefs.Add(def);
                            }
                        }
                        if (line.StartsWith("kernings c"))
                        {
                        }
                        else if (line.StartsWith("kerning"))
                        {
                            StringTokenizer tokens = new StringTokenizer(line, " =");
                            tokens.NextToken();
                            tokens.NextToken();
                            short first = short.Parse(tokens.NextToken());
                            tokens.NextToken();
                            int second = int.Parse(tokens.NextToken());
                            tokens.NextToken();
                            int offset = int.Parse(tokens.NextToken());
                            List<short> values = (List<short>)kerning.GetValue(first);
                            if (values == null)
                            {
                                values = new List<short>();
                                kerning.Put(first, values);
                            }
                            values.Add((short)((offset << 8) | second));
                        }
                    }
                }

                this.chars = new CharDef[maxChar + 1];

                for (IEnumerator<CharDef> iter = charDefs.GetEnumerator(); iter.MoveNext(); )
                {
                    CharDef def = iter.Current;
                    chars[def.id] = def;
                }
                ArrayMap.Entry[] entrys = kerning.ToEntrys();
                for (int j = 0; j < entrys.Length; j++)
                {
                    ArrayMap.Entry entry = entrys[j];
                    short first = (short)entry.GetKey();
                    List<short> valueList = (List<short>)entry.GetValue();
                    short[] valueArray = new short[valueList.Count];
                    int i = 0;
                    for (IEnumerator<short> valueIter = valueList.GetEnumerator(); valueIter
                            .MoveNext(); i++)
                    {
                        valueArray[i] = valueIter.Current;
                    }
                    chars[first].kerning = valueArray;
                }
            }
            catch (IOException)
            {
                throw new Exception("Invalid font file: " + file);
            }
        }