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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Detect the index of the first visible image?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Jan 02 2017 : 06:40:57
I need to get the INDEX of the first image (even partially) visible in the ImageEnMView.

So far I've looped through ALL the images in the ImageEnMView and stopped at the first image where ImageEnMView1.IsVisible(i) = True.

But this is very inefficient when the ImageEnMView contains a LARGE number of images. Is there a better way?
7   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jan 08 2017 : 20:02:24
Thanks, I have corrected it to:

if the user has scrolled vertically by two *rows*

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
PeterPanino Posted - Jan 06 2017 : 06:53:24
Thank you, Nigel. In my function GetIndexOfFirstVisibleImage I do use ViewY. It works well and it really helps me to speed things up. It does indeed support partial view. Thank you!

BTW, I am not sure whether there is a typo at: http://www.imageen.com/help/TImageEnMView.ViewY.html when it says: "if the user has scrolled vertically by two columns".
xequte Posted - Jan 05 2017 : 17:17:24
Hi

You can also use ViewY:

http://www.imageen.com/help/TImageEnMView.ViewX.html

I'm out of the office, so I cannot confirm whether it includes partial thumbnails. If not, you can at least use it to set the range for your iteration which will greatly speed up the process.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Jan 02 2017 : 11:55:47
It works here.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
PeterPanino Posted - Jan 02 2017 : 11:45:08
There was a bug in my code. So here is the (hopefully) bugfree code:

function TForm2.GetImageCountPerRow(const AImageEnMView: TImageEnMView): Integer;
var
  i: Integer;
begin
  Result := -1;

  for i := 0 to AImageEnMView.ImageCount - 1 do
  begin
    if AImageEnMView.ImageRow[i] = 1 then
    begin
      Result := i;
      BREAK;
    end;
  end;
end;

function TForm2.GetIndexOfFirstVisibleImage(const AImageEnMView: TImageEnMView): Integer;
var
  c: Integer;
begin
  c := GetImageCountPerRow(AImageEnMView);

  if c = -1 then
  begin
    // not enough images to fill a row + 1
    Result := 0;
  end
  else
    Result := (AImageEnMView.ViewY div AImageEnMView.ThumbHeight) * c;
end;

CodeSite.Send('Index of first visible Image', GetIndexOfFirstVisibleImage(ImageEnMView1));


Can please anybody test this.
PeterPanino Posted - Jan 02 2017 : 09:55:47
This looks much better:

function TForm2.GetImageCountPerRow(const AImageEnMView: TImageEnMView): Integer;
var
  i: Integer;
begin
  Result := -1;

  for i := 0 to AImageEnMView.ImageCount - 1 do
  begin
    if AImageEnMView.ImageRow[i] = 1 then
    begin
      Result := i;
      BREAK;
    end;
  end;
end;

function TForm2.GetIndexOfFirstVisibleImage(const AImageEnMView: TImageEnMView): Integer;
var
  c: Integer;
begin
  c := GetImageCountPerRow(AImageEnMView);

  if c = -1 then
    Result := -1
  else
    Result := (AImageEnMView.ViewY div AImageEnMView.ThumbHeight) * c;
end;

CodeSite.Send('Index of first visible Image', GetIndexOfFirstVisibleImage(ImageEnMView1));
PeterPanino Posted - Jan 02 2017 : 09:34:32
I made this code:

function GetImageCountPerRow: Integer;
var
  i: Integer;
begin
  Result := -1;

  for i := 0 to ImageEnMView1.ImageCount - 1 do
  begin
    if ImageEnMView1.ImageRow[i] = 1 then
    begin
      Result := i;
      BREAK;
    end;
  end;
end;

CodeSite.Send('Index of first visible Image', 
  (ImageEnMView1.ViewY div ImageEnMView1.ThumbHeight) * GetImageCountPerRow);


It works. But do you think that this could be always reliable?