偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

詳細(xì)VB.NET代碼之圖像轉(zhuǎn)成HTML文件

開發(fā) 后端
這里就圖像轉(zhuǎn)成HTML文件案例做出詳細(xì)VB.NET代碼,想知道是怎么實(shí)現(xiàn)的嗎?文章有詳細(xì)的代碼和解釋,看了一定會給你啟發(fā)的。

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") '讀取一個圖像文件  
  4. Dim w, h As Integer  
  5. w = bit.Width - 1 '取得圖像每行的像素量  
  6. h = bit.Height - 1 '取得圖像的行數(shù)  
  7. Dim pixel As System.Drawing.Color(,) '定義一個類型為系統(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 '定義一個字符串來存放要寫入html的內(nèi)容  
  17. content = toweb(w, h, pixel) '生成寫入html的內(nèi)容  
  18. Dim y As Boolean '定義一個邏輯變量來判斷是否寫入成功  
  19. y = SaveTextFile("c:\999.htm", content) '寫入html文件  
  20. If y Then MsgBox("ok!")  
  21. End Sub  
  22. '得到一個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)) '取得一個像素色彩信息中的R信息,轉(zhuǎn)成16進(jìn)制后存成字符串型  
  26. g = Hex(CInt(x.G)) '取得一個像素色彩信息中的R信息,轉(zhuǎn)成16進(jìn)制后存成字符串型  
  27. b = Hex(CInt(x.B)) '取得一個像素色彩信息中的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 = "<html><head><title>傲風(fēng)圖像網(wǎng)頁生成</title></head><body bgcolor='#000000'><center>" & vbCrLf  
  38. Dim i, j  
  39. For i = 0 To h  
  40. For j = 0 To w  
  41. htmlhtml = html & "<font color='" & GetWEBColorinfo(pixel(j, i)) & "'>" & Int(Rnd(10) * 10) & Int(Rnd(10) * 10) & "</font>"  
  42. Next  
  43. htmlhtml = html & "<br>" & vbCrLf  
  44. Next  
  45. htmlhtml = html & "</center></body></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代碼。

【編輯推薦】

  1. VB.NET編寫托盤程序經(jīng)驗(yàn)雜談
  2. 手把手指導(dǎo)VB.NET Socket編程
  3. 快速了解VB.NET可選參數(shù)
  4. 詳細(xì)介紹VB.NET MyClass
  5. 自己動手用代碼實(shí)現(xiàn)VB.NET ListView加載數(shù)據(jù)
責(zé)任編輯:田樹 來源: 樂博網(wǎng)
相關(guān)推薦

2009-10-28 09:55:29

VB.NET MyCl

2009-10-12 15:41:09

VB.NET動態(tài)代碼

2010-01-20 13:42:10

VB.NET訪問INIGetPrivateP

2009-10-12 13:54:22

VB.NET Data

2009-10-13 17:03:55

VB.NET面向?qū)ο?/a>

2009-11-02 15:45:03

VB.NET IEnu

2009-10-12 15:02:51

VB.NET動態(tài)控件

2010-01-21 16:45:00

VB.NET繼承規(guī)則

2010-01-07 15:18:10

VB.NET常量

2009-10-10 16:44:52

VB.NET開發(fā)控件

2009-11-10 12:42:47

VB.NET Prin

2010-01-12 11:37:34

VB.NET讀取圖像

2010-01-22 14:19:38

VB.NET調(diào)用jar

2009-10-13 17:16:40

VB.NET Web服

2009-10-15 15:04:42

VB.NET PadL

2009-10-12 12:54:58

VB.NET聲明API

2010-01-11 11:37:08

VB.NET操作CSV

2009-11-02 09:45:23

VB.NET文件系統(tǒng)對

2009-10-12 16:56:36

VB.NET常量VB.NET枚舉

2009-09-07 15:04:07

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號