3
Answers

convert image to bitmap image

jeevan mummadi

jeevan mummadi

15y
26.5k
1

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)