zoukankan      html  css  js  c++  java
  • 绘制二维图片

    public partial class MainForm : Form
    {
       public MainForm()
       {
           InitializeComponent();
     
           this.InitialDX();
       }
     
       private Device device;
       private Texture texture;
     
       private void InitialDX()
       {
           PresentParameters presentParams = new PresentParameters();
           presentParams.Windowed = true;
           presentParams.SwapEffect = SwapEffect.Discard;
     
           device = new Device(
               0,
               DeviceType.Hardware,
               this,
               CreateFlags.SoftwareVertexProcessing,
               presentParams);
     
           device.RenderState.Lighting = false;
     
           texture = Texture.FromBitmap(
               device,
               (Bitmap)Image.FromFile("w.png"),
               Usage.None,
               Pool.Managed);
       }
     
       protected override void OnPaint(PaintEventArgs e)
       {
           base.OnPaint(e);
     
           this.DrawDX();
       }
     
       private void DrawDX()
       {
           device.Clear(ClearFlags.Target, Color.AliceBlue, 1f, 0);
           device.BeginScene();
           this.DrawMyGraphics();
           device.EndScene();
           device.Present();
       }
     
       private void DrawMyGraphics()
       {
           Sprite sprite = new Sprite(device);
           sprite.Begin(SpriteFlags.AlphaBlend);
           sprite.Draw2D(texture,
               Point.Empty,
               0f,
               new Point(10, 10),
               Color.White);
           sprite.End();
       }
    }

    效果:

    image

  • 相关阅读:
    大数据技术
    大数据技术
    大数据技术
    设计模式之代理模式
    大数据技术
    大数据技术
    大数据技术
    Intellij IDEA 解决 Maven 依赖下载慢的问题
    大数据技术
    QUdpSocket Class
  • 原文地址:https://www.cnblogs.com/sharpfeng/p/1954018.html
Copyright © 2011-2022 走看看