Reputation: 590
I have an image that was given to me in ASCII character format (from an XML document, i,e. sdlf9sdf09e93jr), and I was told that I should be able to convert that into binary and use that data to view it as a .gif image. I've converted all the ASCII characters into binary, but now I'm stuck and not sure what to do from there.
EDIT: Discovered the real problem I'm having: Even though I've translated the ASCII to binary, I've only written it to a file as what the binary should be for those ASCII characters. The "binary" characters are just a bunch of 0's and 1's in ASCII format. I'm using the C language to write this program that will create gif, but don't know what to do to create a .gif from my original XML parse.
Upvotes: 0
Views: 3538
Reputation: 88428
First, you need to know the encoding scheme used to encode the image as a sequence of characters in the XML document.
Are you sure you have ASCII data? It may be if it is base-64 encoded. If it is not base-64 encoded, perhaps you are seeing the Latin-1 characters corresponding to each byte.
But you say you have the byte sequence, the "binary" as you call it. If so, then do as MRAB says and save the bytes to a file, slap a .gif extension on that and open it with any viewer.
But again, make sure you know the encoding. Base-64 is common in XML.
Upvotes: 1
Reputation: 20664
If the binary is a GIF image, then just write it to a file with the extension ".gif".
Upvotes: 1