Solved

For duke_n

Posted on 1998-09-16
6
145 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

13 Experts available now in Live!

Get 1:1 Help Now