Example #1
0
        internal static Image GenerateDefaultImage(string typeName, bool bigIcon)
        {
            string back_fileName = bigIcon ? @"plain_big.png" : @"plain.png";
            float  x             = 0;
            float  y             = bigIcon ? 6 : 3;
            float  size          = bigIcon ? 36 : 17;

            string label = "";

            for (int i = 0; i < typeName.Length; i++)
            {
                if (Char.IsUpper(typeName[i]))
                {
                    label += typeName[i];
                    if (label.Length == 2)
                    {
                        break;
                    }
                }
            }

            if (label.Length < 2)
            {
                label = typeName.Substring(0, 2);
            }

            Image background = MyResources.GetImage(back_fileName);

            Graphics g = Graphics.FromImage(background);

            g.DrawString(label, new Font(new FontFamily("Consolas"), 17, FontStyle.Bold), Brushes.White, x, y);
            return(background);
        }
Example #2
0
        public static float[] LoadDigits()
        {
            Image charactersTexture = MyResources.GetImage("plot_char.png");
            // = Image.FromFile("res/plot_char.png");

            int width  = charactersTexture.Width;
            int height = charactersTexture.Height;
            int size   = width * height;

            BitmapData bitmapData = new Bitmap(charactersTexture).LockBits(
                new Rectangle(0, 0, charactersTexture.Width, charactersTexture.Height),
                ImageLockMode.ReadOnly, charactersTexture.PixelFormat);

            byte[]  bytes       = new byte[size * 4];
            float[] alphaValues = new float[size];
            Marshal.Copy(bitmapData.Scan0, bytes, 0, size * 4);

            for (int i = 0; i < size; i++)
            {
                alphaValues[i] = (float)bytes[i * 4 + 3] / 255;
            }

            return(alphaValues);
        }