Solved

convert AS jpeg

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

929 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

14 Experts available now in Live!

Get 1:1 Help Now