示例#1
0
        public void LoadImageLibrary(string filename)
        {
            try
            {
                var lib = new SodaImageLibrary(filename);

                if (ImageLibrary != null)
                {
                    foreach (var img in ImageLibrary.Images)
                    {
                        img.FreeImages();
                    }
                }

                LibraryName  = Path.GetFileName(filename);
                ImageLibrary = lib;
                Refresh();
            }
            catch (Exception)
            {
                throw new ArgumentException("There was an exception loading the library");
            }
        }
示例#2
0
        public void ConvertWilTask(string file, string dest)
        {
            SelectedWil = new WilLibrary(file);

            var countimg = SelectedWil.Images.Count();

            SelectedWil = null;

            var title = Path.GetFileNameWithoutExtension(file);

            SodaImageLibrary lib = new SodaImageLibrary(title + ".slib");

            WilLibrary wil = new WilLibrary(file);

            for (int i = 0; i < countimg - 1; i++)
            {
                var wilimg = wil.GetCachedImage(i);

                if (wilimg != null)
                {
                    var image = new SodaImage();
                    image.Height     = wil.Images[i].Height;
                    image.Width      = wil.Images[i].Width;
                    image.PlacementX = wil.Images[i].PlacementX;
                    image.PlacementY = wil.Images[i].PlacementY;

                    using (var img = new MagickImage((Bitmap)wilimg))
                    {
tryagain:
                        try
                        {
                            img.Transparent(MagickColors.Black);
                            var newimg = img.ToBitmap();
                            image.Image = newimg;
                        }
                        catch (Exception ex)
                        {
                            var stop = true;
                            goto tryagain;
                        }
                    }

                    lib.Images.Add(image);
                }
                else
                {
                    var image = new SodaImage();
                    image.Height     = 0;
                    image.Width      = 0;
                    image.PlacementX = 0;
                    image.PlacementY = 0;
                    image.Image      = null;

                    lib.Images.Add(image);
                }
            }

            lib.WriteToBinaryFile(dest + "\\" + title + ".slib", lib, false);

            foreach (var img in lib.Images)
            {
                img.FreeImages();
            }
        }