Click here to Skip to main content
15,897,371 members

Comments by gaurav786mishra (Top 10 by date)

gaurav786mishra 5-Sep-13 10:30am View    
Hi ,Vamshi(Krish)
The above code gives error :Buffer size is not sufficient.

public static BitmapImage ByteToImage(byte[] imageData)
{

byte[] buffer = imageData;

var width = 100; // for example
var height = 100; // for example
var dpiX = 96d;
var dpiY = 96d;
var pixelFormat = PixelFormats.Pbgra32; // for example
var bytesPerPixel = (pixelFormat.BitsPerPixel + 7) * 8;
var stride = bytesPerPixel * width;

var bitmap = BitmapSource.Create(width, height, dpiX, dpiY,
pixelFormat, null, buffer, stride);
return (BitmapImage)bitmap;
}
gaurav786mishra 5-Sep-13 4:22am View    
Ok Thank you for ur reply.Actually rawdata is a byte array which contains the bytes in array format coming from database.I am getting the rawdata array filled with numbers on each index of array.
I guess the problem is i am converting path to byte array and saving in database..If that i am doing..then how can i extract image from image path as wpf has no file upload control?
gaurav786mishra 5-Sep-13 3:06am View    
From the open file dialog box image is selected and that path is kept in txtBrowseFile.Text further from text box it is used in :
private void fillbitmap()
{
#region load image with StreamSrouce
bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = System.IO.File.OpenRead(txtBrowseFile.Text);
bitmapImage.EndInit();
//now, the Position of the StreamSource is not in the begin of the stream.

image1.Source = bitmapImage;

#endregion
}
The bitmap generated from here is then used in passed to :

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;
}

which returns a byte array and then that byte array is stored in database.
gaurav786mishra 4-Jun-13 8:20am View    
Thanks PrissySC for the reply.Did u get the SDK made for WPF application or got sdk for windows application and u are making it work for wpf.
Actualy i need to make all the biometric integration like fingerprint,iris,facial ,signature ,and voice in wpf application.BUt only fingerprint for a browser application ,and i got its sdk of windows form...should i ask client for wpf sdk..or wpf (xbab) sdk or silverlight (sdk)?Or else i need to use only the sdk provided to me..(i.e. windows)and struggle with it to convert in wpf or silverlight
gaurav786mishra 20-May-13 3:52am View    
But its working fine in windows and wpf application.So they says that its working fine.i need to make it work in silverlight