BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Display VERY fast thumbnails from JPEG

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Nicolae Guzun
Guest





PostPosted: Mon Apr 03, 2006 9:03 am    Post subject: Display VERY fast thumbnails from JPEG Reply with quote



Hello.

I have to develop a form where there should be dispayed some dozens of
thumbnails of JPEG images.

I know how to draw them, I know how to store them, I know about Scale
:= jsEighth. My problem is that I have to display some thumbs of VERY
large files (more than 8Mb in JPEG). Even with Scale := jsEighth they
are displayed very slow (20 files in about 20-30 sec). Windows and
ACDSee display them in 1-2 sec!!!!!

I saw here in the group the author of ABC-View Manager Nils Haeck. It
displays them slowly too.

I thought that Windows might display the embedded thumbnail, but I've
tried dEXIF module from
http://mcguirez.homestead.com/downloads.html
it loads embedded thumbnail from the JPEG taken ONLY from digital
cameras. It wont extract any thumbnail from the files created by
Photoshop, for example, although dEXIF sais there is an embedded
thumbnail.

I've also tried intel library but no changes.

Does anyone know a way to fastly load a JPEG in a poorer quality or
something that will help me bypass this problem.

Any help appreciated.
Back to top
Anders Isaksson
Guest





PostPosted: Mon Apr 03, 2006 5:03 pm    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote



Why not create thumbnails the way you're doing it now, but keep them in a
cache on disc? Next time you want to view them it will be much quicker (I
think that is what Windows does - the first time you switch a folder to
thumbnail view it takes a looong time).

This assumes that you want to view the same picture again and again,
otherwise there's no gain. You also need write permissions (and space!)
somewhere on the disk.

--
Anders Isaksson, Sweden
BlockCAD: http://web.telia.com/~u16122508/proglego.htm
Gallery: http://web.telia.com/~u16122508/gallery/index.htm
Back to top
Nils Haeck
Guest





PostPosted: Tue Apr 04, 2006 2:03 am    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote



Hi, I am the author of ABC-View Manager:)

Both ACDSee and Windows store a copy of the thumbnail in some kind of file.
Windows tends to splatter your HD with "thumbs" files (one for each
directory), and I think ACDSee centrally stores them.

ABC-View Manager can also cache and store the thumbnails, and on next run of
the program, when you load the database, it will also be fast.

Your other chance is indeed to read the embedded thumbnail. There is some
info available on the internet (search for EXIF format), which describes how
these are stored. Usually they're either a small JPG variant of the full
picture or (mostly) a small bitmap image.

The disadvantage of the embedded thumbnail is that it is fixed, small size,
and if your users select a thumbnail format slightly larger, the quality
isn't sufficient.

If you don't use the embedded thumbnail, your chances of making it fast for
huge files are minimal, because the first level compression is usually
huffmann, bitwise, and you can't easily divide the decoding process over
multiple processors.

You could try to optimise the existing JPG code though (provided by borland
without sources). There are some libs available, mostly for C/C++ but also
one for Delphi (Jacques Nommsi Nzali, hope I spelled that right, has ported
one, called PasJpeg). I didn't take this step in ABC-View Manager, because
of the amount of work involved.

Hope that helps,

Nils Haeck
www.simdesign.nl

"Nicolae Guzun" <guzunnicolae (AT) gmail (DOT) com> schreef in bericht
news:4430d556 (AT) newsgroups (DOT) borland.com...
Quote:

Hello.

I have to develop a form where there should be dispayed some dozens of
thumbnails of JPEG images.

I know how to draw them, I know how to store them, I know about Scale
:= jsEighth. My problem is that I have to display some thumbs of VERY
large files (more than 8Mb in JPEG). Even with Scale := jsEighth they
are displayed very slow (20 files in about 20-30 sec). Windows and
ACDSee display them in 1-2 sec!!!!!

I saw here in the group the author of ABC-View Manager Nils Haeck. It
displays them slowly too.

I thought that Windows might display the embedded thumbnail, but I've
tried dEXIF module from
http://mcguirez.homestead.com/downloads.html
it loads embedded thumbnail from the JPEG taken ONLY from digital
cameras. It wont extract any thumbnail from the files created by
Photoshop, for example, although dEXIF sais there is an embedded
thumbnail.

I've also tried intel library but no changes.

Does anyone know a way to fastly load a JPEG in a poorer quality or
something that will help me bypass this problem.

Any help appreciated.
Back to top
Nicholas Sherlock
Guest





PostPosted: Tue Apr 04, 2006 5:03 am    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote

Nils Haeck wrote:
Quote:
ABC-View Manager can also cache and store the thumbnails, and on next run of
the program, when you load the database, it will also be fast.

[...]

If you don't use the embedded thumbnail, your chances of making it fast for
huge files are minimal, because the first level compression is usually
huffmann, bitwise, and you can't easily divide the decoding process over
multiple processors.

Further to this, some applications break down the generation of
thumbnails into two stages. First, the directory is loaded and
thumbnails are generated using the fastest process available - Loading
at eighth and doing a linear stretch, perhaps, or loading the embedded
thumbnail. Anything to get something onto the screen that the user can use.

Then, while the user is browsing, you can go back, load the JPEG at high
quality, stretch at high quality, apply sharpening etc, and update your
thumbnail database with the higher quality thumb.

Cheers,
Nicholas Sherlock

--
http://www.sherlocksoftware.org
Back to top
Nicolae Guzun
Guest





PostPosted: Tue Apr 04, 2006 8:03 am    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote

First of all I want to thank Riki Wiki. He pointed me to repost this message on borland server.

