0

I am getting an image (encoded in base64 string format) from a server. This base64-encoded string has to be converted back to image. I am doing in two steps:

  1. Convert the base64 encoded string into a buffer - Using bits -> string to buffer(string,"base64")

  2. Write the buffer into a picture (of same dimensions) - Using Picture -> write buffer(buffer) and then I'm displaying the picture.

The base64 string from the server (whole string):

iVBORw0KGgoAAAANSUhEUgAAAJEAAAAeCAYAAAAsPvwuAAAAmUlEQVR42u3SQQoAIQgAwL7h/x+6sQsLHcqCPI7QITGNmvYsIiK+leX+/ZjPcifnsnvs5pzW3PaunLGrm/W6eZPqv3yjQQQRRBBBBBFEEEEEEUQQQQQRRBBBBBFEEEEEEUQQQQQRRBBBBBFEEEEEEUQQQQQRRBBBBBFEEEEEEUQQQQQRRBBBBBFEEEEEEUQQQQQRRBBBVIuoAwQlLkAhgPjNAAAAAElFTkSuQmCC

The problem is: I am not getting the desired image when I display it on the wall. It just shows a very small image.

So I tried finding what string TouchDevelop expected in bits -> string to buffer(string,"base64") method.

  1. I obtained the original image from online converter (http://www.motobit.com/util/base64-decoder-encoder.asp) supplying the same string as obtained from the server. This image was correct.
  2. Then I did the reverse process of what I described above – Converting an image into base64 string. This, I did by using Picture to buffer(Picture) and then buffer to string(“base64“) and displayed the base64 string as generated by TouchDevelop for the same image.

The base64 string I got from TouchDevelop (just a small part of actual string - Actual string size-23,300 chars):

////////////////////////////////GRkZ/xkZGf////////////////8ZGRn/GRkZ////////////GRkZ/xkZGf8ZGRn/GRkZ//////8ZGRn/GRkZ/xkZGf8ZGRn//////xkZGf8ZGRn///////////8ZGRn/GRkZ/xkZGf8ZGRn//////xkZGf8ZGRn//////////////////////xkZGf8ZGRn//////xkZGf8ZGRn//////xkZGf8ZGRn/GRkZ/xkZGf///////////xkZGf8ZGRn//////xkZGf8ZGRn/GRkZ/xkZGf//////////////////////GRkZ/xkZGf//////GRkZ/xkZGf//////GRkZ/xkZGf8ZGRn/GRkZ////////////GRkZ/xkZGf8ZGRn/GRkZ//////8ZGRn/GRkZ/xkZGf8ZGRn//////////////////////xkZGf8ZGRn//////xkZGf8ZGRn//////xkZGf8ZGRn///////////8ZGRn/GRkZ//////8ZGRn/GRkZ//////////////////////8ZGRn/GRkZ/xkZGf8ZGRn//////xkZGf8ZGRn//////xkZGf8ZGRn/GRkZ/xkZGf///////////xkZGf8ZGRn////////////////……

As you might have noticed, the base64 string from the server and the base64 string what TouchDevelop expects to show the correct image have a huge difference. And this is resulting into displaying of an incorrect image. I am stuck in this problem for a few days. Is there a bug? If not, can anyone help me with this problem?

Andrew T.
  • 4,701
  • 8
  • 43
  • 62
  • I'm not sure, but the output of your base64 from TouchDevelop is similar to [this base64 bytearray on resx file](https://xerostar.net/BattleField/Procon-1/raw/03842e9a85dac5c0b0162fceae69f4d41c25c16f/src/PRoCon/Forms/LicenseAgreement.resx) (the link is considered suspicious by Chrome, but it's actually safe), especially the amount of '/' (slashes). I guess we need the code of how you produced the base64. – Andrew T. Jul 08 '15 at 07:26
  • Oh, and how small the image you got? I got a 145x30px barcode from the original base64 you provided. – Andrew T. Jul 08 '15 at 07:29
  • My code: http://i.imgur.com/H7imR9A.png . And the original image is 145x30px barcode. But as you might notice in the code(alongwith its output on the right side), I'm getting an image of dimensions not even close to the original image. – Tejas Harne Jul 08 '15 at 09:15

0 Answers0