A
andrew.douglas11
Hello,
I'm looking to display an image in the browser using a binary string
containing all the bytes that make up a GIF image. I've tried all
the standard encodings in System.Text.Encoding, but the images aren't
showing up. I'm using the approach where I'm setting ImageURL =
"GetImage.aspx?id=1". Here's my code from GetImage.aspx:
Dim imageData As String = the binary data representing a .gif file
Dim imageBytes() As Byte =
System.Text.Encoding.ASCII.GetBytes(imageData)
Response.Expires = 0
Response.Buffer = True
Response.Clear()
Response.ContentType = "image/gif"
Response.BinaryWrite(imageBytes)
Response.End()
Can anyone offer any insight as to why this won't work? Using the
ASCII encoding, imageBytes.Length is the same size as
imageData.Length, but all the other standard encodings differ. Also,
if I use ASCII encoding and write the byte array to a file, I noticed
that the file size is very close to, but doesn't match the original
exactly. If I open the 2 different files using Notepad, I see special
characters like the Euro in the working original .gif file, but all
the special characters in the other file show up as a question mark
character.
Any help is greatly appreciated!
Andy
I'm looking to display an image in the browser using a binary string
containing all the bytes that make up a GIF image. I've tried all
the standard encodings in System.Text.Encoding, but the images aren't
showing up. I'm using the approach where I'm setting ImageURL =
"GetImage.aspx?id=1". Here's my code from GetImage.aspx:
Dim imageData As String = the binary data representing a .gif file
Dim imageBytes() As Byte =
System.Text.Encoding.ASCII.GetBytes(imageData)
Response.Expires = 0
Response.Buffer = True
Response.Clear()
Response.ContentType = "image/gif"
Response.BinaryWrite(imageBytes)
Response.End()
Can anyone offer any insight as to why this won't work? Using the
ASCII encoding, imageBytes.Length is the same size as
imageData.Length, but all the other standard encodings differ. Also,
if I use ASCII encoding and write the byte array to a file, I noticed
that the file size is very close to, but doesn't match the original
exactly. If I open the 2 different files using Notepad, I see special
characters like the Euro in the working original .gif file, but all
the special characters in the other file show up as a question mark
character.
Any help is greatly appreciated!
Andy