Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

For duke_n

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
joely
Asked:
joely
1 Solution
 
BlackDeathCommented:
decompression algorithm takes more operations (depending on compression rate).

Black Death.
0
 
duke_nCommented:
I've got no idea, but if BlackDeath says so...
It's pretty stisfying explanation...
0
 
BlackDeathCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
JaccoCommented:
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
 
BlackDeathCommented:
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
 
joelyAuthor Commented:
Quite a good explanation.
Thank's.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now