I have grayscale image and i want to see its byte[] is there anyway to do this ?
Here i get grayscaleimage ;
private void OnImage(NGrayscaleImage nImage)
{
}
And i want to send it to this function ;
private void SendBiometricInfo(byte[] imageBuffer, int imageWidth, int imageHeight)
{
}
Is there anyway to do this ? If so could you help me to handle this issue ?
Here is what i tried ...
private void OnImage(NGrayscaleImage nImage)
{
OnImageByte(ImageToByte(nImage), nImage.Width, nImage.Height);
//However here it says there is an invalid arguments.
}
public static byte[] ImageToByte(Image img)
{
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(img, typeof(byte[]));
}
void OnImageByte(byte[] imgBuffer, int width, int height)
{
}
If you can save your image as JPG, is presumible that your NGrayscaleImage
inherits from Image , so you could try to save it into a memory stream
public byte[] imageToByteArray(System.Drawing.Image image)
{
using (MemoryStream ms = new MemoryStream())
{
image.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
return ms.ToArray();
}
}
Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.