Solved

convert AS jpeg

Posted on 1998-03-18
2
566 Views
Last Modified: 2012-05-04
How can I convert a bmp file to JPEG
0
Comment
Question by:aktis
2 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1257758
I have no I dea what is on this sight, but it was proposed as an answer in th windows site.

http://www.pagesz.net/~chrisdl/software/jpegfile.htm
0
 
LVL 2

Accepted Solution

by:
Slarti earned 50 total points
ID: 1257759
What you need to do is the following:
1. Decode BMP file into an array of pixels. This is relatively simple, because BMPs usually aren't compressed. However, it is much simpler if you know what resolution you're working in, and especially the color depth (number of possible colors per pixel), since these are the main differences between different BMP files.
A BMP file contains a header and is then followed by a dump of the video memory, so that, for instance, in 8-bit color depth there will be a header followed by one byte per pixel. The ordering of the pixels depends on the graphics mode and is usually from left to right and from _bottom_ to _top_ (not the other way around as would appear to make more sense).
You can get more detailed information about the BMP format in the following locations:
For Windows BMP files:
http://wotsit.simsware.com/wgraphic/cgm.zip
For OS/2 BMP files (less commonly used):
http://www.edm2.com/0107/os2bmp.html

2. The next stage is to encode to JPEG format. This is _very_ complicated and you probably won't want to write the code yourself. The basic format for JPEG compression is as follows: the image is divided into blocks of 64x64 pixels. A 2D FFT is performed on each block for each color plane (red, green and blue). From the 2D FFT, minimal information is stored; the amount of information depends on the compression level requested, and this is where the quality-vs-compression-level tradeoff in JPEGs comes in to play. For instance, in a high compression level you might record only the 10 highest-amplitude frequencies in a particlar block. The result is then Huffman coded and stored. As I said, it's a pretty complex algorithm, but luckily for you there are plenty of pre-written programs for JPEG compression and decompression. Here's where you can find some programs that are in the public domain:
ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6a.tar.gz
This is a freeware compressor/decompressor written in ANSI C, with extensive comments, so it shouldn't be too difficult to incorporate it into your program.
If you are interested, here is some more detailed technical information about the JPEG format:
http://wotsit.simsware.com/wgraphic/jfif.zip
You may also want to check out the JPEG FAQ list:
http://www.cis.ohio-state.edu/hypertext/faq/usenet/jpeg-faq/top.html

Good luck!

Slarti
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question