예제 #1
0
        /*
         * 編集用
         * VectorArrayの内容をバッファに書き込むが、配列の大きさは変更してはならない。
         * パラメータのVectorArrayは変更しません=const
         */
        public bool SetVectors(int utf16, ref VectorArray va)
        {
            int loc = UTF16ToLocation(utf16);

            if (loc < 0)
            {
                return(false);
            }

            int n = BitConverter.ToInt16(vect, loc);

            if (n < 0 || n != va.Count)
            {
                return(false);
            }

            loc += 2;

            for (int i = 0; i < va.Count; i++)
            {
                if (va[i].c != VectorUnit.Command.MOVETO && va[i].c != VectorUnit.Command.LINETO)
                {
                    return(false);
                }
            }

            for (int i = 0; i < va.Count; i++)
            {
                if (va[i].c == VectorUnit.Command.MOVETO)
                {
                    vect[loc++] = (byte)'M';
                }
                else
                {
                    vect[loc++] = (byte)'L';
                }

                byte[] bs = BitConverter.GetBytes(va[i].x);
                for (int j = 0; j < 4; j++)
                {
                    vect[loc++] = bs[j];
                }

                bs = BitConverter.GetBytes(va[i].y);
                for (int j = 0; j < 4; j++)
                {
                    vect[loc++] = bs[j];
                }
            }

            return(true);
        }
예제 #2
0
        public VectorArray GetVectors(int utf16)
        {
            if (utf16 != 32)
            {
                int loc = UTF16ToLocation(utf16);
                if (loc < 0)
                {
                    return(null);
                }

                int n = BitConverter.ToInt16(vect, loc);
                if (n < 0)
                {
                    return(null);
                }

                VectorArray va = new VectorArray(n);
                loc += 2;

                while (n-- > 0)
                {
                    VectorUnit.Command c;
                    if (vect[loc] == (byte)'M')
                    {
                        c = VectorUnit.Command.MOVETO;
                    }
                    else if (vect[loc] == (byte)'L')
                    {
                        c = VectorUnit.Command.LINETO;
                    }
                    else
                    {
                        throw new Exception("Unknown command");
                    }

                    float x = BitConverter.ToSingle(vect, loc + 1);
                    float y = BitConverter.ToSingle(vect, loc + 5);
                    va.Add(c, x, y);

                    loc += 9;
                }
                return(va);
            }
            else
            {
                //スペースの処理
                VectorArray va = new VectorArray(2);
                va.Add(VectorUnit.Command.NONE, 0.0F, 0.0F);
                va.Add(VectorUnit.Command.NONE, 0.3F, 0.0F);
                return(va);
            }
        }