예제 #1
0
        public Mir3Library Convert()
        {
            string shadowPath = _fileName.Replace(".wtl", "_S.wtl");

            WTLLibrary shadowLibrary = null;

            if (File.Exists(shadowPath))
            {
                shadowLibrary = new WTLLibrary(shadowPath);
            }

            Mir3Library lib = new Mir3Library
            {
                Images = new Mir3Image[Images.Length]
            };

            for (int i = 0; i < Images.Length; i++)
            {
                MImage image = Images[i];
                if (image?.Texture == null)
                {
                    continue;
                }

                lib.Images[i] = image.Convert(shadowLibrary, i);
            }

            shadowLibrary?.Dispose();

            return(lib);
        }
예제 #2
0
파일: WTLLibrary.cs 프로젝트: putao520/mir3
        public void CheckImage(int index)
        {
            if (!_initialized)
            {
                Initialize();
            }
            if (Images == null || index < 0 || index >= Images.Length || _indexList[index] <= 0)
            {
                return;
            }

            if (Images[index] == null)
            {
                _fStream.Position = _indexList[index];
                Images[index]     = new MImage(_bReader);
            }

            if (Images[index].Texture == null)
            {
                _fStream.Position = _indexList[index] + 16;
                Images[index].CreateTexture(_bReader);
            }

            long max = _fStream.Length;

            for (int i = index + 1; i < Images.Length; i++)
            {
                if (_indexList[i] == 0)
                {
                    continue;
                }

                max = _indexList[i];
                break;
            }

            if (_indexList[index] + 16 + Images[index].TLength < max)
            {
                _fStream.Position = _indexList[index] + 16 + Images[index].TLength;
                Images[index].CreateOverlayTexture(_bReader);
            }
        }
예제 #3
0
파일: WTLLibrary.cs 프로젝트: putao520/mir3
        public Mir3Image Convert(WTLLibrary shadowLibrary, int index)
        {
            Mir3Image image = new Mir3Image
            {
                Width         = TWidth,
                Height        = THeight,
                OffSetX       = TOffSetX,
                OffSetY       = TOffSetY,
                ShadowType    = TShadow,
                Data          = GetBytes(Texture),
                ShadowOffSetX = TShadowX,
                ShadowOffSetY = TShadowY
            };

            if (shadowLibrary != null && shadowLibrary.HasImage(index))
            {
                MImage sImage = shadowLibrary.Images[index];

                image.ShadowWidth   = sImage.TWidth;
                image.ShadowHeight  = sImage.THeight;
                image.ShadowOffSetX = sImage.TOffSetX;
                image.ShadowOffSetY = sImage.TOffSetY;
                image.ShadowData    = GetBytes(sImage.Texture);
            }

            if (Overlay != null)
            {
                image.OverlayWidth  = OWidth;
                image.OverlayHeight = OHeight;


                image.OverLayData = GetBytes(Overlay);
            }

            return(image);
        }
예제 #4
0
파일: IMain.cs 프로젝트: junchih/mir3x
        private async void CreateLibrariesButton_Click(object sender, EventArgs e)
        {
            DirectoryInfo directory = new DirectoryInfo((string)folderTextBox.Text);

            if (!directory.Exists)
            {
                return;
            }

            DirectoryInfo[] targets = directory.GetDirectories("*.*", SubFoldersCheckEdit.Checked ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);

            if (targets.Length == 0)
            {
                targets = new[] { directory }
            }
            ;

            TotleCount    = targets.Length;
            ProgressCount = 0;

            if (targets.Length == 0)
            {
                return;
            }

            Task task = Task.Run(() =>
            {
                ParallelOptions po = new ParallelOptions {
                    MaxDegreeOfParallelism = 15
                };

                Parallel.For(0, targets.Length, po, i =>
                {
                    if (!File.Exists(targets[i].FullName + "\\Placements.txt"))
                    {
                        return;
                    }

                    string[] placements = File.ReadAllLines(targets[i].FullName + "\\Placements.txt");

                    Mir3Library lib = new Mir3Library {
                        Images = new Mir3Image[placements.Length]
                    };

                    ParallelOptions po1 = new ParallelOptions {
                        MaxDegreeOfParallelism = 15
                    };
                    Parallel.For(0, placements.Length, po1, index =>
                    {
                        string fileName = string.Format(targets[i].FullName + "\\{0:00000}.bmp", index);

                        if (!File.Exists(fileName))
                        {
                            return;
                        }

                        string[] placement = placements[index].Split(',');

                        short x = short.Parse(placement[0]);
                        short y = short.Parse(placement[1]);


                        using (Bitmap image = new Bitmap(fileName))
                        {
                            lib.Images[index] = new Mir3Image
                            {
                                Width   = (short)image.Width,
                                Height  = (short)image.Height,
                                OffSetX = x,
                                OffSetY = y,
                                Data    = MImage.GetBytes(image)
                            };
                        }
                    });

                    lib.Save(targets[i].FullName + ".Zl");

                    Interlocked.Increment(ref ProgressCount);
                });
            });

            while (!task.IsCompleted)
            {
                UpdateProgress();

                await Task.Delay(100);
            }

            ProgressLabel.Text = "Compeleted.";
        }