当前位置: 首页>>代码示例>>C#>>正文


C# Control.DrawToBitmap方法代码示例

本文整理汇总了C#中System.Windows.Forms.Control.DrawToBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# Control.DrawToBitmap方法的具体用法?C# Control.DrawToBitmap怎么用?C# Control.DrawToBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Control的用法示例。


在下文中一共展示了Control.DrawToBitmap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetTransparentControl

        /// <summary>
        /// Поставить прозрачность + картинка
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="usedControl"></param>
        /// <param name="img"></param>
        public static void SetTransparentControl(Control parent, Panel usedControl, Image img)
        {
            //try
            //{
                //Получить координаты контрола
                var point = new Point(usedControl.Left, usedControl.Top);
                var width = usedControl.Width;
                var height = usedControl.Height;

                var destRect = new Rectangle(0, 0, width, height);//куда вставляем
                var srcRect = new Rectangle(point.X, point.Y, width, height);//Что вырезаем

                var buff = new Bitmap(parent.Width, parent.Height, PixelFormat.Format32bppArgb);
                var dest = new Bitmap(width, height, PixelFormat.Format32bppArgb);

                using (var gr = Graphics.FromImage(dest))
                {
                    parent.DrawToBitmap(buff, new Rectangle(0, 0, parent.Width, parent.Height));
                    gr.DrawImage(buff, destRect, srcRect, GraphicsUnit.Pixel);

                    if (img != null)
                        gr.DrawImage(img, 0, 0, width, height);
                }

                usedControl.BackgroundImage = dest;

            //}
            //catch (Exception ex)
            //{
            //    Logger.ExceptionSaveAndThrow(ex);
            //}
        }
开发者ID:scherbinin,项目名称:Photo-Room,代码行数:38,代码来源:TransparentAdder.cs

示例2: PictureButton

        public PictureButton(Control parent)
        {
            _parent = parent;

            var point = new Point(Left, Top);
            var width = Width;
            var height = Height;

            var destRect = new Rectangle(0, 0, width, height);//куда вставляем
            var srcRect = new Rectangle(point.X, point.Y, width, height);//Что вырезаем

            var buff = new Bitmap(Width, Height, PixelFormat.Format32bppArgb);
            var dest = new Bitmap(width, height, PixelFormat.Format32bppArgb);

            using (var gr = Graphics.FromImage(dest))
            {
                _parent.DrawToBitmap(buff, new Rectangle(0, 0, Width, Height));
                gr.DrawImage(buff, destRect, srcRect, GraphicsUnit.Pixel);

                if(Image!=null)
                    gr.DrawImage(Image, 0, 0, width, height);
            }

            Image = dest;
        }
开发者ID:scherbinin,项目名称:Photo-Room,代码行数:25,代码来源:PictureButton.cs

示例3: GenerateImage

 /// <summary>
 /// 
 /// </summary>
 /// <param name="panel"></param>
 public static void GenerateImage(Control panel)
 {
     //Save control images for documentation purposes
     var image = new Bitmap(panel.ClientRectangle.Width, panel.ClientRectangle.Height);
     panel.DrawToBitmap(image, panel.ClientRectangle);
     image.Save(panel.Name + ".png");
 }
开发者ID:FinalFrontierPrototyping,项目名称:AxialFluxGeneratorDesigner,代码行数:11,代码来源:ControlToImage.cs

示例4: TakeSnapshotFromControl

        public static Bitmap TakeSnapshotFromControl(Control control)
        {
            if (control == null) throw new ArgumentNullException("control");

            var bitmap = new Bitmap(control.Width, control.Height);
            control.DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height));
            return bitmap;
        }
开发者ID:szabototo89,项目名称:EVA2-Lectures,代码行数:8,代码来源:FormUtils.cs

示例5: SavePng

 public static void SavePng(string received, Control control)
 {
     using (var b = new Bitmap(control.Width, control.Height, PixelFormat.Format32bppArgb))
     {
         control.DrawToBitmap(b, new Rectangle(0, 0, control.Width, control.Height));
         b.Save(received, ImageFormat.Png);
     }
 }
开发者ID:EamonNerbonne,项目名称:ApprovalTests.Net,代码行数:8,代码来源:WinFormsUtils.cs

