lidds Posted October 9, 2006 Posted October 9, 2006 I have managed to put together some code (with help from other coders) that will capture my desktop into a bitmap variable, however now I need to convert this into a byte variable so that I can then insert into my image field within SQL server db. Is anyone able to help me, I have search the net and I seem to find loads of example where you are reading a image from a file, however I can find nothing to help me with this. Thanks in advance Simon Quote
*Experts* mutant Posted October 9, 2006 *Experts* Posted October 9, 2006 This article over at MSDN might help you: http://msdn2.microsoft.com/en-us/library/5ey6h79d.aspx Quote
Administrators PlausiblyDamp Posted October 10, 2006 Administrators Posted October 10, 2006 Something like System.Drawing.Bitmap bmp = (Bitmap) System.Drawing.Image.FromFile("c:\\windows\\winnt256.bmp"); System.IO.MemoryStream ms = new System.IO.MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); byte[] data = ms.GetBuffer(); might also work. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Leaders snarfblam Posted October 10, 2006 Leaders Posted October 10, 2006 I would recommend PlausiblyDamp's method because it stores the entire image file into the array, including the pixel format and dimensions. The first example only extracts raw pixel data to the array, which is not enough to reproduce the image later. Quote [sIGPIC]e[/sIGPIC]
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.