ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ImageEnMView with Thumbnail previews?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

lcd877

2 Posts

Posted - Nov 27 2012 :  02:59:20  Show Profile  Reply
I am creating a simple slide viewer with an ImageEnMView for showing the selected image in large size and another ImageEnMView which displays thumbnails of all images in a directory (ImageEnMView is used for the large picture so that we can display transitions when switching between slides).

Currently both controls load their images directly from the directory, which means each image file is loaded twice... This works but is not efficient.

Is there a good way to share the images between the two controls?

Thanks,
Alexander

w2m

USA
1990 Posts

Posted - Nov 28 2012 :  06:46:24  Show Profile  Reply
As far as I know, there is no way to get the original bitmap directly from ImageEnMView when the StoreType property is set to ietThumb. You can load the original bitmap from the file by getting the filename from ImageEnMView and loading it into ImageEnView however:

procedure TForm1.ImageEnMView1ImageSelect(Sender: TObject; idx: Integer);
begin
  // if StoreType = ietNormal get the bitmap from ImageEnMView else load the file
  if ImageEnMView1.StoreType = ietNormal then
  begin
     ImageEnView1.IEBitmap.Assign(ImageEnMView1.GetTIEBitmap(idx));
     ImageEnMView1.ReleaseBitmap(idx);
     ImageEnView1.IO.Params.Assign(ImageEnMView1.MIO.Params[idx]);
  end
  else
  begin    
    iFilename := ImageEnMView1.ImageFileName[idx];
    ImageEnView1.IO.LoadFromFile(iFilename);
  end;
  ImageEnView1.Update;
end;


This is not redundant because when the StoreType property is set to ietThumb, ImageEnMView only contains thumbnails of the original image so the only way to get the original image is to load it directly from a file.

You can move images from one ImageEnMView to another but if the source ImageEnView StoreType is ietThumb, then the destination ImageEnMView will contain thumbnails even if the destination StoreType is ietNormal. This is because ImageEnMView does not have anyway to store the full sized image as well as a thumbnail.

procedure TForm1.Button1Click(Sender: TObject);
// copy images from Source ImageEnMView to Destination ImageEnMView
// Note if source ImageEnMView contains only thumbnails the destination ImageEnMView will also contain thumbnails
var
  i: integer;
  iIEBitmap: TIEBitmap;
begin
  ImageEnMView2.Clear;
  ImageEnMView2.LockPaint;
  for i := 0 to ImageEnMView1.ImageCount - 1 do
  begin
    iIEBitmap := ImageEnMView1.GetTIEBitmap(i);
    ImageEnMView2.AppendImage;
    ImageEnMView2.SetIEBitmap(i, iIEBitmap);
    ImageEnMView1.ReleaseBitmap(i);
  end;
  ImageEnMView2.SelectedImage := 0;
  ImageEnMView2.UnLockPaint;
end;


If I were you I would just set the StoreType for both ImageEnMView to ietNormal which solves the problem because then you can get the original IEBitmap for the transition...

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: