troubleshooting Question

Drawing Pixel by Pixel fastest way without using a bitmap

Avatar of gags03
gags03 asked on
Programming Languages-Other
3 Comments3 Solutions2311 ViewsLast Modified:
I just need to draw one pixel at the time for a very big array of values, each value correspond to a specific color…

Because the array is big, I do not want to use a bitmap to represent it, I want to directly draw each value on the screen …

Note:
If I used a bitmap with the lock functionality it will go very fast, but it will take lot of memory too…

If somebody could find me a SetPixel function who going very fast to draw a pixel on the screen I will be very happy…

Thanks…


This is a sample of code I want to do (in C#):
The solution could be in VB.net, C++ or anything else (I just need to be able to used c# to call the fonction)

public static void DrawValues(Graphics g, ColorPalette palette, double min, double max, float[,] values, PointF loc)
{
      double deltaFreqForOnePix = (max - min) / 255;
      for (int x = 0; x < values.GetLength(0); x++)
      {
            int pixIndex;
            for (int y = 0; y < values.GetLength(1); y++)
            {
                  if (values[x, y] > max)
                        pixIndex = 255;
                  else if (values[x, y] < min)
                        pixIndex = 0;
                  else
                  {
                        pixIndex = Convert.ToInt32(Math.Round((values[x, y] - min) / deltaFreqForOnePix, 0));
                  }
                  if (pixIndex < 0)
                        pixIndex = 0;
                  else if (pixIndex > 255)
                        pixIndex = 255;

// This is very slow: I try all function… this is just an example of what I want to do
g.FillRectangle(new SolidBrush(palette.Entries[pixIndex]), loc.X + x, loc.Y + y, 1, 1);

            }
      }
}
ASKER CERTIFIED SOLUTION
AlexFM

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros