Connecting Tech Pros Worldwide Forums | Help | Site Map

write 2d array in bitmap in c#

Newbie
 
Join Date: Oct 2008
Posts: 2
#1: Oct 2 '08
hey guys!

i am new in csharp. i want to write the content of a 2d float array in a bitmap( in greyscale). what is the easiest solution!

thanks for any response

sevi

Expert
 
Join Date: Sep 2008
Location: USA
Posts: 188
#2: Oct 3 '08

re: write 2d array in bitmap in c#


Could you clarify your objective, please.

Do you want to write a Bitmap whose hight and width correspond to the dimension bounds of the array, and whose each pixel corresponds to the value of the array element and is guaranteed to be in the range of GrayScale values?

There is a constructor of the System.Drawing.Bitmap class with accepts height, width and PixelFormat parameters.

The Bitmap class has a Bitmap.SetPixel(Color) method which can be used to set the value of each pixel.
Newbie
 
Join Date: Oct 2008
Posts: 2
#3: Oct 3 '08

re: write 2d array in bitmap in c#


Thank you, o got it somehow :


color = (int)(discdata[i ][j] / (max - min) * 255);
bmp.SetPixel(i,,j, Color.FromArgb(color, color, color));

where max and min are the extremas of the array.

thanks a lot
sevi
Reply


Similar .NET Framework bytes