How to convert ImageSource to Byte array?

后端 未结 6 597
眼角桃花
眼角桃花 2020-11-30 14:20

I use LeadTools for scanning.

I want to convert scanning image to byte.

void twainSession_AcquirePage(object sender, TwainAcquirePageEventArgs e)
 {
         


        
6条回答
  •  醉话见心
    2020-11-30 14:48

    I ran into this issue in Xamarin.Forms where I needed to convert a taken photo from the camera into a Byte array. After spending days trying to find out how, I saw this solution in the Xamarin forums.

    var photo = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions() { });
    
    byte[] imageArray = null;
    
    using (MemoryStream memory = new MemoryStream()) {
    
        Stream stream = photo.GetStream();
        stream.CopyTo(memory);
        imageArray = memory.ToArray();
    }
    


    Source: https://forums.xamarin.com/discussion/156236/how-to-get-the-bytes-from-the-imagesource-in-xamarin-forms

提交回复
热议问题