romantic_boy Posted July 6, 2005 Posted July 6, 2005 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); } } } Quote
Leaders Iceplug Posted July 8, 2005 Leaders Posted July 8, 2005 (edited) 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: 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); Edited July 8, 2005 by Iceplug Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.