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
 TImageEnMView Issue
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

a.gosling

Germany
3 Posts

Posted - Mar 07 2024 :  01:55:03  Show Profile  Reply
Hi,

in the ImageEN Version 13 I have problems using the TImageEnMView. Theese problems didn't occur in the Version 11. I don't know, if they where present in Version 12.

I made a simple project:
- Loading 3 fixed Images in the List
- Adding ImageBottomText and ImageTag to all of them

Expected result:
- Pic1 with the Pottom Text "Pic 0" and ImageTag = 0
- Pic2 with the Pottom Text "Pic 1" and ImageTag = 1
- Pic3 with the Pottom Text "Pic 2" and ImageTag = 2

Result in fact;
- Pic1 with the Pottom Text "Pic 2" and ImageTag = 2
- Pic2 no Pottom Text and no ImageTag
- Pic3 no Pottom Text and no ImageTag

Can you help me with this problem?

Sourcecode:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, hyiedefs, hyieutils, iexBitmaps,
  iesettings, iemio, ieview, iemview;

type
  TForm1 = class(TForm)
    imgList: TImageEnMView;
    procedure FormShow(Sender: TObject);
    procedure imgListImageSelect(Sender: TObject; idx: Integer);
  private
    procedure LoadPictures;
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
begin
  LoadPictures;
end;

procedure TForm1.imgListImageSelect(Sender: TObject; idx: Integer);
begin
  Caption := 'Select Picture ImageTag: ' + imgList.ImageTag[idx].ToString;
end;

procedure TForm1.LoadPictures;
var
  NdxDokList: Integer;
  FileNames: TStringList;
  Ndx: Integer;
begin
  imgList.Clear;

  FileNames := TStringList.Create;
  FileNames.Add(ExtractFilePath(ParamStr(0)) + 'Pic1.png');
  FileNames.Add(ExtractFilePath(ParamStr(0)) + 'Pic2.png');
  FileNames.Add(ExtractFilePath(ParamStr(0)) + 'Pic3.png');

  imgList.LockPaint;
  imglist.Deselect;

  for Ndx := 0 to FileNames.Count -1 do
  begin
    if ( imglist.MIO.LoadFromFileAuto(FileNames[Ndx]) ) then
    begin
      imglist.ImageBottomText[imglist.ImageCount - 1] := 'Pic ' + Ndx.ToString;
      imglist.ImageTag[imglist.ImageCount - 1] := Ndx;
    end;
  end;

  imgList.UnlockPaint;

  FileNames.Free;
end;

end.

jctaylor

USA
2 Posts

Posted - Mar 10 2024 :  09:46:55  Show Profile  Reply
Shouldn't before the imgList.UnlockPaint be?:

for Ndx := 0 to FileNames.Count -1 do
  begin
    if ( imglist.MIO.LoadFromFileAuto(FileNames[Ndx]) ) then
    begin
      imglist.ImageBottomText[Ndx] := 'Pic ' + Ndx.ToString;
      imglist.ImageTag[Ndx] := Ndx;
    end;
  end;


John Taylor
Go to Top of Page

xequte

38418 Posts

Posted - Mar 10 2024 :  17:08:48  Show Profile  Reply
Yes, please implement John's code suggestion.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

a.gosling

Germany
3 Posts

Posted - Mar 11 2024 :  02:04:50  Show Profile  Reply
Hi,

thank you for your answer. Unfortunately I get the same wrong result, if I first execute imgList.UnlockPaint and then iterate through the FileNames to set ImageTag and ImageBottomText.

Any other ideas?

edit:
- I'm using Delphi 12.1
- I attached the project



Ansgar Gosling


attach/a.gosling/202431121639_TestImageEN.zip
78.81 KB
Go to Top of Page

xequte

38418 Posts

Posted - Mar 11 2024 :  20:00:14  Show Profile  Reply
Hi Ansgar

If you use LoadFromFileAuto() to add an image to a TImageEnMView, then it is added at the current cursor position (not the end of the list), i.e. index will be 0 not, imglist.ImageCount - 1.

You are better to append the image as follows:

  for Ndx := 0 to FileNames.Count -1 do
  begin
    imglist.AppendImage(FileNames[Ndx]);
    imglist.ImageBottomText[imglist.ImageCount - 1] := 'Pic ' + Ndx.ToString;
    imglist.ImageTag[imglist.ImageCount - 1] := Ndx;
  end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

a.gosling

Germany
3 Posts

Posted - Mar 12 2024 :  02:21:20  Show Profile  Reply
Hi Nigel,

awesome, thanks! Now I got, where the problem is :-)

As I'm now using a slightly different solution, I share this here:
I want to use the LoadFromFileAuto - function, because in the original source (I posted an simple "Reproduce-This-Bug-Project" here ) there are not only images and pdfs in the "FileList". LoadFromFileAuto simply extracts them for me.

My solution ist using
imglist.ImageBottomText[0]


instead of
imglist.ImageBottomText[imglist.ImageCount - 1]



kind regards
Ansgar
Go to Top of Page

xequte

38418 Posts

Posted - Mar 12 2024 :  20:13:08  Show Profile  Reply
Hi Ansgar

Yes, at this time, AppendImage() does not add all images of multi-frame files.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: