-1

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. Currently 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!!!)

Grunt
  • 173
  • 2
  • 2
  • 11

2 Answers2

2
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

Emond
  • 50,210
  • 11
  • 84
  • 115
0

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.

abalakin
  • 825
  • 7
  • 6