// This unloads all data
        internal void Unload()
        {
            // Stop background loader
            StopBackgroundLoader();

            // Dispose preview manager
            previews.Dispose();
            previews = null;

            // Dispose resources
            foreach (ImageData i in images.Values)
            {
                i.Dispose();
            }
            palette = null;

            // Dispose containers
            foreach (DataReader c in containers)
            {
                c.Dispose();
            }
            containers.Clear();

            // Trash collections
            containers = null;
            images     = null;
            imageque   = null;
        }
        // This loads the PALETTE.DAT palette
        private void LoadPalette()
        {
            // Go for all opened containers
            for (int i = containers.Count - 1; i >= 0; i--)
            {
                // Load palette
                palette = containers[i].LoadPalette();
                if (palette != null)
                {
                    break;
                }
            }

            // Make empty palette when still no palette found
            if (palette == null)
            {
                General.ErrorLogger.Add(ErrorType.Warning, "None of the loaded resources define a color palette. Did you forget to configure a game GRP for this game configuration?");
                palette = new Playpal();
            }
        }
Example #3
0
        // This check image data and returns the appropriate image reader
        public static IImageReader GetImageReader(Stream data, SupportedImageFormat guessformat, Playpal palette)
        {
            //BinaryReader bindata = new BinaryReader(data);

            // This can ONLY be an ART file, right?
            if (guessformat == SupportedImageFormat.ART && data.Length > 0)
            {
                return(new ARTImageReader(palette));
            }

            // First check the formats that provide the means to 'ensure' that
            // it actually is that format. Then guess the Doom image format.

            // Data long enough to check for signatures?

            /*if(data.Length > 10)
             * {
             *      // Check for PNG signature
             *      data.Seek(0, SeekOrigin.Begin);
             *      if(CheckSignature(data, PNG_SIGNATURE)) return new FileImageReader();
             *
             *      // Check for DDS signature
             *      data.Seek(0, SeekOrigin.Begin);
             *      if(CheckSignature(data, DDS_SIGNATURE)) return new FileImageReader();
             *
             *      // Check for GIF signature
             *      data.Seek(0, SeekOrigin.Begin);
             *      if(CheckSignature(data, GIF_SIGNATURE)) return new FileImageReader();
             *
             *      // Check for BMP signature
             *      data.Seek(0, SeekOrigin.Begin);
             *      if(CheckSignature(data, BMP_SIGNATURE))
             *      {
             *              // Check if data size matches the size specified in the data
             *              if(bindata.ReadUInt32() <= data.Length) return new FileImageReader();
             *      }
             * }*/

            // Format not supported
            return(new UnknownImageReader());
        }