Пример #1
0
        public Image GetCachedImage(int index)
        {
            if (Images != null && index >= 0 && index <= Images.Length)
            {
                if (Images[index] == null)
                {
                    wilFileStream.Position = WilIndex[index];
                    Images[index]          = new WILImage();
                }

                if (Images[index].Image == null)
                {
                    LoadWilImage(index);

                    Images[index].ImageTime = Environment.TickCount;

                    return(Images[index].Image);
                }
                else
                {
                    Images[index].ImageTime = Environment.TickCount;
                    return(Images[index].Image);
                }
            }

            return(null);
        }
Пример #2
0
        public WilLibrary(string wilFilePath)
        {
            WilFilePath = wilFilePath;
            WixFilePath = Path.ChangeExtension(wilFilePath, ".wix");

            MemoryCheckTime = Environment.TickCount;

            try
            {
                if (File.Exists(WilFilePath) && File.Exists(WixFilePath))
                {
                    var wilImageInfo = new WILImage();

                    wilFileStream   = new FileStream(WilFilePath, FileMode.Open, FileAccess.Read);
                    wilBinaryReader = new BinaryReader(wilFileStream);

                    LoadWilHeader();

                    LoadIndexFile(wilFilePath);

                    Images = new WILImage[WilIndex.Count];
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
Пример #3
0
        public Image GetCachedImage(int index, ref int posx, ref int posy)
        {
            if (Images != null && index >= 0 && index <= Images.Length)
            {
                if (Environment.TickCount - MemoryCheckTime > 10000)
                {
                    MemoryCheckTime = Environment.TickCount;
                    FreeOldImageMemory();
                }

                if (Images[index] == null)
                {
                    wilFileStream.Position = WilIndex[index];
                    Images[index]          = new WILImage();
                }

                if (Images[index].Image == null)
                {
                    LoadWilImage(index);

                    posx = Images[index].PlacementX;
                    posy = Images[index].PlacementY;

                    Images[index].ImageTime = Environment.TickCount;

                    return(Images[index].Image);
                }
                else
                {
                    posx = Images[index].PlacementX;
                    posy = Images[index].PlacementY;

                    Images[index].ImageTime = Environment.TickCount;

                    return(Images[index].Image);
                }
            }

            return(null);
        }
Пример #4
0
        public void LoadWilImage(int imageIndex)
        {
            try
            {
                wilFileStream.Position = WilIndex[imageIndex];

                var newWilImage = new WILImage();

                newWilImage.Width      = wilBinaryReader.ReadInt16();
                newWilImage.Height     = wilBinaryReader.ReadInt16();
                newWilImage.PlacementX = wilBinaryReader.ReadInt16();
                newWilImage.PlacementY = wilBinaryReader.ReadInt16();

                if (newWilImage.Width == 4 && newWilImage.Height == 1)
                {
                    return;
                }

                newWilImage.Size = newWilImage.Width * newWilImage.Height;

                var dno  = wilBinaryReader.ReadInt16();
                var dno2 = wilBinaryReader.ReadInt16();

                newWilImage.Size = wilBinaryReader.ReadInt32();

                var compressedImageStream   = new MemoryStream(newWilImage.Size);
                var decompressedImageStream = DecompressImageStream(compressedImageStream);

                newWilImage.ImageTime = Environment.TickCount;

                newWilImage.CreateTexture(wilBinaryReader);

                Images[imageIndex] = newWilImage;
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }