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


C# System.Drawing.Font.Dispose方法代码示例

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


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

示例1: DrawString

        private void DrawString()
        {
            WriteableBitmap writeableBmp = BitmapFactory.New(512, 512);

            WriteableBitmapExtensions.
                System.Drawing.Graphics formGraphics = this.CreateGraphics();
            string drawString = "Sample Text";
            System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16);
            System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            float x = 150.0f;
            float y = 50.0f;
            formGraphics.DrawString(drawString, drawFont, drawBrush, x, y);
            drawFont.Dispose();
            drawBrush.Dispose();
            formGraphics.Dispose();
        }
开发者ID:NecoMeco,项目名称:BuildBoardViewer,代码行数:16,代码来源:MainPage.xaml.cs

示例2: TextWidth

        public double TextWidth(string str)
        {
            System.Drawing.Font font = new System.Drawing.Font(FontFamily, (float)FontSize, System.Drawing.GraphicsUnit.Pixel);
            double w = graphics.MeasureString(str, font).Width;
            font.Dispose();

            return w;
        }
开发者ID:jmjacintos,项目名称:tesseract,代码行数:8,代码来源:WindowsGraphics.cs

示例3: TextHeight

        public double TextHeight(string str)
        {
            System.Drawing.Font font = new System.Drawing.Font(FontFamily, (float)FontSize, System.Drawing.GraphicsUnit.Pixel);
            double h = graphics.MeasureString(str, font).Height;
            font.Dispose();

            return h;
        }
开发者ID:jmjacintos,项目名称:tesseract,代码行数:8,代码来源:WindowsGraphics.cs

示例4: Add

        /// <summary>
        ///  Adds a new string to the text surface manager.  This creates
        ///  the associated text surface so that text can be rendered with
        ///  a fast Blt rather than with a DrawText call.  Note that caching
        ///  could be done in a much more efficient manner and some text
        ///  surfaces will have identical contents.
        /// </summary>
        /// <param name="key">The string to add.</param>
        internal void Add(string key)
        {
            if (key == null || key.Length == 0)
            {
                return;
            }

            // Set up the surface
            RECT rect = new RECT();
            DirectDrawSurface ddSurface = new DirectDrawSurface(StandardFontRect.Right,StandardFontRect.Bottom);
            ddSurface.TransparencyKey = DirectDrawSurface.MagentaColorKey;

            // Color in the back and add the text
            ddSurface.Surface.BltColorFill(ref rect, DirectDrawSurface.MagentaColorKey.low);
            ddSurface.Surface.SetForeColor(0);

            string text = key;
            if (text.Length > 16)
            {
                text = text.Substring(0,16);
                text += "...";
            }

            IntPtr dcHandle = new IntPtr(ddSurface.Surface.GetDC());

            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromHdc( dcHandle );

            System.Drawing.Font font = new System.Drawing.Font( "Verdana", 6.75f, System.Drawing.FontStyle.Regular );

            graphics.DrawString( text, font, System.Drawing.Brushes.Black, 1, 1 );
            graphics.DrawString( text, font, System.Drawing.Brushes.WhiteSmoke, 0, 0 );

            font.Dispose();

            graphics.Dispose();

            ddSurface.Surface.ReleaseDC( dcHandle.ToInt32() );

            sprites.Add(key, ddSurface);
        }
开发者ID:AnthonyMastrean,项目名称:terrarium2,代码行数:48,代码来源:TerrariumTextSurfaceManager.cs

示例5: DumpColRowsPlot


