Home>

There is an array of bytes describing a b-w image (qr-code):

Byte [] byteCodes

How can I send an image from a given bytecode to a telegram bot?

I found examples of how you can send an image from a directory using a link, but this does not suit me in the form of a bytecode.

Tried converting bytecode to Image object like this:

public static Image byteArrayToImage (byte [] byteArrayIn)
    {
        using (var ms= new MemoryStream (byteArrayIn))
        {
            return Image.FromStream (ms);
        }
    }

And then pass it through:

await _telegramBotClient.SendPhotoAsync (message.Chat.Id, QRcodeServices.byteArrayToImage (byteCodes));

But it gives me an error that the SendPhotoAsync method takes a different parameter -InputOnLineFile

@AlAvenger, tried this, but the image transfer method writes that it expects another parameter -described in the question

Vlad-i-mir2021-10-16 00:51:11

@AlAvenger, Bitmap doesn't want to either

Vlad-i-mir2021-10-16 00:51:11