开发者

Easy way to plot X and Y in an array in C#

Hello I am making a double buffer in C# and I need to find out a formula to plot the X and Y coordinates in my array. Current开发者_JS百科ly I am using a loop to plot my X and Y but it takes along time to do it. (NOTE I CANNOT USE A MULTI DIMENSIONAL ARRAY!!!)


int[] buffer = new int[width * height];

void Plot(int x, int y, int color)
{
    buffer[y* width + x] = color;
}

EDIT

To plot longer blocks you could use the Array.Copy functions

If that is still too slow you could fallback to unsafe code to fill the array


May be MathGL (GPL plotting library) may satisfy yours needs. It have no direct C# interface (in fact, it can be built by SWIG but I never try it). But, as I know, the C-functions can be called from C# easily.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