Ejemplo n.º 1
0
 private void CheckImage(int index)
 {
     if (!_initialized)
     {
         Initialize();
     }
     if (Images == null || index < 0 || index >= Images.Length)
     {
         return;
     }
     if (Images[index] == null)
     {
         _fStream.Position = _indexList[index];
         Images[index]     = new WeMadeImage(_bReader, _nType);
     }
     try
     {
         if (Images[index].Image == null)
         {
             _fStream.Seek(_indexList[index] + (_nType > 0 ? ImageStructureSize[_nType] : _version == 0 ? 8 : 12), SeekOrigin.Begin);
             Images[index].CreateTexture(_bReader, _palette);
         }
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 2
0
        public Bitmap GetPreview(int index)
        {
            if (index < 0 || index >= Images.Length)
            {
                return(new Bitmap(1, 1));
            }

            WeMadeImage image = Images[index];

            if (image == null || image.Image == null)
            {
                return(new Bitmap(1, 1));
            }
            else
            {
                Bitmap Preview = new Bitmap(64, 64);

                using (Graphics g = Graphics.FromImage(Preview))
                {
                    g.InterpolationMode = InterpolationMode.Low;//HighQualityBicubic
                    g.Clear(Color.Transparent);
                    int w = Math.Min((int)image.Width, 64);
                    int h = Math.Min((int)image.Height, 64);
                    g.DrawImage(image.Image, new Rectangle((64 - w) / 2, (64 - h) / 2, w, h), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);

                    g.Save();
                }
                return(Preview);
            }
        }
Ejemplo n.º 3
0
        public void MergeToMLibrary(Mir3Library lib, int newImages)
        {
            int offset = lib.Images.Count;

            for (int i = 0; i < Images.Length; i++)
            {
                lib.Images.Add(null);
            }

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            try
            {
                Parallel.For(0, Images.Length, options, i =>
                {
                    WeMadeImage image = Images[i];
                    //if (image.HasMask)
                    //    library.Images[i] = new MLibraryV2.MImage(image.Image, image.MaskImage) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0, MaskX = image.X, MaskY = image.Y };
                    // else
                    lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image)
                    {
                        OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                    };
                });
                lib.AddBlanks(newImages);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        public void ToMLibrary()
        {
            string fileName = Path.ChangeExtension(_fileName, ".Lib");

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            MLibraryV2 library = new MLibraryV2(fileName)
            {
                Images = new List <MLibraryV2.MImage>(), IndexList = new List <int>(), Count = Images.Length
            };

            //library.Save();

            for (int i = 0; i < library.Count; i++)
            {
                library.Images.Add(null);
            }

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            try
            {
                Parallel.For(0, Images.Length, options, i =>
                {
                    WeMadeImage image = Images[i];
                    if (image.HasMask)
                    {
                        library.Images[i] = new MLibraryV2.MImage(image.Image, image.MaskImage)
                        {
                            X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0, MaskX = image.X, MaskY = image.Y
                        }
                    }
                    ;
                    else
                    {
                        library.Images[i] = new MLibraryV2.MImage(image.Image)
                        {
                            X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0
                        }
                    };
                });
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                library.Save();
            }
        }
Ejemplo n.º 5
0
        public void ToMLibrary()
        {
            string fileName = Path.ChangeExtension(_fileName, ".Zl");

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            Mir3Library library = new Mir3Library(fileName)
            {
                Images = new List <Mir3Library.Mir3Image>(Images.Length)
            };

            //library.Save();

            for (int i = 0; i < Images.Length; i++)
            {
                library.Images.Add(null);
            }

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            try
            {
                Parallel.For(0, Images.Length, options, i =>
                {
                    WeMadeImage image = Images[i];
                    //if (image.HasMask)
                    //    library.Images[i] = new MLibraryV2.MImage(image.Image, image.MaskImage) { X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0, MaskX = image.X, MaskY = image.Y };
                    // else
                    library.Images[i] = new Mir3Library.Mir3Image(image.Image)
                    {
                        OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                    };
                });
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                library.Save(fileName);
            }

            // Operation finished.
            // System.Windows.Forms.MessageBox.Show("Converted " + fileName + " successfully.",
            //    "Wemade Information",
            //        System.Windows.Forms.MessageBoxButtons.OK,
            //            System.Windows.Forms.MessageBoxIcon.Information,
            //                System.Windows.Forms.MessageBoxDefaultButton.Button1);
        }
Ejemplo n.º 6
0
        public void ToImageArray()
        {
            Controls.FolderSelectDialog fbd = new Controls.FolderSelectDialog();
            fbd.ShowDialog();
            string SaveDir       = fbd.FileName;
            string placementPath = SaveDir + "\\Placements\\";

            if (!Directory.Exists(SaveDir + "\\Placements"))
            {
                Directory.CreateDirectory(SaveDir + "\\Placements");
            }

            //string fileName = Path.ChangeExtension(_fileName, ".Lib");

            // if (File.Exists(fileName))
            //     File.Delete(fileName);

            MLibraryV2 library = new MLibraryV2(null)
            {
                Images = new List <MLibraryV2.MImage>(), IndexList = new List <int>(), Count = Images.Length
            };

            //library.Save();

            for (int i = 0; i < library.Count; i++)
            {
                library.Images.Add(null);
            }

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 1
            };

            try
            {
                Parallel.For(0, Images.Length, options, i =>
                {
                    WeMadeImage image = Images[i];
                    if (image.HasMask)
                    {
                        library.Images[0] = new MLibraryV2.MImage(image.Image, image.MaskImage)
                        {
                            X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0, MaskX = image.X, MaskY = image.Y
                        }
                    }
                    ;
                    else
                    {
                        library.Images[0] = new MLibraryV2.MImage(image.Image)
                        {
                            X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.boHasShadow ? (byte)1 : (byte)0
                        }
                    };

                    try
                    {
                        // Bitmap b = new Bitmap(library.Images[i].Image);
                        library.Images[0].Image.Save(SaveDir + "\\" + i.ToString("00000") + ".png", ImageFormat.Png);

                        File.AppendAllLines(placementPath + i.ToString("00000") + ".txt", new string[] { library.Images[0].X.ToString(), library.Images[0].Y.ToString() });
                    }
                    catch (System.Exception)
                    {
                    }

                    //library.Images[i].Save( new BinaryWriter( fileName + "\\" + i.ToString("00000") + ".bmp");
                });
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                MessageBox.Show("done!");
            }
        }
Ejemplo n.º 7
0
        private void CheckImage(int index)
        {
            if (!_initialized) Initialize();
            if (Images == null || index < 0 || index >= Images.Length) return;
            if (Images[index] == null)
            {
                _fStream.Position = _indexList[index];
                Images[index] = new WeMadeImage(_bReader, _nType);
            }

            if (Images[index].Image == null)
            {
                _fStream.Seek(_indexList[index] + (_nType > 0 ? ImageStructureSize[_nType] : _version == 0 ? 8 : 12), SeekOrigin.Begin);
                Images[index].CreateTexture(_bReader, _palette);
            }
        }