Vb.net将二进制转换为图像,参数错误 [英] Vb.net convert binary to image, parameter error

查看:139
本文介绍了Vb.net将二进制转换为图像,参数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i have database, and i have a column that stored picture in access database
in that column i right click it and insert object which is picture from file
and it said "package" in the column  

the idea is i upload picture to 'pic' column in access database from file, and using 'querypic' table adapter query with parameter is 'comboname.text' is selected to return picture and store it as binary in byte of array

but when i convert it to image i got an error 
"System.ArgumentException: 'Parameter is not valid."

i checked my b() which is array of byte and it got result {length=40276}
can someone help me?





我尝试过:





What I have tried:

<pre>Private Sub cmdSelect_Click(sender As Object, e As EventArgs) Handles cmdSelect.Click
            Dim facultytabeladapt As New CSE_DEPTDataSetTableAdapters.FacultyTableAdapter
            Dim b() As Byte
            Dim s As String
            b = facultytabeladapt.querypic(ComboName.Text)
    
            PhotoBox.Image = b21(b)
    
    
        End Sub
        Private Function b21(ByVal b() As Byte) As Image
    
            Dim imgc As New ImageConverter
    
            Dim imgpic As Image = CType(imgc.ConvertFrom(b), Image) 'it has error "System.ArgumentException: 'Parameter is not valid."
            Return imgpic
        End Function

推荐答案

如果在列中显示package,则将其存储为一个OLE包装器,而不是图像的原始字节。



从OLE包装器中提取图像有点复杂:

将访问映像OLE对象转换为C#中的原始图像字节数组 - 堆栈溢出 [ ^ ]



将列类型更改为更容易 BLOB ,并从代码中插入原始图像字节。
If it says "package" in the column, then it's stored as an OLE wrapper, rather than the raw bytes of the image.

Extracting images from OLE wrappers is somewhat complicated:
Convert Access image OLE Object into raw image byte array in C# - Stack Overflow[^]

It would probably be easier to change the column type to BLOB, and insert the raw image bytes from code.


这篇关于Vb.net将二进制转换为图像,参数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