以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  狐表实现Base64编码转图片,如何实现图片转Base64编码呢?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=40118)

--  作者:打错潇洒
--  发布时间:2013/9/10 8:07:00
--  狐表实现Base64编码转图片,如何实现图片转Base64编码呢?
以下内容为程序代码:

1
2 Dim str As String = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAB2AFoDASIA AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3 ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA AwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx BhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3 uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMB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dd wsaBQNvQV5jtfQpSaEkJX5X2qeeCfbj9a8V+KjCTX4sbcpHzj6//AFq9vvCuMOcIOTXhnxD/AHvi KQ5ZsgdeoxmtKXxhDc4GfJG4dTn+dQ24M15DEPvOwUfyrQljOwY6AZNV9OQJq8JwCVdevTNd/MnF jauz6M0ETw2MUO0bBgdc8Y65rYHmjJYMRzjI4qhomH0yF/MjO7GADxnjIrVYtypl+XO0sW6+1eYK UrlB0kmQrcKSgII7YPOK8I8eIV11ISzHaxBB7HNfQMuERv3qDbwRkcGvCvH1sq+LnCurnaCSDkA1 tQdp3BybOKlG2z/3XI/Slt281UJ4IbtUt+mIHK9Mlqi005k29t6/4V26ctyT6A8HErplqQD80Sk5 GO3FdoFBAri/DLNHDbw42hI1GPXiu1H3R9K8tO+o2rMrasxWDIxkV4j4zm+0eI7gjdgIoG7r8wFF Fa0viLhsctMgMmAON2PyrOgQD97j5i+7NFFdkdg+0fSfhrE/h21lVFVyvJA6gVquFVidq4GSBtGO Bnn35oorzyZbj9iEsQg28hc9iK8I8XOZvE8rnA6D9KKK0pfEScTfL+6jHbj+tJpHzzBfVs/rRRXo S/hsZ754ZB8pGZizMckmuyX7o+lFFeWI/9k="
3 Dim bs As Byte() = Convert.FromBase64String(str)
4 Dim stream As System.IO.Stream = New System.IO.MemoryStream(bs)
5 Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(stream)
6 bmp.Save("E:\\\\temp.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
7


如何实现图片转Base64编码呢?



--  作者:Bin
--  发布时间:2013/9/10 8:52:00
--  
Dim ms As New System.IO.MemoryStream
getImage("D:\\\\temp.jpg").Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim BPicture As Byte() = New Byte(ms.Length - 1) {}
BPicture = ms.GetBuffer()

MessageBox.show(Convert.ToBase64String(BPicture))