Advertisement
datatheoz

Eazy Pixel to Html

Feb 10th, 2020
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  Dim strImageFile As String = txtFile.Text
  2.         Dim b As Bitmap = New Bitmap(strImageFile)
  3.         Dim w As Integer = b.Width
  4.         Dim p As Color
  5.         Dim clr As String
  6.         Dim sb As New System.Text.StringBuilder
  7.  
  8.         For y As Integer = 0 To b.Height - 1
  9.             sb.Append("<tr><td height=""1px"" style=""width:" & w.ToString & "px;background:linear-gradient(to right,")
  10.  
  11.             For x = 0 To b.Width - 1
  12.                 p = b.GetPixel(x, y)
  13.                 clr = System.Drawing.ColorTranslator.ToHtml(p)
  14.                 sb.Append(clr & ",")
  15.             Next
  16.  
  17.             sb.Remove(sb.Length - 1, 1)
  18.             sb.Append(")""></td></tr>")
  19.         Next
  20.         Dim StrDiv As String = "<div style=""display:inline-block;vertical-align: Top;margin:5px;padding:2px;"">"
  21.  
  22.         Dim strResult As String = StrDiv & "<table cellpadding=""0"" cellspacing=""0"" width=""100"" Height=""100""><tbody>" & sb.ToString & "</tbody></table></div>"
  23.         txtData1.Text = strResult
  24.  
  25.         If txtData1.Text.Contains("#") Then
  26.             Status.Text = "Success!"
  27.         End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement