Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

convert AS jpeg

Posted on 1998-03-18
2
Medium Priority
?
571 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 200 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

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…
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 for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

618 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