Hack Forums
[.NET] Image to Code and Code to Image - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Image to Code and Code to Image (/showthread.php?tid=5739820)



Image to Code and Code to Image - D3n1s1990 - Oct 18, 2017

PHP Code

<?php 
Convert an image into code
:
Dim ITC As New ImageToCodeClass
Dim Code 
as String =  ITC.ImageToCode(YourImage)

Convert the code into an image:
Dim ITC As New ImageToCodeClass
PictureBox1
.Image = ITC.CodeToImage("<YOUR IMAGE CODE HERE>")


Public Class 
ImageToCodeClass
    
Public Function ImageToCode(ByVal Img As Bitmap) As String
  
Return Convert.ToBase64String(DirectCast(System.ComponentModel.TypeDescriptor.GetConver?ter(Img).ConvertTo(Img, GetType(Byte())), Byte()))
    
End Function

    Public Function 
CodeToImage(ByVal Code As String) As Image
  
Return Image.FromStream(New System.IO.MemoryStream(Convert.FromBase64String(Code)))
    
End Function
End Class