473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to convert a base 64 encoded GIF image to a *.gif file?

hb
Hi,

Would you please give me some idea to convert/decode a Base 64 encoded GIF
image string to a *.gif file in ASP.Net?

Thank you

hb
Nov 18 '05 #1
6 3973
See if this helps: http://vsdntips.com/Tips/VS.NET/Csharp/76.aspx

"hb" <ho****@goodoffices.com> wrote in message
news:OV**************@TK2MSFTNGP14.phx.gbl...
Hi,

Would you please give me some idea to convert/decode a Base 64 encoded GIF
image string to a *.gif file in ASP.Net?

Thank you

hb

Nov 18 '05 #2
hb
Hi, Shiva,

Thank you for the help!

I tried the code mentioned in the link page you gave me. But I got the
following error:
===
System.ArgumentException: Invalid parameter used. at
System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement, Boolean validateImageData) at
System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement) at System.Drawing.Image.FromStream(Stream
stream)
===

Here is the code I used:
---
string sLabel=UPS.UPSShipLabelHtml(); //get Base 64 encoded image string
string sTrackNum=UPS.UPSTrackNum();
if(sLabel.Trim().Length>0)
{
string sf="label"+sTrackNum+".gif";
Byte[] bitmapData=new Byte[sLabel.Length];

//take out space and "\r\n" from sLabel
bitmapData=Convert.FromBase64String(UPS.CleanBase6 4Image(sLabel));
System.IO.MemoryStream memStream=new System.IO.MemoryStream(bitmapData);
System.Drawing.Bitmap bitImage=new
System.Drawing.Bitmap((System.Drawing.Bitmap)Syste m.Drawing.Image.FromStream
(memStream));
bitImage.Save(MapPath("/docs/"+sf));
}
---

Would you please help me to figure out the problem?

Thank you

hb
"Shiva" <sh******@online.excite.com> wrote in message
news:up**************@TK2MSFTNGP12.phx.gbl...
See if this helps: http://vsdntips.com/Tips/VS.NET/Csharp/76.aspx

Nov 18 '05 #3
Hi,
Make sure the Base64 string represents a valid image.

"hb" <ho****@goodoffices.com> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
Hi, Shiva,

Thank you for the help!

I tried the code mentioned in the link page you gave me. But I got the
following error:
===
System.ArgumentException: Invalid parameter used. at
System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement, Boolean validateImageData) at
System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement) at System.Drawing.Image.FromStream(Stream
stream)
===

Here is the code I used:
---
string sLabel=UPS.UPSShipLabelHtml(); //get Base 64 encoded image string
string sTrackNum=UPS.UPSTrackNum();
if(sLabel.Trim().Length>0)
{
string sf="label"+sTrackNum+".gif";
Byte[] bitmapData=new Byte[sLabel.Length];

//take out space and "\r\n" from sLabel
bitmapData=Convert.FromBase64String(UPS.CleanBase6 4Image(sLabel));
System.IO.MemoryStream memStream=new System.IO.MemoryStream(bitmapData);
System.Drawing.Bitmap bitImage=new
System.Drawing.Bitmap((System.Drawing.Bitmap)Syste m.Drawing.Image.FromStream
(memStream));
bitImage.Save(MapPath("/docs/"+sf));
}
---

Would you please help me to figure out the problem?

Thank you

hb
"Shiva" <sh******@online.excite.com> wrote in message
news:up**************@TK2MSFTNGP12.phx.gbl...
See if this helps: http://vsdntips.com/Tips/VS.NET/Csharp/76.aspx


Nov 18 '05 #4
hb
Hi, Shiva,

Yes, the Base64 string does represent a valid GIF image.

Do you know why the parameter I used in FromStream() is invalid?
It is a MemoryStream object.

Thank you

hb
"Shiva" <sh******@online.excite.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,
Make sure the Base64 string represents a valid image.

"hb" <ho****@goodoffices.com> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
Hi, Shiva,

Thank you for the help!

I tried the code mentioned in the link page you gave me. But I got the
following error:
===
System.ArgumentException: Invalid parameter used. at
System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement, Boolean validateImageData) at
System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement) at System.Drawing.Image.FromStream(Stream
stream)
===

Here is the code I used:
---
string sLabel=UPS.UPSShipLabelHtml(); //get Base 64 encoded image string
string sTrackNum=UPS.UPSTrackNum();
if(sLabel.Trim().Length>0)
{
string sf="label"+sTrackNum+".gif";
Byte[] bitmapData=new Byte[sLabel.Length];

//take out space and "\r\n" from sLabel
bitmapData=Convert.FromBase64String(UPS.CleanBase6 4Image(sLabel));
System.IO.MemoryStream memStream=new System.IO.MemoryStream(bitmapData);
System.Drawing.Bitmap bitImage=new
System.Drawing.Bitmap((System.Drawing.Bitmap)Syste m.Drawing.Image.FromStream (memStream));
bitImage.Save(MapPath("/docs/"+sf));
}
---

Would you please help me to figure out the problem?

Thank you

hb
"Shiva" <sh******@online.excite.com> wrote in message
news:up**************@TK2MSFTNGP12.phx.gbl...
See if this helps: http://vsdntips.com/Tips/VS.NET/Csharp/76.aspx


Nov 18 '05 #5
Ok, going deeper, what about the stream that you pass to FromStream() - is
it null by chance? Is the bitmapData array ok?

