Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.40/5 (4 votes)
See more:
hi every body
I want to convert a table double [,] into Bitmap 8bpp in order to put it in picturebox and save it

thanks
Posted
Comments
DinoRondelly 12-Apr-13 14:51pm    
Try google ...
Sergey Alexandrovich Kryukov 5-May-13 20:08pm    
Don't use PictureBox, it is totally unrelated, not needed for saving.
—SA

1 solution

You could find an answer with some searching on Google. However, try reading this[^] to get some ideas.

[Edit added some more details]
Here is some code to create the bitmap
C#
//Create the new bitmap
int w = 20;//use the desired height/width
int h = 20;
Bitmap newBmp = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);

//Build a grayscale color Palette
ColorPalette grayscalePalette = newBmp.Palette;
for (int i = 0; i < 256; i++)
{
    Color tmp = Color.FromArgb(255, i, i, i);
    grayscalePalette.Entries[i] = Color.FromArgb(255, i, i, i);
}
newBmp.Palette = grayscalePalette;

//now add the data as the link above shows

By the way, a data range of 0-255 is 8 bits per pixel.
 
Share this answer
 
v3
Comments
Hadjer91 12-Apr-13 16:15pm    
no,this is can not work with image of 8bpp
BillW33 12-Apr-13 17:27pm    
I added some more details to my solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900