Пример #1
0
        public Bitmap GetPreview(int index)
        {
            if (index < 0 || index >= Images.Length)
            {
                return(new Bitmap(1, 1));
            }

            WTLImage 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);
            }
        }
Пример #2
0
        public void CheckMImage(int index)
        {
            if (!_initialized)
            {
                Initialize();
            }

            if (index < 0 || index >= Images.Length)
            {
                return;
            }
            if (_indexList[index] == 0)
            {
                Images[index] = new WTLImage();
                return;
            }
            WTLImage image = Images[index];

            if (image == null)
            {
                _fStream.Seek(_indexList[index], SeekOrigin.Begin);
                image         = new WTLImage(_bReader);
                Images[index] = image;
                image.CreateTexture(_bReader);
            }
        }
Пример #3
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 =>
                {
                    WTLImage 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.Shadow, MaskX = image.MaskX, MaskY = image.MaskY
                        }
                    }
                    ;
                    else
                    {
                        library.Images[i] = new MLibraryV2.MImage(image.Image)
                        {
                            X = image.X, Y = image.Y, ShadowX = image.ShadowX, ShadowY = image.ShadowY, Shadow = image.Shadow
                        }
                    };
                });
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                library.Save();
            }

            // Operation finished.
            // System.Windows.Forms.MessageBox.Show("Converted " + fileName + " successfully.",
            //    "Shanda Information",
            //        System.Windows.Forms.MessageBoxButtons.OK,
            //            System.Windows.Forms.MessageBoxIcon.Information,
            //                System.Windows.Forms.MessageBoxDefaultButton.Button1);
        }