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


C# Form.DrawToBitmap方法代码示例

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


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

示例1: ScreenCapture

        public static void ScreenCapture(string received, Form form)
        {
            EnsureControlDisplaysCorrectlyByAddingItToAHiddenForm(form);

            var b = new Bitmap(form.Width, form.Height, PixelFormat.Format32bppArgb);
            form.DrawToBitmap(b, new Rectangle(0, 0, form.Width, form.Height));
            b.Save(received, ImageFormat.Png);
        }
开发者ID:Vidarls,项目名称:ApprovalTests,代码行数:8,代码来源:WinFormsUtils.cs

示例2: Draw

        /// <summary>
        /// Draws the form to a bitmap.
        /// </summary>
        /// <param name="form">The form to draw.</param>
        /// <param name="clientArea">If only the client area (non-chrome area) should be drawn.</param>
        /// <returns>An image with the form drawn onto it.</returns>
        /// <remarks>Internally uses WM_PRINT to draw the form to an HDC.</remarks>
        public static Bitmap Draw(Form form, bool clientArea)
        {
            Bitmap bmp = new Bitmap(form.Width, form.Height);
            form.DrawToBitmap(bmp, new Rectangle(0, 0, form.Width, form.Height));

            if (clientArea)
            {
                Bitmap crop = new Bitmap(form.ClientRectangle.Width, form.ClientRectangle.Height);
                using (Graphics g = Graphics.FromImage(crop))
                {
                    Rectangle screenRectangle = form.RectangleToScreen(form.ClientRectangle);
                    int titleHeight = screenRectangle.Top - form.Top;
                    g.DrawImage(bmp, new Point((form.ClientRectangle.Width - form.Width) / 2, -titleHeight));
                }
                bmp.Dispose();
                bmp = crop;
            }
            return bmp;
        }
开发者ID:TGOSeraph,项目名称:StUtil,代码行数:26,代码来源:ScreenCapture.cs

示例3: DisplayComparisonPlot

        private void DisplayComparisonPlot(MSSpectra spectrumX, MSSpectra spectrumY, double mzTolerance,
            string path = "comparison.png", string newTitle = "MS/MS Spectra")
        {
            var model = CreatePlot(spectrumX.Peaks, spectrumY.Peaks, mzTolerance);
            model.Title = newTitle;

            var plot = new PlotView();
            plot.Model = model;
            var form = new Form();
            form.Size = Screen.PrimaryScreen.WorkingArea.Size;
            plot.Dock = DockStyle.Fill;
            form.Controls.Add(plot);
            form.Show();

            IO.Utilities.SleepNow(3);

            using (var bitmap = new Bitmap(form.Width, form.Height))
            {
                form.DrawToBitmap(bitmap, form.DisplayRectangle);
                bitmap.Save(path);
            }
        }
开发者ID:msdna,项目名称:MultiAlign,代码行数:22,代码来源:SpectralComparisonTests.cs

示例4: PaintMap

        public Bitmap PaintMap(Form f1, Graphics grap)
        {
            try
            {
                mapimage = new Bitmap(f1.Width, f1.Height);
                Rectangle frame = new Rectangle(new System.Drawing.Point(f1.Width, f1.Height), f1.Size);
                f1.DrawToBitmap(mapimage, frame);
                grap = Graphics.FromImage(mapimage);
                string[] lines = System.IO.File.ReadAllLines(_mapname.ToString());
                int Index_x;
                int Limit = _wide - 1;
                int Index_y;
                int Limit_Y = _height - 1;
                for (Index_x = 0; Index_x < Limit; Index_x++)
                {
                    for (Index_y = 0; Index_y < Limit_Y; Index_y++)
                    {
                        //paint(grap, new Point(Index_x, Index_y), 0);
                    }
                }

            }
            catch (Exception p)
            {
                Console.Write(p.Message);

            }
            return mapimage;
        }
开发者ID:jose-sanchez,项目名称:EvolutionSimulator,代码行数:29,代码来源:GMap.cs

示例5: TAC_TurnAreaToPixData

        //当前窗口上指定相对坐标,指定范围,转为点阵数据。
        public static byte[][] TAC_TurnAreaToPixData(Form fmImaNoScreen, int nPositionX, int nPositionY, int nAreaWidth, int nAreaHeight)
        {
            byte[][] tempDesData = new byte[nAreaHeight][];
            for (int i = 0; i < nAreaHeight; i++)
                tempDesData[i] = new byte[nAreaWidth];
            try
            {
                Bitmap bmpForm = new Bitmap(fmImaNoScreen.Width, fmImaNoScreen.Height);
                fmImaNoScreen.DrawToBitmap(bmpForm, new Rectangle(0, 0, bmpForm.Width, bmpForm.Height));
                Bitmap bmpDes = new Bitmap(nAreaWidth, nAreaHeight);
                Graphics grpForm = Graphics.FromImage(bmpDes);
                int Border = (fmImaNoScreen.Width - fmImaNoScreen.ClientSize.Width) / 2;
                Rectangle destRect = new Rectangle(nPositionX + Border,
                    nPositionY + fmImaNoScreen.Height - fmImaNoScreen.ClientSize.Height - Border,
                    nAreaWidth, nAreaHeight);
                Rectangle srcRect = new Rectangle(0, 0, nAreaWidth, nAreaHeight);
                grpForm.DrawImage(bmpForm, srcRect, destRect, GraphicsUnit.Pixel);

                System.Drawing.Imaging.BitmapData tempBitmapData = bmpDes.LockBits(srcRect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                fmImaNoScreen.Enabled = false;
                unsafe
                {
                    byte* tempPixelData = (byte*)tempBitmapData.Scan0.ToPointer();
                    int jump = tempBitmapData.Stride - nAreaWidth * 3;
                    for (int i = 0; i < nAreaHeight; i++)
                    {
                        for (int j = 0; j < nAreaWidth; j++)
                        {
                            tempDesData[i][j] = TAC_IsBlack(*tempPixelData ^ 0xff, *(tempPixelData + 1) ^ 0xff, *(tempPixelData + 2) ^ 0xff, 1);
                            tempPixelData += 3;
                        }
                        tempPixelData += jump;
                    }
                }
                fmImaNoScreen.Enabled = true;
            }
            catch (Exception Mistake)
            {
                MessageBox.Show(Mistake.ToString());
                return null;
            }
            return tempDesData;
        }
开发者ID:aircross,项目名称:vs-projects,代码行数:45,代码来源:TEXTANDPIC.cs


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