473,395 Members | 1,678 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,395 software developers and data experts.

Convert encoded text to image

4
Hi there,

I would like to process the text of a gif file (when decoded something like GIF89aš @÷ € € €€ €€ € €€€€€ĄĄĄ’ ......) back to an image for display in a web page. I have done this with other image types (bmp and jpg), reading in there base64 converted strings, but have not found a way to do this with the gif filetype. Is this at all possible using c# and asp.net, even javascript? Thank you for any advice on this subject.

Regards,
Oct 1 '09 #1
9 5317
mwwv
4
Hi,

Is there a way to convert the ascii representation of an image (e.g. BM¶¦ 6 ( € ć   €¦ BAB ...), to display in an image control using C#? Thanks.

Regards,
Oct 6 '09 #2
Plater
7,872 Expert 4TB
Create a Bitmap object and set the pixels according to the input data. Depending on the format of your data, you might be able to load a Bitmap object directly from it.
Oct 6 '09 #3
tlhintoq
3,525 Expert 2GB
@mwwv
Basically undo the process that created the ASCII out of the bitmap to turn it back into a bitmap.

How did you convert the bitmap to an ASCII representation?
Oct 6 '09 #4
mwwv
4
Thank you both for your input.

The purpose of the application is to process MMS messages and display their contents (whatever format it comes in) through a web browser. The MMSs are received as text and the images they contain are therefore displayed as ASCII characters like in the example, so I do not actually do any conversion to ASCII myself. I just need to convert it back. I will look into your suggestions, thanks again.
Oct 8 '09 #5
tlhintoq
3,525 Expert 2GB
I'm going to guess the data comes in as a stream of bytes.
Those bytes are being blindly converted to text. Probably something similar to
Expand|Select|Wrap|Line Numbers
  1.         public static string ToString(byte[] Bytes)
  2.         {
  3.             System.Text.Encoding enc = System.Text.Encoding.ASCII;
  4.             return enc.GetString(Bytes);
  5.         }
  6.  
Assuming no data has actually been lost, you need to know what the format of the image is supposed to be and try to convert the text to bytes to a bmp.

Do you have any way of knowing what the image format would be that was sent?
JPG... GIF.... PNG...
Indexed color?
RGB?

I'm going to guess that you have lost data though. As soon as the byte[] was converted to text it would have been truncated at the first zero byte \0 because that is the "end of string" terminator.

You need to pull the image out of the raw byte[] before it gets converting to text. Is that an option?
Oct 9 '09 #6
Plater
7,872 Expert 4TB
MMS messages are pretty much like emails. There should be content header declaring the MIME type of the data
Oct 9 '09 #7
mwwv
4
Again, thanks for your replies.

Plater you are correct about the header, I have a sample MMS and I will paste the info below, and this also answers tlhintoq's question regarding the image format as the header indicates this:

------=_Part_4629139_16129933.1248339602246
Content-Type: image/gif;Name=waterfall_gif.gif
Content-Transfer-Encoding: binary
Content-Location:waterfall_gif.gif

GIF89aš @÷ € € €€ €€ € €€€€€ĄĄĄ’ ’ ’’ ’’ ’ ’’’’’ 3 f ™ Ģ ’ 3 33 3f...

This particular example indicates a GIF image. This is basically as much info as we get as the MMS's are received as text files.
Oct 14 '09 #8
If you're reading in a base64 encoded binary string (the content of the GIF), decode it and then write it to a wherever you're writing the jpeg and bmp to, it should really be exactly the same for a GIF file I guess.

What is the exact problem when doing it with the GIF file as opposed to doing it with a JPEG or BMP?
Oct 15 '09 #9
Plater
7,872 Expert 4TB
Well then that sounds good, you just need to save the data into a file.
Have you tried writing all the binary data to a file and naming it say "waterfall_gif.gif" and seeing if it came out right?
Oct 15 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Leif Wessman | last post by:
Hi, How can I/Is it possible to convert a jpg image to a favicon using php (including resizing it if needed)? Leif
0
by: Marco | last post by:
Hi All, I am kinda new to this .NET programming and wondering if there's a way to convert PDF to Image(JPEG) using C#. If there's a way, could you give me a hint or two of how to do it,...
6
by: hb | last post by:
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
2
by: UJ | last post by:
I have need to convert a text string (with formatting) to an image. This is so that I can resize the image to different sizes and the formatting stays exactly the same regardless of the size. I...
4
by: Ben Amada | last post by:
Hello group. I'm passing URL encoded text (actually HTML) via querystring to a webform. Part of the encoded text looks like: ... %3Cfont%20color%3D%22yellow%22%20size%3D%227%22%3E .. ...
1
by: Husam | last post by:
Hi EveryBody: I have this code which convert RTF Text to HTML ? but I think it is written by vb.classic, I want some body help my in writting this code by Vb.Net ? but if it is already writen by...
1
by: Beckster6701 | last post by:
I have a MSAccess database that is linked to a SQL server. I cannot change the SQL server datatype as I am not the only one that uses the database. I'm trying to convert the text field to a valid...
6
by: cmdolcet69 | last post by:
Is there a class or anything else that i can use to convert English text to Spanish text in my vb.net programming application?
0
rahulephp
by: rahulephp | last post by:
hi all, I wanted such a php script which can convert pdf to image (jpg or png or gif) I searched a lot but couldn't able to find any simple ready-made script for this. Can anybody please hold my...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.