panel picture

romantic_boy

New member
Joined
Jul 6, 2005
Messages
1
I need to convert the picture on the panel to bytes.
I did that but it works only for the backgroungimage of a panel.
in my program I use 3ds max to draw on the panel
I need to convert the picture on the panel to bytes
this is the function I use to get the bytes of the backgroungimage of the panel

private void fun()
{
pna1.BackgroundImage.Save("m"); //m is the name of the file
bm = new Bitmap("m");

//the size of the panel is 240*160
byte [,] matrix= new byte [240,160];

byte red=0, green=0, blue=0;
byte [] test=new byte [1];
for (int y=0; y < 160; y++)
{
for (int x =0; x < 240; x++)
{
Color u=bm.GetPixel (x ,y);
//I need only one byte represent each pixel
blue = (byte)(u.B/64*64);
green = (byte)(u.G/32*8);
red =(byte)(u.R/32);
matrix[x,y]=(byte)(red + green + blue);
}
}
}
 
First of all, if you draw to a control using some GDI or GDI+ function, you cannot examine the pixels. You can only get the pixel information if you draw to a bitmap object.

How to draw to a bitmap:
Code:
Bitmap bmp, Graphics gfx;

bmp = new Bitmap(40, 40);  //40 by 40 bitmap.
gfx = Graphics.FromImage(bmp); //This is the key line.

gfx.DrawLine(Pens.Red, 0, 0, 32, 32);
 
Last edited by a moderator:
Back
Top