Solved

For duke_n

Posted on 1998-09-16
6
149 Views
Last Modified: 2010-04-06
Hi

Based on your proposed answer to roosiedb (Jan van Barchum) about Picture-formats other than BMP.
Reading JPG file is much slower than reading BMP file. Why ?
Do you have any solution to make it faster ?

Joely
0
Comment
Question by:joely
6 Comments
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1339851
decompression algorithm takes more operations (depending on compression rate).

Black Death.
0
 
LVL 1

Expert Comment

by:duke_n
ID: 1339852
I've got no idea, but if BlackDeath says so...
It's pretty stisfying explanation...
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1339853
well:

jpeg (joint photographics experts group) is a compression method designed by this group, not a format.

e.g. the file formats tiff and jfif use this compression method.

mostly jfif is referred to as jpeg and named *.jpg or *.jpeg.

now - the point is, to display a bmp you just gotta decode the header and bring it up to screen.

to display a jpeg-compressed jfif or tiff, you gotta decompress first, then decode the respective header and then bring it to screen. the higher the compression rate, the longer decompression lasts.

the latter one takes more operations, depending on compression rate.

if you wanna have information on picture compression and formats, take a look at the following sites:

http://members.aol.com/judinorth/gifs.book/jpegs/jpeg.html
http://members.aol.com/jnfbooks/gifs.html

- they're really informative.

have a nice day,

Black Death.

p.s.: i do not know any way to display jpeg-compressed pictures faster then bitmaps...


0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 10

Accepted Solution

by:
Jacco earned 50 total points
ID: 1339854
BlackDeath:

>>the higher the compression rate, the longer decompression lasts.

joely:

This is entirely not true. The higher the compression rate (you loose more color information) The less information there is to decompress. So actually it is faster.

The compression used by the JPG file format is a rather complex one. Compressing and decompressing can take quite long. This all is because it uses a Fourier Transform method to reduce the information. This transformation inclodus sine and cosinus math. So there goes your speed. The transformation is done on square pixel blocks for each color spectrum (red green blue). The information is aranged in a way that the least important information for the eye is represented by as low as possible numbers (a lot become zero if the compression is not lossless). The result is the runlength encoded (special kind don't remember). Because of all the zeros at the end of (the information that is least important for the eye) is compressed very good. (i.e. 20x0 is smaller then 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0).

Now you understand why jpg is slower. BMP just contains straight forward (optionally only runlength encoded) information.

You cannot write a jpg encoder/decoder yourself. Way to complex!! But there is one included with delphi and there is jpegpas or jpegpas10 (you can find it on the most important Delphi sites). Maybe (i don't know) this library is faster then the one included with Delphi. Try it out.

But loading/displaying a bitmap will ALWAYS be faster.

Regards Jacco
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1339855
hi jacco!

i have to confess:
you're absolutely right concerning decompression time.
i've tested with a big bitmap, which i converted 3 times to jpg:
1st with 0%   compression
2nd with 50%  compression
3rd with 100% compression
i saved them as x000.jpg, x050.jpg, x100.jpg.
only silly thing i did was to not read the dialog:
below it said: "picture quality" and not "compression ratio".
so i interpreted the times i measured completely the wrong way round.
(which i didn't even wonder about, because with file compression my interpretation would have fit, so i didn't think about it any longer)

i apologize for the wrong information and feel very awful about it.

i hope you pardon me for this crap.

have a nice day,

Black Death.

0
 

Author Comment

by:joely
ID: 1339856
Quite a good explanation.
Thank's.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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