Exemple #1
0
        /* Retrieves the specified image from the library. Pass the string key value.
         * Returns a default image if the passed image name is not found in the library. */
        public Bitmap GetImage(String name)
        {
            if (name != null)
            {
                if (images.ContainsKey(name))
                {
                    return(images[name]);
                }
            }

            return(images[Map.GetDefaultImage()]);
        }
Exemple #2
0
        // Loads the predermined default image file from the embedded resource file.
        public void LoadDefaultImage()
        {
            try
            {
                Assembly assembly;
                Stream   stream;

                assembly = Assembly.GetExecutingAssembly();
                stream   = assembly.GetManifestResourceStream("MapMaker.Wood,horizontal.jpg");

                // Load the default image into a properly sized copy
                Bitmap defaultImage = new Bitmap(Image.FromStream(stream), IMAGE_SIZE, IMAGE_SIZE);

                // Add the key to the default image to the palette.
                AddNewImage(Map.GetDefaultImage(), defaultImage);

                stream.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show("Default image could not be loaded.");
                Console.Write(e.ToString());
            }
        }