コード例 #1
0
        //============================================================
        // <T>合并压缩。</T>
        //
        // @autor DYWEN 20120712
        //============================================================
        public void tsbShowImage_Click(object sender, EventArgs e)
        {
            GetRectangle();
            SIntPoint2      sintp2  = GetAllRectangle(maxW, maxH);
            Bitmap          _bitmap = new Bitmap(sintp2.X, sintp2.Y);
            FRsResourceClip rcl     = _resourceAnimation.FristClip;
            Graphics        g       = Graphics.FromImage(_bitmap);

            for (int i = 0; i < rcl.FrameCount; i++)
            {
                Bitmap bmn = rcl.Frames.Items[i].Bitmap.Native;
                _fCutBitmap = new FBitmap(bmn);
                SIntRectangle rct = _fCutBitmap.TestValidRectangle(1);
                Bitmap        p   = bmn.Clone(new Rectangle(rct.Left, rct.Top, rct.Width, rct.Height), PixelFormat.Format32bppArgb);
                // 防止图片缩放问题
                g.DrawImage(p, i * maxW, 0, p.Width, p.Height);
            }
            QDsResourceViewForm sci = new QDsResourceViewForm();

            foreach (Control item in sci.Controls)
            {
                if (item is PictureBox)
                {
                    PictureBox picbox = item as PictureBox;
                    picbox.Width           = _bitmap.Width;
                    picbox.Height          = _bitmap.Height;
                    picbox.BackgroundImage = _bitmap;
                }
            }
            String mapInfo = "宽:" + _bitmap.Width + " " + "高:" + _bitmap.Height;

            sci.Text = mapInfo;
            g.Dispose();
            sci.Show();
        }
コード例 #2
0
        //============================================================
        // <T>获取有效区域</T>
        //
        // @autor DYWEN 20120816
        //============================================================
        public void GetRectangle()
        {
            FRsResourceClip rcl = _resourceAnimation.FristClip;

            for (int i = 0; i < rcl.FrameCount; i++)
            {
                Bitmap        bmn     = rcl.Frames.Items[i].Bitmap.Native;
                FBitmap       fbitmap = new FBitmap(bmn);
                SIntRectangle rcthw   = fbitmap.TestValidRectangle(1);
                int           height  = rcthw.Height;
                if (maxH < height)
                {
                    maxH = height;
                }
                int width = rcthw.Width;
                if (maxW < width)
                {
                    maxW = width;
                }
            }
        }
コード例 #3
0
 //============================================================
 // <T>打开资源。</T>
 //============================================================
 public void Open()
 {
     if (!_opened)
     {
         // 加载图片
         _bitmap      = new FBitmap(_fileName);
         _size.Width  = _bitmap.Width;
         _size.Height = _bitmap.Height;
         // 获取有效范围
         _bitmap.TestValidRectangle(_validRectangle, 8);
         // 计算有效重心
         _validBarycenter.X = (_size.Width / 2) - _validRectangle.Left;
         _validBarycenter.Y = (_size.Height / 2) - _validRectangle.Top;
         if (!_validRectangle.IsEmpty)
         {
             Bitmap nativeBitmap = _bitmap.Native.Clone(new Rectangle(_validRectangle.Left, _validRectangle.Top, _validRectangle.Width, _validRectangle.Height), PixelFormat.Format32bppArgb);
             _validBitmap = new FBitmap(nativeBitmap);
             int width  = _validRectangle.Width;
             int height = _validRectangle.Height;
         }
         _opened = true;
     }
 }