Sindibad_123
asked on
to convert raw byte array(its not actual image) to Bitmap image?
Hi, I need to convert raw byte array(its not actual image) to image?
Regards.
Regards.
please shed more light on "its not actual image" if the above does nto work.
ASKER
I mean, it is just a buffer of raw pixel data, and not a complete image file so MemoryStream will not work.
ASKER
I think the asker of this question: http://social.msdn.microsoft.com/Forums/en-SG/clr/thread/220095e4-0150-4c23-a613-7276494290 did it but he did not put the all code, do someone have a such code?
link seems to be invalid
also sounds like you just talking about a bitmap
MemoryStream ms = new MemoryStream(BitmapData);
return (new Bitmap(ms));
ASKER
ASKER
CodeCruiser I tried the function that suggested in that link:
public Bitmap CopyDataToBitmap(byte[] data)
{
Bitmap bmp = new Bitmap( 900, 600, PixelFormat.Format16bppRgb 565);
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat);
Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
//set the beginning of pixel data
bmp.UnlockBits(bmpData);
return bmp;
}
but the image got displayed as a black image, any suggestion?
public Bitmap CopyDataToBitmap(byte[] data)
{
Bitmap bmp = new Bitmap( 900, 600, PixelFormat.Format16bppRgb
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat);
Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
//set the beginning of pixel data
bmp.UnlockBits(bmpData);
return bmp;
}
but the image got displayed as a black image, any suggestion?
Make sure you are using the correct format and depth.
ASKER
How can I know what's the correct format & depth?
Where is the raw data coming from? You need to confirm from the source.
ASKER
Actually the data is a web page request that come as stream.
A web page request? Not sure I understand.
ASKER
Something like this:
HttpWebRequest httpWebRequest = (System.Net.HttpWebRequest )System.Ne t.HttpWebR equest.Cre ate(url);
System.Net.HttpWebResponse httpWebResponse = (System.Net.HttpWebRespons e)httpWebR equest.Get Response() ;
System.IO.Stream stream = httpWebResponse.GetRespons eStream();
byte[] imageData = ConverToByteArray(stream, 32768);
I want to take a screenshot without using thirdparty app.
HttpWebRequest httpWebRequest = (System.Net.HttpWebRequest
System.Net.HttpWebResponse
System.IO.Stream stream = httpWebResponse.GetRespons
byte[] imageData = ConverToByteArray(stream, 32768);
I want to take a screenshot without using thirdparty app.
Ah. So you want to convert HTML to pixels? :-)
ASKER
We do not want to use WebBrowser control.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window