Esempio n. 1
0
        // get widest bitmap
        Rectangle getLargestBitmapFromCharInfo(CharacterGenerationInfo[] charInfoArray)
        {
            // largest rect
            Rectangle largestRect = new Rectangle(0, 0, 0, 0);

            // iterate through chars
            for (int charIdx = 0; charIdx < charInfoArray.Length; ++charIdx)
            {
                // get the string of the characer
                string letterString = charInfoArray[charIdx].character.ToString();

                // measure the size of teh character in pixels
                Size stringSize = TextRenderer.MeasureText(letterString, charInfoArray[charIdx].fontInfo.font);

                // check if larger
                largestRect.Height = Math.Max(largestRect.Height, stringSize.Height);
                largestRect.Width = Math.Max(largestRect.Width, stringSize.Width);
            }

            // return largest
            return largestRect;
        }
Esempio n. 2
0
        // iterate through the original bitmaps and find the tightest common border
        private void findTightestCommonBitmapBorder(CharacterGenerationInfo[] charInfoArray,
            ref BitmapBorder tightestBorder)
        {
            // iterate through bitmaps
            for (int charIdx = 0; charIdx < charInfoArray.Length; ++charIdx)
            {
                // create a border
                BitmapBorder bitmapBorder = new BitmapBorder();

                // get the bitmaps border
                getBitmapBorder(charInfoArray[charIdx].bitmapOriginal, bitmapBorder);

                // check if we need to loosen up the tightest border
                tightestBorder.leftX = Math.Min(bitmapBorder.leftX, tightestBorder.leftX);
                tightestBorder.topY = Math.Min(bitmapBorder.topY, tightestBorder.topY);
                tightestBorder.rightX = Math.Max(bitmapBorder.rightX, tightestBorder.rightX);
                tightestBorder.bottomY = Math.Max(bitmapBorder.bottomY, tightestBorder.bottomY);

            }
        }
Esempio n. 3
0
        // get size of largest bitmap
        Rectangle GetSizeOfLargestBitmap(CharacterGenerationInfo[] charInfoArray, int interCharSpacing)
        {
            // largest rect
            Rectangle largestRect = new Rectangle(0, 0, 0, 0);

            // iterate through chars
            for (int charIdx = 0; charIdx < charInfoArray.Length; charIdx++)
            {
                // get the string of the characer
                string letterString = charInfoArray[charIdx].Character.ToString();

                // set proposed size with dimensions set to the maximum integer value.
                Size proposedSize = new Size(int.MaxValue, int.MaxValue);

                // measure the size of the character in pixels
                Size stringSize = TextRenderer.MeasureText(letterString, charInfoArray[charIdx].fontInfo.WindowsFont);

                // check if larger
                largestRect.Height = Math.Max(largestRect.Height, stringSize.Height);
                largestRect.Width = Math.Max(largestRect.Width, stringSize.Width);
            }

            // add inter-character spacing
            largestRect.Width += interCharSpacing;

            // add line spacing
            //    largestRect.Height += lineSpacing;

            // return largest
            return largestRect;
        }