Ejemplo n.º 1
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.º 2
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 =>
                {
                    WTLImage image       = Images[i];
                    WTLImage shadowimage = shadowLibrary != null ? shadowLibrary.Images[i] : null;

                    if (shadowimage != null)
                    {
                        lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image, shadowimage.Image, image.MaskImage)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY, ShadowType = image.Shadow
                        }
                    }
                    ;
                    else
                    {
                        lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image, null, image.MaskImage)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY, ShadowType = image.Shadow
                        }
                    };
                });
                lib.AddBlanks(newImages);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public void MergeToMLibrary(Mir3Library lib, int newImages)
        {
            int offset = lib.Images.Count;

            lib.Images.AddRange(Enumerable.Repeat(new Mir3Library.Mir3Image(), Images.Count));
            //library.Save();

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            try
            {
                Parallel.For(0, Images.Count, options, i =>
                {
                    MImage image = Images[i];
                    if (image.HasMask)
                    {
                        lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image, null, image.MaskImage)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                        }
                    }
                    ;
                    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
        private void MergeButton_Click(object sender, EventArgs e)
        {
            if (_library == null)
            {
                return;
            }
            if (_library.FileName == null)
            {
                return;
            }

            string value = "1000";
            int    temp  = 0;

            if (InputBox("Merge Blanks", "How Many Images Per Object:", ref value) == DialogResult.OK)
            {
                if (!int.TryParse(value, out temp))
                {
                    MessageBox.Show("Should be a numeric value");
                    return;
                }
                if (temp <= 0)
                {
                    MessageBox.Show("Must be atleast 1");
                    return;
                }
                newImages = temp;
            }

            _library.AddBlanks(newImages);

            if (OpenMergeDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            toolStripProgressBar.Maximum = OpenMergeDialog.FileNames.Length;
            toolStripProgressBar.Value   = 0;

            try
            {
                foreach (string file in OpenMergeDialog.FileNames)
                {
                    if (Path.GetExtension(file).ToUpper() == ".ZL")
                    {
                        Mir3Library newLib = new Mir3Library(file);
                        foreach (Mir3Library.Mir3Image image in newLib.Images)
                        {
                            _library.AddImage(image.Image, image.OffSetX, image.OffSetY);
                        }
                    }
                    else if (Path.GetExtension(file).ToUpper() == ".WTL")
                    {
                        WTLLibrary WTLlib = new WTLLibrary(file);
                        WTLlib.MergeToMLibrary(_library, newImages);
                    }
                    else if (Path.GetExtension(file).ToUpper() == ".LIB")
                    {
                        FileStream   stream         = new FileStream(file, FileMode.Open, FileAccess.ReadWrite);
                        BinaryReader reader         = new BinaryReader(stream);
                        int          CurrentVersion = reader.ReadInt32();
                        stream.Close();
                        stream.Dispose();
                        reader.Dispose();
                        if (CurrentVersion == 1)
                        {
                            MLibrary v1Lib = new MLibrary(file);
                            v1Lib.MergeToMLibrary(_library, newImages);
                        }
                        else
                        {
                            MLibraryV2 v2Lib = new MLibraryV2(file);
                            v2Lib.MergeToMLibrary(_library, newImages);
                        }
                    }
                    else
                    {
                        WeMadeLibrary WILlib = new WeMadeLibrary(file);
                        WILlib.MergeToMLibrary(_library, newImages);
                    }
                    toolStripProgressBar.Value++;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            toolStripProgressBar.Value = 0;

            MessageBox.Show(string.Format("Successfully merged {0} {1}",
                                          (OpenMergeDialog.FileNames.Length).ToString(),
                                          (OpenMergeDialog.FileNames.Length > 1) ? "libraries" : "library"));

            ImageList.Images.Clear();
            _indexList.Clear();
            PreviewListView.VirtualListSize = _library.Images.Count;

            _library.Save(_library.FileName);
        }