Giter Site home page Giter Site logo

differentrain / dxdrawpad Goto Github PK

View Code? Open in Web Editor NEW

This project forked from m5home/dxdrawpad

0.0 0.0 0.0 850 KB

基于GDI的Graphics交互,使用DX(基于SharpDX)绘图的绘图控件,简单的图元管理方式与使用方式,比GDI更好的性能.

Home Page: http://www.m5home.com

License: MIT License

C# 100.00%

dxdrawpad's Introduction

基于GDI的Graphics交互,使用DX(基于SharpDX)绘图的绘图控件,简单的图元管理方式与使用方式,比GDI更好的性能.

因为工作中需要一个绘图框架,但找了不少库都不是很容易使用,要么接口复杂,要么使用麻烦,所以自己撸一个吧,毕竟我也勉强算个程序员?

这个控件的使用接口如下:

image

控件的工作思路很简单:

就是有一堆逻辑上的[子画布],用户在这些画布上绘图,贴图片什么的(使用的是Graphics对象),然后交由控件使用Direct2D来依顺序(添加子画布,调用AddDrawObject的顺序)绘制到控件中.

由于使用GDI的Graphics对象来交互,所以使用上很方便,没什么不一样.

绘制的内容,再由DX来绘制,这样效率就非常高.

由于是依顺序绘制的,所以也就有层的概念了,先添加的子画布先绘制,即在Z顺序的底层.

中间有一层从GDI的Bitmap转换为SharpDX的Bitmap过程(ConvertGdiBitmap函数),实现流程比较绕:

先用System.Drawing.Image把内容写入到Stream,再用SharpDX的BitmapDecoder从Stream中读回来,并最终转化为SharpDX.Direct2D1.Bitmap.

这应该是最低性能的一环了.

代码中的工程显示了一个大底图,并使用按钮绘制一个实心圆及线圈,以及几个GIF图象显示,有固定的也有跟随鼠标的.

别的就没啥了:)

dxdrawpad's People

Contributors

m5home avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.