//============================================================ // <T>改变大小处理。</T> // // @param width 宽度 // @param height 高度 //============================================================ public void Resize(int width, int height) { if ((_size.Width != width) || (_size.Height != height)) { _size.Set(width, height); _target.Resize(new Size(width, height)); } }
//============================================================ // <T>获得或设置设计背景颜色。</T> //============================================================ //public Color DesignBackColor { // get { return _designBackColor; } // set { // _designBackColor = value; // _designBackBrush = _context.BuildDesignColor(value); // if (_designFrame != null) { // _designFrame.DesignBackColor = value; // } // } //} //============================================================ // <T>改变大小。</T> // // @param width 宽度 // @param height 高度 //============================================================ public void Resize(int width, int height) { // 设置大小 _size.Set(width, height); // 刷新数据 Refresh(); Paint(); }
//============================================================ // <T>更新属性。</T> //============================================================ public void Update() { // 测试有效区域 SIntRectangle rect = new SIntRectangle(); RBitmap.TestValidRectangle(_bitmap, rect, _validAlpha); // 设置属性 _size.Set(_bitmap.Width, _bitmap.Height); _validLocation.Set(rect.Left, rect.Top); _validSize.Set(rect.Width, rect.Height); }
//============================================================ // <T>加载位图数据。</T> // // @param bitmap 位图 //============================================================ public void LoadBitmap(System.Drawing.Bitmap bitmap) { // 打开图片 int width = bitmap.Width; int height = bitmap.Height; _size.Set(width, height); // 读取数据 System.Drawing.Imaging.BitmapData bitmapData = bitmap.LockBits( new System.Drawing.Rectangle(0, 0, width, height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); DataStream dataStream = new DataStream(bitmapData.Scan0, bitmapData.Stride * bitmapData.Height, true, false); _properties.PixelFormat = new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied); // 创建对象 _native = new Bitmap(_device.Target, new System.Drawing.Size(width, height), dataStream, bitmapData.Stride, _properties); bitmap.UnlockBits(bitmapData); }
//============================================================ // <T>设置边界。</T> // // @param x 横坐标 // @param y 纵坐标 // @param width 宽度 // @param height 高度 //============================================================ public void SetBounds(int x, int y, int width, int height) { _location.Set(x, y); _size.Set(width, height); }