示例6: createBitmapPreview

 /// <summary>
 /// Creates the bitmap preview. Will distort BMP
 /// </summary>
 /// <param name="src">The shape to scale bitmap to.</param>
 /// <param name="width">The width to scale down to.</param>
 /// <param name="height">The height to scale down to.</param>
 /// <returns></returns>
 public static Bitmap createBitmapPreview(Control src, int width, int height)
 {
     using (var bmp = new Bitmap(src.Width, src.Height))
     {
         src.DrawToBitmap(bmp, new Rectangle(0, 0, src.Width, src.Height));
         return ResizeImage(bmp, new Size(width, height));
     }
 }
开发者ID:jrpavoncello,项目名称:OrbitMapper,代码行数:15,代码来源:ImageUtilities.cs

示例7: SetDragImage

		/// <summary>
		/// Sets the drag image as the rendering of a control.
		/// </summary>
		/// <param name="dataObject">The DataObject to set the drag image on.</param>
		/// <param name="control">The Control to render as the drag image.</param>
		/// <param name="cursorOffset">The location of the cursor relative to the control.</param>
		public static void SetDragImage(this System.Windows.Forms.IDataObject dataObject, Control control, Point cursorOffset) {
			int width = control.Width;
			int height = control.Height;

			var bmp = new Bitmap(width, height);
			control.DrawToBitmap(bmp, new Rectangle(0, 0, width, height));

			SetDragImage(dataObject, bmp, cursorOffset);
		}
开发者ID:hbaes,项目名称:updateSystem.NET,代码行数:15,代码来源:SwfDataObjectExtensions.cs

示例8: GetForeground

 protected virtual Bitmap GetForeground(Control ctrl)
 {
     Bitmap bitmap = new Bitmap(base.Width, base.Height);
     if (!ctrl.IsDisposed)
     {
         this.isSnapshotNow = true;
         ctrl.DrawToBitmap(bitmap, new Rectangle(this.Padding.Left, this.Padding.Top, ctrl.Width, ctrl.Height));
         this.isSnapshotNow = false;
     }
     return bitmap;
 }
开发者ID:weitaoxiao,项目名称:ClientEngine,代码行数:11,代码来源:DecorationControl.cs

示例9: FormToBitmap

 public static Image FormToBitmap(Control form, Size size)
 {
     Size formSize = form.Size;
     Rectangle rect = new Rectangle(new Point(0, 0), formSize);
     Bitmap bitmap = new Bitmap(formSize.Width, formSize.Height);
     form.DrawToBitmap(bitmap, rect);
     Bitmap result = new Bitmap(size.Width, size.Height);
     Graphics g = Graphics.FromImage(result);
     rect.Size = size;
     g.DrawImage(bitmap, rect);
     return result;
 }
开发者ID:dishiyicijinqiu,项目名称:OneCardAccess,代码行数:12,代码来源:ThumbnailHelper.cs

