Solved

convert AS jpeg

Posted on 1998-03-18
2
567 Views
Last Modified: 2012-05-04
How can I convert a bmp file to JPEG
0
Comment
Question by:aktis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C Language combined operators 28 137
C language IDE – Compilers installation 14 90
How to learn Linux? 10 96
upload values via post via proxy 1 19
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…
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…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Suggested Courses

734 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