开发者

how i pass image in This function

public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
    Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFi开发者_StackOverflowleDialog();
    dlg.FileName = "Document"; // Default file name
    dlg.DefaultExt = ".txt"; // Default file extension
    dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension
    Nullable<bool> result = dlg.ShowDialog(); // Show open file dialog box

    // Process open file dialog box results
    if (result == true)
    {
        // Open document
        string filename = dlg.FileName;
        txtBrowse.Text = filename;
    }
    ImageSource imageSource = new BitmapImage(new Uri(txtBrowse.Text));
    imgImageAdlut.Source = imageSource; ;
    byte[] array1 = null;
    //array1 = imageToByteArray();
}

public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
    MemoryStream ms = new MemoryStream();
    imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
    return ms.ToArray();
}


Try this:

 var img  = new System.Drawing.Bitmap(@"D:\Your image path\your image.bmp");
 byte[] array1 =  imageToByteArray(img);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