So, I have the following script to convert images into binaries (so I can put it on a blob):
public static byte[] ImagemBin(string imagePath, int imagem_comp)
{
FileStream fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
byte[] buffer = new byte[imagem_comp];
int numBytesToRead = imagem_comp;
int numBytesRead = 0;
while (numBytesToRead > 0)
{
// Read may return anything from 0 to numBytesToRead.
int n = fileStream.Read(buffer, numBytesRead, numBytesToRead);
// Break when the end of the file is reached.
if (n == 0)
break;
numBytesRead += n;
numBytesToRead -= n;
}
numBytesToRead = buffer.Length;
fileStream.Read(buffer, 0, numBytesToRead);
fileStream.Close();
return buffer;
}
Where imagePath is the location of the image in the computer, and imagem_comp is the size of the image. However, the image convertion is incomplete, and after a few bytes, it returns uniquely 0's...
So, any help on this?
Thank you in advance.