如何將Base64字串資料轉回圖形

摘要:如何將Base64字串資料轉回圖形

這也是一個MemoryStream的應用之一,不囉嗦,我們直接來瞧瞧程式碼吧~

  1. Dim Str As String  
  2.   
  3. Str = _  
  4. "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8" & _  
  5. "YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAALEwAA" & _  
  6. "CxMBAJqcGAAAA3VJREFUOE+lU/9P1HUYf+7gjvt87vP17jzsiOsqw7DpKbO7GczU2SGrucpSWc5go8Gw" & _  
  7. "kmE7aGUM5YfAyqhNiRBcWsrS4Dg1mBbZBAszqwV6kJeYfcOYcR73Acbx6s1Rf0HP9tp7772f5/W897xe" & _  
  8. "jw4A/a/gnT4SHMuJVI9uxeO1NXZnVobAm0hRVFJUBtt8Um12MvEcLcx5/umlvqqdKSkGUq1y4p1451oi" & _  
  9. "aTH5Cg42a9NA8PNQWLJnLhB4YyJBtVnJYFlE9qyXci9ejkM /gosWFFWaeL0pKoKUbIjN8W7sbnh91tA" & _  
  10. "nBHMxvvHBgY5NcMlSSKZJZksDxSt+aRnKnrjJhD6ZRptPdNwel4oF0RBR3Jm4dbWc8CVGwzXgYHhGQz9" & _  
  11. "Aezcd6k/2bbczi+p8u5r/+vv736eQaBXw0fdMQT7gIqmWzBZM7NJEHjb6k01n7Z0A8d7ptB+fgKBrzSc" & _  
  12. "/gEoeWNgsKJpZLTzUhxNXRpqjsawo2UaRe9EkPHgxlZRMFlIkSUyGpPlrCfqzviPALs/nsSeNg31HRr2" & _  
  13. "d8XxZnAKJe+NY+WrEaSXaBC3jCHJ9dRxM6cTEzNQFCVBwnEGiytv71lPVRzZVRNYtUuD5xUNrhdjMG2N" & _  
  14. "gvJjMGwegfG+zQHJrJNVC6tLEMxKNSuZyBFnJFHN+7BvXtkM+OcmIRRPQiyeSuCeijhUd0GraCAu0ZQV" & _  
  15. "zxGkppFitZPsuJ9s3tJcT/XNP927gWUM2bVzWLoL8LLTs+PrC0r6MpcscHM/Z2AEDhIFnuavb/Q9XI/x" & _  
  16. "RxuAZ1qAynag7gxQexrwtwH5zcD6A8BD1deuyne675XMzCezBPIdTkr1Fq7a0Bi9XXoMeDkINPYCXSGg" & _  
  17. "40eg8zJwimE/k9ofAEoZ2brXh0KyY9FdsmAiSluzPacsiGjdWeBthiPfAn3MEz3XZ+D2FRzKzd/e8f0I" & _  
  18. "u18DDn0DvPUFsIeRPdsQDqlpGU5S0hfn+A9fiZy6ymzcD1z8DegfBVZu2HY0SUcper2O37StujN8GzjP" & _  
  19. "jBZgOSfDQPG750ZFq2MJiczzsmPhI/Unh8aGNeCnMSBvS3mbXkfifxLrk5KUwsq9nw3HgPA48NrBL0dM" & _  
  20. "knW1xIaZkNBsSqZ5d7sf+6B7IPJkkf8E68pq2bb9O2mF7YTOYLSW1x3ubTxxIcKrqT7RPLex/wChysEH" & _  
  21. "uzPdJAAAAABJRU5ErkJggg=="  
  22.   
  23. Dim B() As Byte  
  24. B = Convert.FromBase64String(Str)  
  25. Dim MS As IO.MemoryStream  
  26. MS = New IO.MemoryStream(B)  
  27. PictureBox1.Image = Image.FromStream(MS)