Click here to Skip to main content
15,906,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<Image x:Name="ListImage" Height="500" Width="400" />

I have capture image using web came and also crop image using silver light and store image into image control so please how can i get byte from this image control because i have add this image to database so i have need byte from this image so if any idea so let me know.
Posted

1 solution

 
Share this answer
 
Comments
Ashish Rathod 7-Jan-13 8:00am    
public Byte[] BufferFromImage(BitmapImage imageSource)
{
Stream stream = imageSource.StreamSource;
Byte[] buffer = null;
if (stream != null && stream.Length > 0)
{
using (BinaryReader br = new BinaryReader(stream))
{
buffer = br.ReadBytes((Int32)stream.Length);
}
}

return buffer;
}

How can i find image source from image control because i have not save image in file directory
Naz_Firdouse 7-Jan-13 8:23am    
whn u r capturing the image from webcam , r u assigning the result to imagebrush...
Naz_Firdouse 7-Jan-13 8:24am    
did u tried this...
private byte[] ConvertImageToByteArray(Image imageToConvert, ImageFormat formatOfImage)
{
byte[] Ret = new byte[1000];
try
{
using (MemoryStream ms = new MemoryStream())
{
imageToConvert.Save(ms, formatOfImage);
Ret = ms.ToArray();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return Ret;
}

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