Beispiel #1
0
        private void extract_Image_ClickTiff(object sender, EventArgs e)
        {
            if (!Art.IsValidStatic(index))
            {
                return;
            }
            string   path     = FiddlerControls.Options.OutputPath;
            string   FileName = Path.Combine(path, String.Format("Item 0x{0:X}.tiff", index));
            Bitmap   bit      = new Bitmap(Ultima.Art.GetStatic(index).Width, Ultima.Art.GetStatic(index).Height);
            Graphics newgraph = Graphics.FromImage(bit);

            newgraph.Clear(Color.Transparent);
            Bitmap huebit = new Bitmap(Ultima.Art.GetStatic(index));

            if (defHue > 0)
            {
                Hue hue = Ultima.Hues.List[defHue];
                hue.ApplyTo(huebit, partialHue);
            }
            newgraph.DrawImage(huebit, 0, 0);
            bit.Save(FileName, ImageFormat.Tiff);
            MessageBox.Show(
                String.Format("Item saved to {0}", FileName),
                "Saved",
                MessageBoxButtons.OK,
                MessageBoxIcon.Information,
                MessageBoxDefaultButton.Button1);
        }
Beispiel #2
0
        private void AnimTick(object sender, EventArgs e)
        {
            ++frame;
            if (frame >= info.FrameCount)
            {
                frame = 0;
            }

            Bitmap animbit = new Bitmap(Ultima.Art.GetStatic(index + info.FrameData[frame]));

            if (defHue >= 0)
            {
                Hue hue = Ultima.Hues.List[defHue];
                hue.ApplyTo(animbit, partialHue);
            }
            Graphic.Tag = animbit;
            Graphic.Invalidate();
        }
Beispiel #3
0
        private void GenerateImage()
        {
            Frame[] animFrames = Animations.GetAnimation(m_BodyId, 0, 1, (m_Hue - 1), false);

            Bitmap bmp = null;

            if (Bestiary.UseFixes)
            {
                string fixPath = Path.Combine("Bestiary/fixes", m_MasterType.Name + ".jpg");

                if (File.Exists(fixPath))
                {
                    bmp = new Bitmap(fixPath);
                }
            }

            if (animFrames != null || bmp != null)
            {
                using (Bitmap mobImage = new Bitmap(bmp ?? animFrames[0].Bitmap))
                {
                    using (Bitmap result = new Bitmap(m_BorderImage.Width, m_BorderImage.Height))
                    {
                        using (Bitmap title = ASCIIText.DrawText(3, m_Name, 0x3B2))
                        {
                            using (Graphics gr = Graphics.FromImage(result))
                            {
                                using (Bitmap tz = ASCIIText.DrawText(3, " - The Retelling - Bestiary -", 1260))
                                {
                                    using (SolidBrush blackBrush = new SolidBrush(Color.FromArgb(60, 1, 1, 1)))
                                    {
                                        if (m_Hue > 0)
                                        {
                                            Hue hue = GetHue(m_Hue - 1);

                                            if (hue != null)
                                            {
                                                // explicitely apply the hue, GetAnimation method doesn't work for few bodyIds.
                                                hue.ApplyTo(mobImage, false);
                                            }
                                        }

                                        GraphicsUnit unit = GraphicsUnit.Pixel;
                                        RectangleF   rect = mobImage.GetBounds(ref unit);
                                        int          trX  = (214 - (mobImage.Width >> 1));
                                        int          trY  = (170 - (mobImage.Height >> 1));
                                        int          brX  = (int)(trX + rect.Width);
                                        int          brY  = (int)(trY + rect.Height);

                                        string customBg = Bestiary.TypeRegistry[m_MasterType].Background;

                                        if (!string.IsNullOrEmpty(customBg))
                                        {
                                            using (Bitmap cBg = new Bitmap(customBg))
                                            {
                                                gr.DrawImage(cBg, 0.0f, 0.0f);
                                            }
                                        }
                                        else
                                        {
                                            gr.DrawImage(m_Background, 0.0f, 0.0f);
                                        }

                                        gr.FillRectangle(blackBrush, new Rectangle(22, 22, 385, 30));
                                        gr.DrawImage(
                                            m_WaterMark,
                                            new Rectangle(0, 0, m_BorderImage.Width, m_BorderImage.Height),
                                            0,
                                            0,
                                            m_BorderImage.Width,
                                            m_BorderImage.Height,
                                            GraphicsUnit.Pixel,
                                            imgAttrs
                                            );
                                        gr.DrawImage(title, ((brX + trX) >> 1) - (title.Width >> 1), trY - 5 - title.Height);
                                        gr.DrawImage(mobImage, trX, trY);
                                        gr.DrawImage(m_BorderImage, 0, 0, m_BorderImage.Width, m_BorderImage.Height);
                                        gr.DrawImage(tz, 100, 25);

                                        result.Save(Path.Combine("./Bestiary/images/", m_MasterType.Name + ".jpg"), m_Encoder, m_EncoderParameter);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("Couldn't acquire animation frames for bodyID: {0}, {1}", m_BodyId, m_Name);
            }
        }