tags:

views:

594

answers:

3

I want to develop an appication which can converts image to text format(some Ascii format) and text to image format. I want this because i need to decrease the size of the image file. Any suggestion plz. Thanks in advance, Ibrahim.

+1  A: 

When you say that you wish to reduce the size of the image do you mean that you wish to reduce the image file size or reduce the dimensions that it takes up on the display?

If you wish to reduce the file size then converting it to an ASCII file won't help. Instead you need to compress it. (Say by converting bitmap to jpeg).

Edit

Based on your comment. I would suggest that you look at JpegBitmapDecoder and JpegBitmapEncoder classes for decoding the jpeg file into a bitmap and then encoding the bitmap with different valkues from the start.

Microsoft info

Also look here for more information including how to override the default compression of 75% More info

ChrisBD
I want to reduce the file size. And iam using jpeg images only. Still i want to reduce the file size
ibrahimkhan
Edited my answer to include pointer to JpegBitmapEncoder and Decoder.
ChrisBD
If you are already using jpegs and still need to further reduce your file size, you really only have 3 options.1. Drop the quality of the jpeg (looks worse, but takes up less space)2. Reduce the resolution (again, it looks worse, but there are less graphical glitches)3. Use procedurally generated textures (can look really good and take up almost no space, but images have to be created specifically for it, and you'll have to fork out for a professional solution, or spend months of solid work developing your own, not really an option for most people)
Grant Peters
+2  A: 

Actually, when you convert an image to text, you will increase the size, not decrease it! The reason for this is simple: if you store an image in binary format, you'll have the full value spectrum of a byte available to store your image in. When you use a text format, the value spectrum is limited to 26 uppercase characters, 26 lowercase characters, 10 digits and a bunch of special characters, but it will be far less than the 256 values that you have in binary mode.

Converting binary to text and back again is often done by using UUEncoding. It's an encoding system that still manages to generate a reasonable small text-stream and it's a good standard that is used in many places already, with plenty of libraries for dozens of languages. UUEncoding uses 64 different characters, thus every 3 bytes of binary data gets translated to 4 characters. (Increase with one-third.)

To make your binary images smaller, use a different image format like JPG or PNG. JPG is advised for photo's where some loss of quality isn't a big problem. PNG is often used when image quality must be high or when your image has some transparent parts. If your original image is a BMP then converting it to PNG and then UUEncoding the PNG file will result in a considerable shrinking in filesize. (But that's because of the PNG compression, not the encoding.)

Workshop Alex
A: 

If you are wanting to recognise letters in your image and convert that to text, how about one of the OCR libraries?

Samuel Jack