I don't know how it works in VB but this is how I'd alter this in C#, which should be code that can be easily converted to VB!
private void PutImage(IntPtr pPtr, int imageBufferSize, AdvImageType imageType)
{
byte[] data = new byte[imageBufferSize];
Marshal.Copy(pPtr, data, 0, imageBufferSize);
using (MemoryStream imageStream = new MemoryStream(imageBufferSize))
{
using (BinaryWriter w = new BinaryWriter(imageStream))
{
for (int i = 0; i < imageBufferSize; i++)
w.Write(data[i]);
Bitmap lPicture = new Bitmap(
Image.FromStream(imageStream),
signatureImagePictureBox.Width,
signatureImagePictureBox.Height);
if (imageType == AdvImageType.AdvSignatureImage)
signatureImagePictureBox.Image = lPicture;
else
cardholderImagePictureBox.Image = lPicture;
Marshal.FreeCoTaskMem(pPtr);
}
}
}
I have changed the first parameter by removing the ref. There seems little point in passing a pointer to a pointer in this scenario. I have also used the Marshal class to create a managed array from the data instead as then there is no need to use unsafe code!
Untested of course, but it compiles and should be OK.
Edit: Removed the unsafe keyword as no longer needed :doh!