示例10: DrawBackControl

 private void DrawBackControl(Control c, System.Windows.Forms.PaintEventArgs pevent)
 {
     using (Bitmap bmp = new Bitmap(c.Width, c.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
     {
         c.DrawToBitmap(bmp, new Rectangle(0, 0, c.Width, c.Height));
         int offsetX = (c.Left - this.Left) -
             (int)Math.Floor((double)(this.Bounds.Width - this.ClientRectangle.Width) / 2.0);
         int offsetY = (c.Top - this.Top) - (int)Math.Floor
             ((double)(this.Bounds.Height -
             this.ClientRectangle.Height) / 2.0);
         pevent.Graphics.DrawImage(bmp, offsetX, offsetY, c.Width, c.Height);
     }
 }
开发者ID:utau1116b,项目名称:Hello-World,代码行数:13,代码来源:PictureBoxImage.cs

示例11: DoFade

        public void DoFade(Control panel1, Control panel2)
        {
            _startimage = new Bitmap(panel1.Width, panel1.Height);
            _endimage = new Bitmap(panel2.Width, panel2.Height);

            panel1.DrawToBitmap(_startimage, panel1.ClientRectangle);
            panel2.DrawToBitmap(_endimage, panel2.ClientRectangle);

            Location = panel1.Location;
            Size = panel1.Size;

            _fade = 1;

            _tmr.Interval = 1;
            _tmr.Enabled = true;
        }
开发者ID:stuartd,项目名称:keymapper,代码行数:16,代码来源:fader.cs

示例12: GetScreenBackground

        /*
        private Bitmap GetScreenBackground(Control ctrl, bool includeForeground, bool clip)
        {
            var size = GetBounds().Size;
            Graphics temp = FakeControl.CreateGraphics();//???
            var bmp = new Bitmap(size.Width, size.Height, temp);
            Graphics gr = Graphics.FromImage(bmp);
            var p = ctrl.Parent == null? ctrl.Location : ctrl.Parent.PointToScreen(ctrl.Location);
            gr.CopyFromScreen(p.X - animation.Padding.Left, p.Y - animation.Padding.Top, 0, 0, size);
            return bmp;
        }*/
        protected virtual Bitmap GetForeground(Control ctrl)
        {
            Bitmap bmp = null;

            if (!ctrl.IsDisposed)
            {
                if (ctrl.Parent == null)
                {
                    bmp = new Bitmap(ctrl.Width + animation.Padding.Horizontal, ctrl.Height + animation.Padding.Vertical);
                    ctrl.DrawToBitmap(bmp, new Rectangle(animation.Padding.Left, animation.Padding.Top, ctrl.Width, ctrl.Height));
                }
                else
                {
                    bmp = new Bitmap(DoubleBitmap.Width, DoubleBitmap.Height);
                    ctrl.DrawToBitmap(bmp, new Rectangle(ctrl.Left - DoubleBitmap.Left, ctrl.Top - DoubleBitmap.Top, ctrl.Width, ctrl.Height));
            #if debug
            using (var gr = Graphics.FromImage(bmp))
                gr.DrawLine(Pens.Red, 0, 0, DoubleBitmap.Width, DoubleBitmap.Height);
            #endif
                }
            }

            return bmp;
        }
开发者ID:tsovince,项目名称:V_Library,代码行数:35,代码来源:Controller.cs

示例13: GetForeground

        protected virtual Bitmap GetForeground(Control ctrl)
        {
            Bitmap bmp = new Bitmap(this.Width, this.Height);

            if (!ctrl.IsDisposed)
            {
                isSnapshotNow = true;
                ctrl.DrawToBitmap(bmp, new Rectangle(Padding.Left, Padding.Top, ctrl.Width, ctrl.Height));
                isSnapshotNow = false;
            }
            return bmp;
        }
开发者ID:modulexcite,项目名称:Animator,代码行数:12,代码来源:DecorationControl.cs

示例14: Draw

 /// <summary>
 /// Draws the control to a bitmap.
 /// </summary>
 /// <param name="control">The control to draw.</param>
 /// <returns>An image with the control drawn onto it.</returns>
 /// <remarks>Internally uses WM_PRINT to draw the control to an HDC</remarks>
 public static Bitmap Draw(Control control)
 {
     Bitmap dest = new Bitmap(control.Width, control.Height);
     control.DrawToBitmap(dest, new Rectangle(0, 0, control.Width, control.Height));
     return dest;
 }
开发者ID:TGOSeraph,项目名称:StUtil,代码行数:12,代码来源:ScreenCapture.cs

示例15: Show

 //-------------------------------------------------------------------------------------
 /// <summary>
 /// Отображает контрол в указанном родителе.
 /// </summary>
 /// <param name="parent">Родительский контрол.</param>
 /// <param name="useBack">Определяет, будет ли использоваться эмуляция прозрачности фона.</param>
 public static void Show(Control parent, bool useBack = true)
 {
  SimProgress box = new SimProgress();
  foreach(Control c in parent.Controls)
   if(c is SimProgress)
   {
    ((SimProgress)c).Start();
    return;
   }
  Rectangle r = new Rectangle(Point.Empty, parent.Size);
  try
  {
   if(useBack)
   {
    r.X = -1*(parent.Width - parent.ClientSize.Width)/2;
    r.Y = -1*(parent.Height - parent.ClientSize.Height)/2;
    Bitmap bmp = new Bitmap(r.Width, r.Height);
    parent.DrawToBitmap(bmp, new Rectangle(Point.Empty, parent.Size)); //parent.Location 
    BitmapEffects.GaussianBlur(bmp, 4);
    BitmapEffects.Ligth(bmp, 50);
    if(box.BackgroundImageLayout != ImageLayout.Center)
     box.BackgroundImageLayout = ImageLayout.Center;
    box.BackgroundImage = bmp;  
   }
   else
    box.BackColor = Color.Transparent;
  }
  catch
  {
  }
  box.Bounds = r;
  parent.Controls.Add(box);
  box.BringToFront();
  box.timer.Start();
  parent.SizeChanged += new EventHandler(parent_SizeChanged);
 }
开发者ID:GoldMax,项目名称:Pulsar.NET,代码行数:42,代码来源:SimProgress.cs


注:本文中的System.Windows.Forms.Control.DrawToBitmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。