"hb" <ho****@goodoffices.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi, Shiva,

Yes, the Base64 string does represent a valid GIF image.

Do you know why the parameter I used in FromStream() is invalid?
It is a MemoryStream object.

Thank you

hb
"Shiva" <sh******@online.excite.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,
Make sure the Base64 string represents a valid image.

"hb" <ho****@goodoffices.com> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
Hi, Shiva,

Thank you for the help!

I tried the code mentioned in the link page you gave me. But I got the
following error:
===
System.ArgumentException: Invalid parameter used. at
System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement, Boolean validateImageData) at
System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement) at System.Drawing.Image.FromStream(Stream
stream)
===

Here is the code I used:
---
string sLabel=UPS.UPSShipLabelHtml(); //get Base 64 encoded image string
string sTrackNum=UPS.UPSTrackNum();
if(sLabel.Trim().Length>0)
{
string sf="label"+sTrackNum+".gif";
Byte[] bitmapData=new Byte[sLabel.Length];

//take out space and "\r\n" from sLabel
bitmapData=Convert.FromBase64String(UPS.CleanBase6 4Image(sLabel));
System.IO.MemoryStream memStream=new System.IO.MemoryStream(bitmapData);
System.Drawing.Bitmap bitImage=new
System.Drawing.Bitmap((System.Drawing.Bitmap)Syste m.Drawing.Image.FromStream (memStream));
bitImage.Save(MapPath("/docs/"+sf));
}
---

Would you please help me to figure out the problem?

Thank you

hb
"Shiva" <sh******@online.excite.com> wrote in message
news:up**************@TK2MSFTNGP12.phx.gbl...
See if this helps: http://vsdntips.com/Tips/VS.NET/Csharp/76.aspx



Nov 18 '05 #6
hb
Shiva,

I checked the data. bitmapData is OK and memStream.ToArray().Length=1852.
Why FromStream() complaints about the parameter?

hb
"Shiva" <sh******@online.excite.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
Ok, going deeper, what about the stream that you pass to FromStream() - is
it null by chance? Is the bitmapData array ok?

"hb" <ho****@goodoffices.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi, Shiva,

Yes, the Base64 string does represent a valid GIF image.

Do you know why the parameter I used in FromStream() is invalid?
It is a MemoryStream object.

Thank you

hb
"Shiva" <sh******@online.excite.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,
Make sure the Base64 string represents a valid image.

"hb" <ho****@goodoffices.com> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
Hi, Shiva,

Thank you for the help!

I tried the code mentioned in the link page you gave me. But I got the
following error:
===
System.ArgumentException: Invalid parameter used. at
System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement, Boolean validateImageData) at
System.Drawing.Image.FromStream(Stream stream, Boolean
useEmbeddedColorManagement) at System.Drawing.Image.FromStream(Stream
stream)
===

Here is the code I used:
---
string sLabel=UPS.UPSShipLabelHtml(); //get Base 64 encoded image string
string sTrackNum=UPS.UPSTrackNum();
if(sLabel.Trim().Length>0)
{
string sf="label"+sTrackNum+".gif";
Byte[] bitmapData=new Byte[sLabel.Length];

//take out space and "\r\n" from sLabel
bitmapData=Convert.FromBase64String(UPS.CleanBase6 4Image(sLabel));
System.IO.MemoryStream memStream=new System.IO.MemoryStream(bitmapData); System.Drawing.Bitmap bitImage=new

System.Drawing.Bitmap((System.Drawing.Bitmap)Syste m.Drawing.Image.FromStream
(memStream));
bitImage.Save(MapPath("/docs/"+sf));
}
---

Would you please help me to figure out the problem?

Thank you

hb
"Shiva" <sh******@online.excite.com> wrote in message
news:up**************@TK2MSFTNGP12.phx.gbl...
See if this helps: http://vsdntips.com/Tips/VS.NET/Csharp/76.aspx



Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
2
by: VenuGopal | last post by:
Hi Everyone, in my application i am interacting to a known server. i send a request and get a response from the server. i am using XML and HTTP here. part of the job is that the XYZ server is...
2
by: Joey Lee | last post by:
Hi, Does anyone know how I am able to write a utf-8 encoded binary string into binary file? Currently I am given a UTF-8 string which was read from a gif image. Here are my functions... ...
5
by: Socrates | last post by:
I am interested in developing an online utility that will enable users to copy and past any image (or upload any image on the internet) to the online utility, which will then convert the image to...
0
by: Sanjib Biswas | last post by:
Hi, How to convert string data from an XML file representing an image to an oleobject? And how do you insert this data into a table using insert into... statement? I know Access 2002 has the...
6
by: PenguinPig | last post by:
Dear All Experts I would like to know how to convert a HTML into Image using C#. Or allow me contains HTML code (parsed) in Image? I also tried this way but it just display the character "<" &...
3
by: Sun | last post by:
Hi everyone . I have two files named a.txt and b.txt. I open a.txt with ultraeditor.exe. here is the first row of the file: neu für then I switch to the HEX mode: 00000000h: FF FE 6E 00 65...
4
by: =?ISO-8859-2?Q?Boris_Du=B9ek?= | last post by:
Hi, I have an API that returns UTF-8 encoded strings. I have a utf8 codevt facet available to do the conversion from UTF-8 to wchar_t encoding defined by the platform. I have no trouble...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.