Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

ambil gambar di database mysql dengan menggunakan vb

Kesalahannya adalah dalam mengambil gambar Anda. Anda perlu mengonversi gambar terlebih dahulu ke array byte. sebelum Anda menampilkannya ke kotak gambar..

 Public Function ResizeImageWithAspect(ByVal picImage As Image, ByVal newWidth As Integer) As Bitmap
    Dim original As Image = picImage
    If Not original Is Nothing Then
        //Find the aspect ratio between the height and width.
        Dim aspect As Single = CSng(original.Height) / CSng(original.Width)

        //Calculate the new height using the aspect ratio
        // and the desired new width.
        Dim newHeight As Integer = CInt((newWidth * aspect))

        //Create a bitmap of the correct size.
        Dim temp As New Bitmap(newWidth, newHeight, original.PixelFormat)

        //Get a Graphics object from the bitmap.
        Dim newImage As Graphics = Graphics.FromImage(temp)

        //Draw the image with the new width/height
        newImage.DrawImage(original, 0, 0, newWidth, newHeight)

        //Dispose of our objects.
        Return temp
        original.Dispose()
        temp.Dispose()
        newImage.Dispose()
    Else
        Return Nothing
    End If

End Function

Public Function ByteToImage(ByVal blob() As Byte) As Bitmap
    Dim mStream As New System.IO.MemoryStream
    Dim pData() As Byte = DirectCast(blob, Byte())
    mStream.Write(pData, 0, Convert.ToInt32(pData.Length))
    Dim bm As Bitmap = New Bitmap(mStream, False)
    mStream.Dispose()
    Return bm
End Function

Public Function FileImageToByte(ByVal filePath As String) As Byte()
    Dim fs As FileStream = New FileStream(filePath, FileMode.Open, FileAccess.Read)
    Dim br As BinaryReader = New BinaryReader(fs)
    Dim bm() As Byte = br.ReadBytes(fs.Length)
    br.Close()
    fs.Close()
    Dim photo() As Byte = bm
    Return photo
End Function

Untuk info lebih lanjut lihat tautan ini



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. MySQL:Ringkas semua jumlah baris tabel dalam satu kueri

  2. mysql melempar kolom 'mac' yang tidak dikenal di 'daftar bidang'

  3. perbarui beberapa baris menggunakan batas di mysql?

  4. Dimana saya bisa mendapatkan aplikasi chat room PHP/MYSQL

  5. Bagaimana cara mengambil item berikutnya dalam daftar catatan MySQL?