//.........这里部分代码省略.........
                    tg.NColumns, tg.NRows, tg.ThumbWidth, tg.ThumbHeight,
                    wastedWidth, wastedHeight,
                    extraWidth, extraHeight,
                    newContainer.Width, newContainer.Height,
                    extraWidthPercent, extraHeightPercent,
                    newContainer.AspectRatio
                    ));

                int index;

                if (plotThresholds)
                    {
                    index = seriesWW.Points.AddXY (aspectRatio, wastedWidth * 100.0);
                    if (wastedWidth == 0.0)
                        seriesWW.Points[index].IsEmpty = true;

                    index = seriesWH.Points.AddXY (aspectRatio, wastedHeight * 100.0);
                    if (wastedHeight == 0.0)
                        seriesWH.Points[index].IsEmpty = true;
                    }

                seriesNCols.Points.AddXY (aspectRatio, tg.NColumns);
                seriesNRows.Points.AddXY (aspectRatio, tg.NRows);
                }
            chartArea.RecalculateAxesScale ();

            AddARAnnotation (chart, "Fullscreen 4:3\n(1.33)", 1.33, annotationFont, plotThresholds);
            AddARAnnotation (chart, "HD 16:9\n(1.78)", 1.78, annotationFont, plotThresholds);
            AddARAnnotation (chart, "Widescreen\n(1.85)", 1.85, annotationFont, plotThresholds);
            AddARAnnotation (chart, "CinemaScope\n(2.35)", 2.35, annotationFont, plotThresholds);
            AddARAnnotation (chart, "Ultra-Panavision\n(2.76)", 2.76, annotationFont, plotThresholds);

            AddARAnnotation (chart,
                    String.Format ("Layout Threshold\n({0:F2})",
                                crossoverThreshold),
                    crossoverThreshold,
                    _tnSettings.LayoutMode == ThumbnailSettings.LayoutModes.Auto ?
                        annotationFont : annotationItFont,
                    plotThresholds,
                    true);

            if (_tnSettings.RCOptimization && plotThresholds)
                {
                switch (_tnSettings.LayoutMode)
                    {
                    case ThumbnailSettings.LayoutModes.Auto:

                        if (_tnSettings.WidthThreshold == _tnSettings.HeightThreshold)
                            AddThresholdAnnotation (chart,
                                                   String.Format ("Width & Height Threshold\n" +
                                                                 "({0:F2})", _tnSettings.WidthThreshold),
                                                   _tnSettings.WidthThreshold,
                                                   annotationFont);
                        else
                            {
                            AddThresholdAnnotation (chart,
                                                   String.Format ("Width Threshold\n" +
                                                                 "({0:F2})", _tnSettings.WidthThreshold),
                                                   _tnSettings.WidthThreshold,
                                                   annotationFont);
                            AddThresholdAnnotation (chart,
                                                   String.Format ("Height Threshold\n" +
                                                                 "({0:F2})", _tnSettings.HeightThreshold),
                                                   _tnSettings.HeightThreshold,
                                                   annotationFont);
                            }
                        break;

                    case ThumbnailSettings.LayoutModes.RowPriority:
                        AddThresholdAnnotation (chart,
                                               String.Format ("Width Threshold\n" +
                                                             "({0:F2})", _tnSettings.WidthThreshold),
                                               _tnSettings.WidthThreshold,
                                               annotationFont);
                        break;

                    case ThumbnailSettings.LayoutModes.ColumnPriority:
                        AddThresholdAnnotation (chart,
                                               String.Format ("Height Threshold\n" +
                                                             "({0:F2})", _tnSettings.HeightThreshold),
                                               _tnSettings.HeightThreshold,
                                               annotationFont);
                        break;
                    }
                }

            chart.SaveImage (filename, Charting.ChartImageFormat.Png);
            THelper.Information ("'{0}' created.", filename);

            labelStyle1.Dispose ();
            labelStyle2.Dispose ();
            labelStyle3.Dispose ();

            titleFont.Dispose ();
            subTitleFont.Dispose ();
            axisFont.Dispose ();
            annotationFont.Dispose ();
            annotationItFont.Dispose ();
            chart.Dispose ();
        }
开发者ID:rm2,项目名称:CLAutoThumbnailer,代码行数:101,代码来源:CLAutoThumbnailer.cs

示例6: GeraImage

        public string GeraImage(HttpContext pagina, string imgKey)
        {
            string strValida = imgKey;

            if (string.IsNullOrEmpty(strValida))
                strValida = ImageString();

            pagina.Response.ContentType = "image/jpeg";
            pagina.Response.Clear();
            pagina.Response.BufferOutput = true;

            System.Drawing.Bitmap img = new System.Drawing.Bitmap(_width, _height);
            System.Drawing.Graphics dr = System.Drawing.Graphics.FromImage(img);

            dr.FillRectangle(_backColor, new System.Drawing.Rectangle(0, 0, img.Width, img.Height));

            System.Drawing.Font font = new System.Drawing.Font("Verdana", 18, System.Drawing.FontStyle.Bold);
            dr.DrawString(strValida, font, _color, rnd.Next(20), rnd.Next(_height - 24));

            dr.DrawLine(new System.Drawing.Pen(_color), new System.Drawing.Point(0, rnd.Next(_height)), new System.Drawing.Point(_width, rnd.Next(_height)));
            dr.DrawLine(new System.Drawing.Pen(_color), new System.Drawing.Point(0, rnd.Next(_height)), new System.Drawing.Point(_width, rnd.Next(_height)));
            dr.DrawLine(new System.Drawing.Pen(_color), new System.Drawing.Point(0, rnd.Next(_height)), new System.Drawing.Point(_width, rnd.Next(_height)));
            dr.DrawLine(new System.Drawing.Pen(_color), new System.Drawing.Point(0, rnd.Next(_height)), new System.Drawing.Point(_width, rnd.Next(_height)));
            dr.DrawLine(new System.Drawing.Pen(_color), new System.Drawing.Point(0, rnd.Next(_height)), new System.Drawing.Point(_width, rnd.Next(_height)));
            dr.DrawLine(new System.Drawing.Pen(_color), new System.Drawing.Point(rnd.Next(_width), 0), new System.Drawing.Point(_height, rnd.Next(_width)));
            dr.DrawLine(new System.Drawing.Pen(_color), new System.Drawing.Point(rnd.Next(_width), 0), new System.Drawing.Point(_height, rnd.Next(_width)));
            dr.DrawLine(new System.Drawing.Pen(_color), new System.Drawing.Point(rnd.Next(_width), 0), new System.Drawing.Point(_height, rnd.Next(_width)));
            dr.DrawLine(new System.Drawing.Pen(_color), new System.Drawing.Point(rnd.Next(_width), 0), new System.Drawing.Point(_height, rnd.Next(_width)));
            dr.DrawLine(new System.Drawing.Pen(_color), new System.Drawing.Point(rnd.Next(_width), 0), new System.Drawing.Point(_height, rnd.Next(_width)));

            for (int x = 0; x < img.Width; x++)
                for (int y = 0; y < img.Height; y++)
                    if (rnd.Next(6) == 1)
                        img.SetPixel(x, y, _pointColor);

            font.Dispose();
            dr.Dispose();

            img.Save(pagina.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            img.Dispose();

            pagina.Response.Write(strValida);
            return strValida;
        }
开发者ID:jhomarolo,项目名称:Captcha,代码行数:44,代码来源:Captcha.cs

示例7: VerifyCode_GET

 /// <summary>
 /// 登录验证码
 /// </summary>
 public void VerifyCode_GET()
 {
     string word = null;
     VerifyCode v = new VerifyCode();
     var font = v.GetDefaultFont();
     try
     {
         font = new System.Drawing.Font(font.FontFamily, 16);
         v.AllowRepeat = false;
         Response.BinaryWrite(v.GraphicDrawImage(4,
             VerifyWordOptions.Letter,
             !true,
             font,
             60,
             out word));
         VerifyCodeManager.AddWord(word);
         Response.ContentType = "Image/Jpeg";
     }
     catch (Exception exc)
     {
         if (font != null)
         {
             font.Dispose();
         }
         throw exc;
     }
 }
开发者ID:coodream,项目名称:cms,代码行数:30,代码来源:SystemC.cs

示例8: GenerateCaptchaImage

        private byte[] GenerateCaptchaImage(string text, int width, int height)
        {
            Random random = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), System.Globalization.NumberStyles.HexNumber));

            System.Drawing.Font font;
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bmp);
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, width, height);
            System.Drawing.Drawing2D.HatchBrush brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.SmallConfetti, System.Drawing.Color.LightGray, System.Drawing.Color.White);
            graphics.FillRectangle(brush, rect);

            float emSize = rect.Height + 1;

            do {
                emSize--;
                font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, emSize, System.Drawing.FontStyle.Bold);
            } while (graphics.MeasureString(text, font).Width > rect.Width);

            System.Drawing.StringFormat format = new System.Drawing.StringFormat {
                Alignment = System.Drawing.StringAlignment.Center,
                LineAlignment = System.Drawing.StringAlignment.Center
            };

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddString(text, font.FontFamily, (int)font.Style, 75f, rect, format);
            float num2 = 4f;
            System.Drawing.PointF[] destPoints = new System.Drawing.PointF[] { new System.Drawing.PointF(((float)random.Next(rect.Width)) / num2, ((float)random.Next(rect.Height)) / num2), new System.Drawing.PointF(rect.Width - (((float)random.Next(rect.Width)) / num2), ((float)random.Next(rect.Height)) / num2), new System.Drawing.PointF(((float)random.Next(rect.Width)) / num2, rect.Height - (((float)random.Next(rect.Height)) / num2)), new System.Drawing.PointF(rect.Width - (((float)random.Next(rect.Width)) / num2), rect.Height - (((float)random.Next(rect.Height)) / num2)) };
            System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
            matrix.Translate(0f, 0f);
            path.Warp(destPoints, rect, matrix, System.Drawing.Drawing2D.WarpMode.Perspective, 0f);
            brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Percent10, System.Drawing.Color.Black, System.Drawing.Color.SkyBlue);
            graphics.FillPath(brush, path);

            int num3 = Math.Max(rect.Width, rect.Height);
            for (int i = 0; i < ((int)(((float)(rect.Width * rect.Height)) / 30f)); i++) {
                int x = random.Next(rect.Width);
                int y = random.Next(rect.Height);
                int w = random.Next(num3 / 50);
                int h = random.Next(num3 / 50);
                graphics.FillEllipse(brush, x, y, w, h);
            }
            font.Dispose();
            brush.Dispose();
            graphics.Dispose();

            System.IO.MemoryStream imageStream = new System.IO.MemoryStream();
            bmp.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);

            byte[] imageContent = new Byte[imageStream.Length];
            imageStream.Position = 0;
            imageStream.Read(imageContent, 0, (int)imageStream.Length);
            return imageContent;
        }
开发者ID:CWMalherbe,项目名称:EA,代码行数:54,代码来源:ImageController.cs


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