Board index » delphi » Creating image thumbnails????

Creating image thumbnails????

Hi all,

Ive got the ImageEn imaging library installed for delphi4, and it allows me
to create a thumbnail view of an image. The question I have, is how could I
display the entire directory contents in thumbnails. If I have the
filelistview on one side of the dialog, i would like to display thumbnails
of all the images in the directory. Can I just create the component at
runtime for every instance of a file??

Any help would be appreciated,

Dave

 

Re:Creating image thumbnails????


Hi Doc,

Ihaven't used the imageEn library and can't help you with it directly
but you can download my components for thumbnails from torry on graphics
3 tab to take some ideas on how to implement the directory view.

If you want I could help you to adapted so it could work with the
imageEn Library.But I need more info like how the images are opened can
be converted into Tbitmap component etc.

Hope this helps

Best Regards
Johnnie.

Quote
Doc wrote:

> Hi all,

> Ive got the ImageEn imaging library installed for delphi4, and it allows me
> to create a thumbnail view of an image. The question I have, is how could I
> display the entire directory contents in thumbnails. If I have the
> filelistview on one side of the dialog, i would like to display thumbnails
> of all the images in the directory. Can I just create the component at
> runtime for every instance of a file??

> Any help would be appreciated,

> Dave

Re:Creating image thumbnails????


Have a look at my delphi page. From the code there it should be obvious
how it is done.

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com

Quote
Doc wrote:

> Hi all,

> Ive got the ImageEn imaging library installed for delphi4, and it allows me
> to create a thumbnail view of an image. The question I have, is how could I
> display the entire directory contents in thumbnails. If I have the
> filelistview on one side of the dialog, i would like to display thumbnails
> of all the images in the directory. Can I just create the component at
> runtime for every instance of a file??

Re:Creating image thumbnails????


It can be done with a very few line of code with ImageEn.

var
  intIndex: integer;
  MySearchRec: TSearchRec;
begin
  iemv.Clear;
  try
    if (FindFirst(strPath, faAnyFile, MySearchRec) = 0) then
    begin
        Repeat
            intIndex := iemv.ImageCount;
            iemv.InsertImage(intIndex);
            iemv.ImageFileName[intIndex] := MySearchrec.FileName;
        Until (FindNext(MySearchRec) <> 0)
    end;
  finally
    FindClose(MySearchRec);
  end;
end;

Please join the ImageEn mailing list to have more informations.
http://www.egroups.com/group/imageen

Alex

Doc <[email protected]> a crit dans le message :
[email protected]

Quote
> Hi all,

> Ive got the ImageEn imaging library installed for delphi4, and it allows
me
> to create a thumbnail view of an image. The question I have, is how could
I
> display the entire directory contents in thumbnails. If I have the
> filelistview on one side of the dialog, i would like to display thumbnails
> of all the images in the directory. Can I just create the component at
> runtime for every instance of a file??

> Any help would be appreciated,

> Dave

Re:Creating image thumbnails????


You can use a standard image list and list view to do this.

Drop a list view on a form, leave it set to vsIcon.  Drop an ImageList
on a form.  Set the Width & Height to (say) 80.  Set the ListView's
LargeImages property to point to the image list.

Then do this (it only works for jpegs, but you could improve it...).  
It's quite fast, at least with JPegs.  Obviously you could further
improve it by cacheing the thumbnails (like paint-shop pro does with
their JBF files, or whatever they are)

procedure TfmBrowser.SetCurrentDirectory(const dir: string);
var
  s : TSearchRec;
  filter : string;
  n : Integer;
  b : TBitmap;
  i : TJPegImage;
  r, br, bb : TRect;
  c : Integer;
begin
  lvBrowse.Items.Clear;
  ilBrowse.Clear;
  filter := '*.jpg';
  i := Nil;

  b := TBitmap.Create;
  try
    b.Width := ilBrowse.Width;
    b.Height := ilBrowse.Height;

    br := rect (0, 0, b.Width - 1, b.Height - 1);
    bb := br;
    InflateRect (bb, -6, -6);

    i := TJPEGImage.Create;
    i.Scale := jsEighth;
    if FindFirst (dir + filter,  faReadOnly, s) = 0 then
    try
      n := 0;
      repeat
        i.LoadFromFile (dir + s.Name);
        if i.Width > i.Height then
        begin
          r.left := bb.left;
          r.right := bb.right;
          c := i.Height * bb.Right div i.Width;
          r.top := (bb.Bottom - c) div 2 + 1;
          r.Bottom := r.top + c
        end
        else
        begin
          r.Top := bb.Top;
          r.bottom := bb.Bottom;
          c := i.Width * bb.Bottom div i.Height;
          r.left := (bb.Right - c) div 2 + 1;
          r.Right := r.left + c
        end;
        DrawEdge (b.Canvas.Handle, br, EDGE_RAISED, BF_MIDDLE or
BF_TOPLEFT or BF_BOTTOMRIGHT);
        b.Canvas.StretchDraw (r, i);
        ilBrowse.Add (b, Nil);
        with lvBrowse.Items.Add do
        begin
          caption := s.Name;
          ImageIndex := n;
          Inc (n)
        end

      until FindNext (s) <> 0
    finally
      FindClose (s)
    end
  finally
    b.Free;
    i.Free
  end
end;

Colin
e-mail :[email protected]
web: http://www.wilsonc.demon.co.uk/delphi.htm

Other Threads