日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
詳細(xì)VB.NET代碼之圖像轉(zhuǎn)成HTML文件

VB.NET還是比較常用的,于是我研究了一下VB.NET,在這里拿出來和大家分享一下,希望對大家有用。在vb.net中寫出了相同實(shí)現(xiàn)功能的VB.NET代碼
功能實(shí)現(xiàn)主要是應(yīng)用到system.drawing.bitmap,和其方法getpixel()

主要VB.NET代碼 如下:

 
 
 
  1. Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim bit As System.Drawing.Bitmap
  3. bitbit = bit.FromFile("c:\aowindme.bmp") '讀取一個(gè)圖像文件
  4. Dim w, h As Integer
  5. w = bit.Width - 1 '取得圖像每行的像素量
  6. h = bit.Height - 1 '取得圖像的行數(shù)
  7. Dim pixel As System.Drawing.Color(,) '定義一個(gè)類型為系統(tǒng)色彩型的二維數(shù)組,來存放圖片的所有像系的色彩信息
  8. pixel = New System.Drawing.Color(w, h) {} '根據(jù)圖像的像系每行數(shù)量和行量來重新定義數(shù)組下標(biāo)
  9. Dim i, j
  10. '利用循環(huán)把圖像所有像素的色彩信息對應(yīng)存入數(shù)組
  11. For i = 0 To h
  12. For j = 0 To w
  13. pixel(j, i) = bit.GetPixel(j, i)
  14. Next
  15. Next
  16. Dim content As String '定義一個(gè)字符串來存放要寫入html的內(nèi)容
  17. content = toweb(w, h, pixel) '生成寫入html的內(nèi)容
  18. Dim y As Boolean '定義一個(gè)邏輯變量來判斷是否寫入成功
  19. y = SaveTextFile("c:\999.htm", content) '寫入html文件
  20. If y Then MsgBox("ok!")
  21. End Sub
  22. '得到一個(gè)RGB信息的相應(yīng)WEB代碼
  23. Private Function GetWEBColorinfo()Function GetWEBColorinfo(ByVal x As Color) As String
  24. Dim r, g, b As String
  25. r = Hex(CInt(x.R)) '取得一個(gè)像素色彩信息中的R信息,轉(zhuǎn)成16進(jìn)制后存成字符串型
  26. g = Hex(CInt(x.G)) '取得一個(gè)像素色彩信息中的R信息,轉(zhuǎn)成16進(jìn)制后存成字符串型
  27. b = Hex(CInt(x.B)) '取得一個(gè)像素色彩信息中的R信息,轉(zhuǎn)成16進(jìn)制后存成字符串型
  28. '如果不足兩位的在前面加0,因?yàn)閃EB色彩表示應(yīng)為#+R(兩位16進(jìn)制)+G(兩位16進(jìn)制)+B(兩位16進(jìn)制)
  29. If r.Length = 1 Then r = "0" & r
  30. If g.Length = 1 Then g = "0" & g
  31. If b.Length = 1 Then b = "0" & b
  32. Return "#" & r & g & b
  33. End Function
  34. '生成要寫處html文件的字符串,即html文件的內(nèi)容
  35. Private Function toweb()Function toweb(ByVal w As Integer, ByVal h As Integer, ByVal pixel As Color(,)) As String
  36. Dim html As String
  37. html = "傲風(fēng)圖像網(wǎng)頁生成
    " & vbCrLf
  38. Dim i, j
  39. For i = 0 To h
  40. For j = 0 To w
  41. htmlhtml = html & " color='" & GetWEBColorinfo(pixel(j, i)) & "'>" & Int(Rnd(10) * 10) & Int(Rnd(10) * 10) & ""
  42. Next
  43. htmlhtml = html & "
    " & vbCrLf
  44. Next
  45. htmlhtml = html & ""
  46. Return html
  47. End Function
  48. '寫入文件函數(shù)
  49. Private Function SaveTextFile()Function SaveTextFile(ByVal FilePath As String, ByVal FileContent As String) As Boolean
  50. Dim sw As System.IO.StreamWriter
  51. Try
  52. sw = New System.IO.StreamWriter(FilePath, False)
  53. sw.Write(FileContent)
  54. Return True
  55. Catch e As Exception
  56. Return False
  57. Finally
  58. If Not sw Is Nothing Then sw.Close()
  59. End Try
  60. End Function

以上就是將圖像轉(zhuǎn)成HTML文件,VB.NET代碼。


本文題目:詳細(xì)VB.NET代碼之圖像轉(zhuǎn)成HTML文件
URL分享:http://m.5511xx.com/article/dhpiode.html