Thanks for the replies - how do I find how the encoding? It's
whatever encoding that .Net uses in GDI+ to save a .GIF file. Here's
how the image is created:
'From: http://www.chrisfrazier.net/blog/archive/2005/05/27/276.aspx
Dim stream As New
System.IO.MemoryStream(Convert.FromBase64String(imageData))
Dim noteImage As System.Drawing.Bitmap =
DirectCast(System.Drawing.Image.FromStream(stream),
System.Drawing.Bitmap)
noteImage.Save(fs, System.Drawing.Imaging.ImageFormat.Gif)
stream.Close()
After this code runs, the file is stored to a String field in a Siebel
database (I realize that a different type might be preferable).
However, the .gif file is created correctly in the local file system,
and when I pull the string OUT of the database, it's the exact same
length in bytes as the file.
I've tried all the standard encodings (Unicode, UTF7, UTF8, UTF32,
BigEndianUnicode, and Default), and none of them seem to work. ASCII
gets me the closest to the correct byte size though. Is this a case
where I need to resort to referring to a numbered CodePage?
Thanks!
Andy
Andrew Morton - 12 Mar 2008 17:36 GMT
> Thanks for the replies - how do I find how the encoding? It's
> whatever encoding that .Net uses in GDI+ to save a .GIF file. Here's
> how the image is created:
<snip>
.Net (and everything else) doesn't use any encoding to save a .gif file -
it's just a load of bytes with no relation to text.
> I've tried all the standard encodings (Unicode, UTF7, UTF8, UTF32,
> BigEndianUnicode, and Default), and none of them seem to work. ASCII
> gets me the closest to the correct byte size though. Is this a case
> where I need to resort to referring to a numbered CodePage?
The chrisfrazier web site is being too slow for me to see a reason for you
wanting to treat binary data as text, but basically you want the system to
use an 8-bit character set. UTF and ASCII are not; Windows-1252 and so on
are.
If the gif file exists on disk, you can use Response.WriteFile().
Andrew
Andrew Douglas - 12 Mar 2008 18:24 GMT
Got it working - thanks everyone for the replies! Bruce was correct
about losing data. The image data was coming from a Base64 String,
and I was losing data going to String. With
System.Convert.ToBase64String(data), all the bytes are as they were
when I saved the .gif.
Thanks all!