第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

字節(jié)數(shù)組到圖像轉(zhuǎn)換

字節(jié)數(shù)組到圖像轉(zhuǎn)換

C#
胡子哥哥 2019-07-27 10:35:34
字節(jié)數(shù)組到圖像轉(zhuǎn)換我想將字節(jié)數(shù)組轉(zhuǎn)換為圖像。這是我獲取字節(jié)數(shù)組的數(shù)據(jù)庫(kù)代碼:public void Get_Finger_print(){     try     {         using (SqlConnection thisConnection = new SqlConnection(@"Data Source=" + System.Environment.MachineName + "\\SQLEXPRESS;Initial Catalog=Image_Scanning;Integrated Security=SSPI "))         {             thisConnection.Open();             string query = "select pic from Image_tbl";// where Name='" + name + "'";             SqlCommand cmd = new SqlCommand(query, thisConnection);             byte[] image =(byte[]) cmd.ExecuteScalar();             Image newImage = byteArrayToImage(image);             Picture.Image = newImage;             //return image;         }     }     catch (Exception) { }     //return null;}我的轉(zhuǎn)換代碼:public Image byteArrayToImage(byte[] byteArrayIn){     try     {         MemoryStream ms = new MemoryStream(byteArrayIn,0,byteArrayIn.Length);         ms.Write(byteArrayIn, 0, byteArrayIn.Length);         returnImage = Image.FromStream(ms,true);//Exception occurs here     }     catch { }     return returnImage;}當(dāng)我通過(guò)注釋到達(dá)該行時(shí),會(huì)發(fā)生以下異常: Parameter is not valid.如何解決導(dǎo)致此異常的問(wèn)題?
查看完整描述

3 回答

?
料青山看我應(yīng)如是

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊

也許我錯(cuò)過(guò)了一些東西,但對(duì)我來(lái)說(shuō),這個(gè)單行程序可以正常工作,其中包含一個(gè)包含JPEG文件圖像的字節(jié)數(shù)組。

Image x = (Bitmap)((new ImageConverter()).ConvertFrom(jpegByteArray));

編輯:

請(qǐng)參閱此處獲取此答案的更新版本:如何在字節(jié)數(shù)組中轉(zhuǎn)換圖像


查看完整回答
反對(duì) 回復(fù) 2019-07-27
?
明月笑刀無(wú)情

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超4個(gè)贊

public Image byteArrayToImage(byte[] bytesArr)
    {
        using (MemoryStream memstr = new MemoryStream(bytesArr))
        {
            Image img = Image.FromStream(memstr);
            return img;
        }
    }


查看完整回答
反對(duì) 回復(fù) 2019-07-27
  • 3 回答
  • 0 關(guān)注
  • 434 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)