Exemple #1
0
        /// <summary>
        /// save bitmaps to disk.
        /// </summary>
        /// <param name="dictionary"></param>
        /// <param name="bitmaps"></param>
        private static void Test(Dictionary <string, GlyphInfo> dictionary, Bitmap[] bitmaps)
        {
            //var graphicses = new Graphics[bitmaps.Length];
            foreach (var item in dictionary)
            {
                GlyphInfo     info  = item.Value;
                QuadSTRStruct quad  = info.quad;
                int           index = (int)Math.Floor(quad.leftTop.z);

                float x0 = quad.leftTop.x * bitmaps[index].Width;
                float x1 = quad.rightTop.x * bitmaps[index].Width;
                float y0 = quad.leftTop.y * bitmaps[index].Height;
                float y1 = quad.leftBottom.y * bitmaps[index].Height;
                using (var graphics = Graphics.FromImage(bitmaps[index]))
                {
                    graphics.DrawRectangle(index == 0 ? Pens.Red : Pens.Green, x0, y0, x1 - x0, y1 - y0);
                }
            }

            for (int i = 0; i < bitmaps.Length; i++)
            {
                bitmaps[i].Save(string.Format("{0}.png", i));
            }

            //using (var sw = new System.IO.StreamWriter("defaultGlyphServer.txt"))
            //{
            //    foreach (var item in dictionary)
            //    {
            //        string line = string.Empty;
            //        try
            //        {
            //            line = item.Value.ToString();
            //            sw.WriteLine(line);
            //        }
            //        catch (Exception ex)
            //        {
            //            Console.WriteLine(ex);
            //            //line = string.Format("glyph:[??], quad:[{0}]", item.Value.quad);
            //        }
            //    }
            //}
        }
Exemple #2
0
        /// <summary>
        /// save bitmaps to disk.
        /// </summary>
        /// <param name="dictionary"></param>
        /// <param name="bitmaps"></param>
        private static void Test(Dictionary <string, GlyphInfo> dictionary, Bitmap[] bitmaps)
        {
            //var graphicses = new Graphics[bitmaps.Length];
            foreach (var item in dictionary)
            {
                GlyphInfo     info  = item.Value;
                QuadSTRStruct quad  = info.quad;
                int           index = (int)Math.Floor(quad.leftTop.z);

                float x0 = quad.leftTop.x * bitmaps[index].Width;
                float x1 = quad.rightTop.x * bitmaps[index].Width;
                float y0 = quad.leftTop.y * bitmaps[index].Height;
                float y1 = quad.leftBottom.y * bitmaps[index].Height;
                using (var graphics = Graphics.FromImage(bitmaps[index]))
                {
                    graphics.DrawRectangle(index == 0 ? Pens.Red : Pens.Green, x0, y0, x1 - x0, y1 - y0);
                }
            }

            for (int i = 0; i < bitmaps.Length; i++)
            {
                bitmaps[i].Save(string.Format("{0}.png", i));
            }
        }
Exemple #3
0
        ///// <summary>
        ///// Index of the the texture which this glyph belongs to in the 2D texture array.
        ///// 此字符所在的纹理,在二维纹理数组中的索引。
        ///// </summary>
        //public readonly int textureIndex;

        /// <summary>
        /// Information of rendering a glyph.
        /// 绘制一个字符(串)所需要的信息。
        /// </summary>
        /// <param name="characters">The glyph(a character or a string).此字符(串)。</param>
        /// <param name="leftTop">UV of left top.此字符的字形在纹理的横向偏移量(左上角uv)</param>
        /// <param name="rightBottom">UV of right bottom.此字符的字形在纹理的纵向偏移量(右下角uv)</param>
        /// <param name="textureIndex">Index of the the texture which this glyph belongs to in the 2D texture array.此字符所在的纹理,在二维纹理数组中的索引。</param>
        public GlyphInfo(string characters, vec2 leftTop, vec2 rightBottom, int textureIndex)
        {
            this.characters = characters;
            this.quad       = new QuadSTRStruct(leftTop, rightBottom, textureIndex);
        }