Ejemplo n.º 1
0
        // Get a bitmap from an image resource.
        public static Bitmap GetBitmap(ZeldaImage image)
        {
            // If the image's bitmap is already loaded, then return it.
            if (resourceBitmaps.ContainsKey(image))
                return resourceBitmaps[image];

            // Save the XNA image to memory as a png, and load it as a bitmap.
            MemoryStream ms = new System.IO.MemoryStream();
            image.Texture.SaveAsPng(ms, image.Texture.Width, image.Texture.Height);
            Bitmap bitmap = new System.Drawing.Bitmap(ms);

            // Add the new bitmap to the resource map.
            resourceBitmaps[image] = bitmap;
            return bitmap;
        }
Ejemplo n.º 2
0
        // Get a bitmap from an image resource.
        public static Bitmap GetBitmap(ZeldaImage image)
        {
            // If the image's bitmap is already loaded, then return it.
            if (resourceBitmaps.ContainsKey(image))
            {
                return(resourceBitmaps[image]);
            }

            // Save the XNA image to memory as a png, and load it as a bitmap.
            MemoryStream ms = new System.IO.MemoryStream();

            image.Texture.SaveAsPng(ms, image.Texture.Width, image.Texture.Height);
            Bitmap bitmap = new System.Drawing.Bitmap(ms);

            // Add the new bitmap to the resource map.
            resourceBitmaps[image] = bitmap;
            return(bitmap);
        }