jeevan mummadi

jeevan mummadi

  • NA
  • 157
  • 0

convert image to bitmap image

Jun 12 2009 5:05 AM

i want to convert image to bitmapimage .
i pass imagesource parameter to below method
imagesource="example.jpg";
but at imagesource.streamsource i getting null value
plz tell me how to convert image to bitmap image

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;

Answers (3)