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
 FillFromDirectory works MIO.LoadFromFiles fails ..
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Greg Lumley

South Africa
8 Posts

Posted - May 30 2012 :  14:13:41  Show Profile  Reply
First of all please bear with me, I'm very very new to Delphi!

I'm building an app whereby users can select images, it's all going well but now I want them to be able to filter only the selected images from the database, so building a string I'm using the ImageEnMView.MIO.LoadFromFiles method which does load the files successfully to the thumbgrid but now, ImageEnMView1.ImageFileName[0] no longer returns the filename which I'm using as a unique key in an sqlite db... of course all this causes the SQL statement to fail... like I said please bear with me I'm still figuring this all out...


//ImageEnMView1.FillFromDirectory(DirectoryListBox1.Directory); //All working perfectly with this line.
 ImageEnMView1.MIO.LoadFromFiles('dacl_f_00053.jpg|dacl_f_00057.jpg|dacl_f_00058.jpg|dacl_f_00059.jpg');//No longer returns the file name with this line...


Thank you for your assistance ;-)


Greg.

fab

1310 Posts

Posted - May 30 2012 :  22:57:44  Show Profile  Reply
They are two very different ways to present images in TImageEnMView.
Setting ImageFileName[] tells TImageEnMView to load the image only when it is actually necessary. It is not an informative tag.
For example FillFromDirectory just fills ImageFileName[] with the file names to load (when necessary).
Instead TImageEnMView.MIO.LoadFromFile (and other TImageEnMView.MIO... methods ) actually loads one o more images immediately. It doesn't populate ImageFileName[], because images are loaded, even they aren't displayed.
Go to Top of Page

Greg Lumley

South Africa
8 Posts

Posted - May 31 2012 :  01:03:36  Show Profile  Reply
Hi Fabrizio, thank you for your answer... but I'm still hazy.

Perhaps if I show you my code (modified from the EnImageExamples)



ImageEnMView1.Clear;
ImageEnMView1.FillFromDirectory(DirectoryListBox1.Directory);

  ImageEnMView1.SelectedImage := 0;
  ShowMessage(ImageEnMView1.ImageFileName[0]);//This displays the file name 
  ImageEnView1.io.LoadFromFile(ImageEnMView1.ImageFileName[0]);

  //Load the main image variable as well as the label
  pub_currentimagename :=   ExtractFileName(ImageEnMview1.ImageFileName[0]) ;
  self.lbl_currentimage.Caption :=  pub_currentImageName;



Further on in the code if a user selects an image its entered as a new row in the sqlite db...

My next step is to allow the user to see what he/she has selected so far so instead of loading the directory I'd like to load only the selection from the database as a string...

Below is what I tried when it failed...


  ImageEnMView1.Clear;

  ImageEnMView1.MIO.LoadFromFiles('dacl_f_00058.jpg|dacl_f_00059.jpg');//A test string before dynamically generating from db.
  ImageEnMView1.SelectedImage := 0;
  ShowMessage(ImageEnMView1.ImageFileName[0]);// <-- it's now empty, "loadfromdirectory" autopopulates it but not LoadFromFile
  ImageEnView1.io.LoadFromFile(ImageEnMView1.ImageFileName[0]);
  pub_currentimagename :=   ExtractFileName(ImageEnMview1.ImageFileName[0]) ;
  self.lbl_currentimage.Caption :=  pub_currentImageName;


What would you do to fix it?

Thank you!

Greg.

Greg.
Go to Top of Page

fab

1310 Posts

Posted - May 31 2012 :  02:04:13  Show Profile  Reply
...
ImageEnMView1.MIO.LoadFromFiles('dacl_f_00058.jpg|dacl_f_00059.jpg');//A test string before dynamically generating from db.
  ImageEnMView1.SelectedImage := 0;
  ShowMessage(ImageEnMView1.ImageFileName[0]);// <-- it's now empty, "loadfromdirectory" autopopulates it but not LoadFromFile


yes, but this is exactly what I explained you. LoadFromFile doesn't populate ImageFileName[]!
If you have an array of filenames and you want to load them without LoadFromFiles, just write:

ImageEnMView1.Clear();
ImageEnMView1.ImageFileName[ ImageEnMView1.AppendImage() ] := 'dacl_f_00058.jpg';
ImageEnMView1.ImageFileName[ ImageEnMView1.AppendImage() ] := 'dacl_f_00059.jpg';
etc...
Go to Top of Page

Greg Lumley

South Africa
8 Posts

Posted - May 31 2012 :  08:41:32  Show Profile  Reply
Hi Fabrizio, I'm not going to lie... I'm hacking here! I'm from a self taught PHP background, I stopped 7 years ago and I'm now a professional photographer (I'm far better at that!) when I coded for a living I tried to teach myself good habits not always managing... you might as well have spoken Japanese there for a moment.. it went over my head ;-)

Thank you for code it works perfectly and I'll probably be able to convert that Japanese to English as a result!

Your help is much appreciated!

Greg.

Greg.
Go to Top of Page

Greg Lumley

South Africa
8 Posts

Posted - May 31 2012 :  08:44:26  Show Profile  Reply
Fabrizio, I just re-read your original post... it was a case of paying attention on my part, it's very very clear! I feel like a bit of an idiot here... thanks for helping me anyway!

G

Greg.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: