zoukankan      html  css  js  c++  java
  • GDI+技术

    GDI+GDI的后继者,它是一种构成 Windows XP 操作系统的子系统的应用程序编程接口。

     

    一般来说有3种基本类型的绘图界面,分别为Windows 窗体上的控件、要发送给打印机的页面和内存中的位图、图像,而Graphics类封装了一个GDI+绘图界面,因此该类提供了可以在3中绘图界面上绘图的功能。

     

     

    绘制直线

    private void button1_Click(object sender, EventArgs e)

            {

                Graphics graphics = this.CreateGraphics();

                Pen pen = new Pen(Color .Blue ,2);

                graphics.DrawLine(pen ,50,30,170,30);

            }

     

     

    绘制矩形

    private void button1_Click(object sender, EventArgs e)

            {

                Graphics graphics = this.CreateGraphics ();

                Pen pen = new Pen(Color .Red ,3);

                graphics.DrawRectangle(pen,70,20,80,50);//(x,y)指的是要绘制矩形的左上角的xy坐标

            }

     

    绘制椭圆

    private void button1_Click(object sender, EventArgs e)

            {

                Graphics graphics = this.CreateGraphics();

                Pen pen = new Pen(Color.Red, 3);

                Rectangle myRec = new Rectangle ( 70, 20, 80, 50);//(x,y)指的是要绘制矩形的左上角的xy坐标

                graphics.DrawEllipse(pen ,myRec);

     

            }

     

     

    绘制图形路径

    路径是通过组合直线、矩形、简单的曲线而形成的。在GDI+中,GraphicsPath对象允许将基本构造块收集到一个单元中,调用一次Graphics类的DrawPath方法,就可以绘制出整个单元的直线、矩形、多边形和曲线。

     

    private void button1_Click(object sender, EventArgs e)

            {

                Graphics graphics = this.CreateGraphics();

                System.Drawing.Drawing2D.GraphicsPath myGraphicPath = new System.Drawing.Drawing2D.GraphicsPath();

                Pen myPen = new Pen(Color .Red ,2);

                Point[] myPoints = { new Point(15, 30), new Point(30, 40), new Point(50,30) };

                myGraphicPath.AddArc(15,20,80,50,210,120);

                myGraphicPath.StartFigure();//不闭合当前图形继续画下一个图形

                myGraphicPath.AddCurve(myPoints );

                myGraphicPath.AddString("图形路径",new FontFamily ("华文行楷"),(int )FontStyle .Underline ,50,new PointF(20,50),new StringFormat ());

                myGraphicPath.AddPie(180,20,80,50,210,120);

                graphics.DrawPath(myPen ,myGraphicPath );

            }

     

  • 相关阅读:
    chrome 开发者工具——前端实用功能总结
    而立之年——回顾我的前端转行之路
    编译原理实战入门:用 JavaScript 写一个简单的四则运算编译器(修订版)
    手把手带你入门前端工程化——超详细教程
    手把手教你搭建 Vue 服务端渲染项目
    前端项目自动化部署——超详细教程(Jenkins、Github Actions)
    前端国际化辅助工具——自动替换中文并翻译
    深入了解 webpack 模块加载原理
    实现一个 webpack loader 和 webpack plugin
    博客本地编辑器-OpenLiveWriter安装使用
  • 原文地址:https://www.cnblogs.com/sly-tongtong/p/3688165.html
Copyright © 2011-2022 走看看