Пример #1
0
 public void LoadContent(Growalone growalone)
 {
     try
     {
         this.spritesheet = growalone.Content.Load <Texture2D>("star");
     }
     catch
     {
         Color[]   data      = GraphicOptions.DrawMissingnoTexture();
         Texture2D texture2D = new Texture2D(growalone.graphics.GraphicsDevice, 75, 25);
         texture2D.SetData <Color>(data);
         this.spritesheet = texture2D;
     }
 }
        public static Microsoft.Xna.Framework.Color[] DrawMissingnoTexture()
        {
            Bitmap   bitmap   = new Bitmap(75, 25);
            Graphics graphics = Graphics.FromImage(bitmap);

            graphics.Clear(System.Drawing.Color.White);
            Font font = new Font("System", 10f, FontStyle.Bold);

            graphics.DrawString("missingno", font, Brushes.Red, new PointF(5f, 5f));
            Microsoft.Xna.Framework.Color[] array = new Microsoft.Xna.Framework.Color[bitmap.Width * bitmap.Height];
            for (int i = 0; i < bitmap.Height; i++)
            {
                for (int j = 0; j < bitmap.Width; j++)
                {
                    array[j + i * bitmap.Width] = GraphicOptions.DrawingColorToXnaColor(bitmap.GetPixel(j, i));
                }
            }
            return(array);
        }
Пример #3
0
        public void UpdatePic(GraphicsDevice gd)
        {
            WebClient webClient = new WebClient();

            byte[] bytes = webClient.DownloadData("http://growalonegame.000webhostapp.com/gallery_of_worlds//" + this.name + "/" + this.thumbnail);
            File.WriteAllBytes("c:\\growalone_maps\\thumb.png", bytes);
            Bitmap bitmap = new Bitmap(1, 1);

            using (FileStream fileStream = new FileStream("c:\\growalone_maps\\thumb.png", FileMode.Open, FileAccess.Read))
            {
                bitmap = (Bitmap)Image.FromStream(fileStream);
            }
            System.Drawing.Color[] array = new System.Drawing.Color[bitmap.Width * bitmap.Height];
            array = GraphicOptions.DrawingBitmapToDrawingColorArray(bitmap);
            Microsoft.Xna.Framework.Color[] array2 = new Microsoft.Xna.Framework.Color[bitmap.Width * bitmap.Height];
            for (int i = 0; i < array.Length; i++)
            {
                array2[i] = GraphicOptions.DrawingColorToXnaColor(array[i]);
            }
            this.thumbTex = new Texture2D(gd, bitmap.Width, bitmap.Height);
            this.thumbTex.SetData <Microsoft.Xna.Framework.Color>(array2);
            File.Delete("c:\\growalone_maps\\thumb.png");
        }