Solved

convert AS jpeg

Posted on 1998-03-18
2
561 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now