Next I want to thank all you for replies.

Well, I had in mind the idea of a database that will store the thumbnails. But I don't like it so much. First, if the image is changed the thumbnail in the database remains the same, except that I check everytime I load an image for changes. Second, the algorythm becomes too complicated.
But as I see I have no other choise :)

To Nils Haeck:
Very interesting why your program loads the thumbs in a random order? What I like, is that if there are different file sizes it loads at first the smallest ones and after that moves to bigger Smile.
By the way when previewing my 8Mb JPEG image your program grows to about 200-400 Mb. Seems you don't stretch them. Look at it. And sometimes, especially when I open them from a network drive it writes me "Unable to decode".
Back to top
Nicholas Sherlock
Guest





PostPosted: Tue Apr 04, 2006 11:03 am    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote

Nicolae Guzun wrote:
Quote:
[..] I had in mind the idea of a database that will store the thumbnails. But I don't like it so much. First, if the image is changed the thumbnail in the database remains the same, except that I check everytime I load an image for changes

Checking comes free by way of FindFirst/FindNext(). You can just check
the last write time stamp and file size. I wouldn't bother with anything
as extensive as a CRC or checksum.

Cheers,
Nicholas Sherlock

--
http://www.sherlocksoftware.org
Back to top
Jens Gruschel
Guest





PostPosted: Tue Apr 04, 2006 6:03 pm    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote

Probably this won't help you, but I add it anyway. If you need a very
fast resampling algorithm for thumbnails take a look at
http://www.pegtop.net/delphi/components/common/ (especially
TPegtopThumbnail and TPegtopGraphicOpenDialog). For very large jpegs
jsEighth is used, but the jpeg is stretched to a multiple of the
destination size, then resampled (using MMX if available). If you
download the compiled demo you can see it in action in the file dialog
example.

--
Jens Gruschel
http://www.pegtop.net
Back to top
Nicolae Guzun
Guest





PostPosted: Wed Apr 05, 2006 8:03 am    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote

to Jens Gruschel:
I tried PegTop but I couldn't make it work. I am using Delphi 7, WinXP SP2. Then I downloaded the compiled demo and in GraphicDialog it does not display anything for my big pictures.

to Nicholas Sherlock:
I guess this is the preferred method considering development time and reliability. Thanks
Back to top
Jens Gruschel
Guest





PostPosted: Wed Apr 05, 2006 8:03 pm    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote

Quote:
I tried PegTop but I couldn't make it work. I am using Delphi 7, WinXP SP2.

What exactly didn't work? Any error messages?


Quote:
Then I downloaded the compiled demo and in GraphicDialog it does not display anything for my big pictures.

Well, that's why I said, it probably doesn't help you, because it
doesn't speed up loading. For loading images, TPicture.LoadFromFile is
used (which calls TJPegImage.LoadFromFile for jpegs), so if it doesn't
work for your images blame it on the VCL. My code is only useful to
display the image, more exactly: to resample it to thumbnail size, once
it is loaded.

--
Jens Gruschel
http://www.pegtop.net
Back to top
Nicolae Guzun
Guest





PostPosted: Thu Apr 06, 2006 3:03 pm    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote

Quote:
What exactly didn't work? Any error messages?

First of all my DPK's are PegtopCommonD5.dpk and PegtopCommonD5D.dpk. As I guess they are for Delphi 5.

Run-time package compiles without problem.

But design-time package tells me that it cannot find vcl50. Yesterday it blamed about another dcu file, I don't remember although I had it in pas. And sometimes at compilation I am getting "Out of memory".
Back to top
Jens Gruschel
Guest





PostPosted: Thu Apr 06, 2006 7:03 pm    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote

Quote:
But design-time package tells me that it cannot find vcl50.

Seems like it is not converted properly like it should.

Quote:
Yesterday it blamed about another dcu file, I don't remember although I had it in pas.

There are only .pas files included, no .dcu files.

Quote:
And sometimes at compilation I am getting "Out of memory".

That's not good, I'll take a look at it. The package compiles well here,
but with Delphi 5, but it was also compiled with Delphi 7 successfully
(I really should attach the package files to the .zip archive).

--
Jens Gruschel
http://www.pegtop.net
Back to top
Nils Haeck
Guest





PostPosted: Fri Apr 07, 2006 11:03 am    Post subject: Re: Display VERY fast thumbnails from JPEG Reply with quote

Quote:
To Nils Haeck:
Very interesting why your program loads the thumbs in a random order? What
I like, is that if there are different file sizes it loads at first the
smallest ones and after that moves to bigger Smile.
By the way when previewing my 8Mb JPEG image your program grows to about
200-400 Mb. Seems you don't stretch them. Look at it. And sometimes,
especially when I open them from a network drive it writes me "Unable to
decode".

First of all, I wrote ABC-View Manager in 2000, and didn't really have time
afterwards to update it thoroughly.

It doesn't decode the thumbnais at random, although it may seem so. It
decodes them based on whether the user wants to see them. So if you scroll
through a long listview of thumbnails, the ones that should be on the screen
are decoded first. I'm not sure if I added an additional file size sorting,
perhaps I did.

When you preview a large image, it indeed decodes the full image so you can
look at it full-size. It does limit the number of images in memory though,
and *should* take into account the available memory in that case (not sure
if it all works flawlessly though).

Opening from network might cause problems with timeouts leading to the
"unable to decode". In fact, there are quite a few little bugs in ABC-View
Manager. I wish I had time to really give the application an overhaul, but
right now I'm working on a lot of other projects, so it will have to wait.

Nils
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.