Page 1 of 2

importing pictures into a data grid

Posted: Sat Mar 08, 2014 11:10 pm
by tyarmsteadBUSuSfT
Hello,
I am wrestling with importing a picture into a thumbnail of a data grid. The user would take a picture the app imports the view in to the app. The user then types a description and other data then saves it. The save button saves the info to a text file. Upon going to the data grid the data grid loads and displays the contents of the file. I can populate all of the text fields but not the image.
on FillInData pDataArray
set the text of field "EntryDate" of me to pDataArray["Date"]
set the text of field "lon" of me to pDataArray["Ion"]
set the text of field "lat" of me to pDataArray["lat"]
set the text of field "Category" of me to pDataArray["category"]
set the text of field "ItemName" of me to pDataArray["itemname"]
set the text of field "ItemDesc" of me to pDataArray["ItemDesc"]
set the hilited of button "save location" of me to (pDataArray["saveLoc"] is "true")
set the hilited of button "HIgh Rank" of me to (pDataArray["High"] is "true")
set the hilited of button "Med Rank" of me to (pDataArray["Med"] is "true")
set the hilited of button "Low Rank" of me to (pDataArray["Low"] is "true")
set the text of field "Seq Numb" of me to pDataArray["SeqNumb"]
set the text of image "itemimage"of me to pDataArray["picture"]
end FillInData
The Show Item Detail is:
on ShowItemDetail
global gSeqNumb
go to card "ItemEntry"
set itemDel to tab
put url ("file:" & specialFolderPath("documents") & "/ItemList.txt")  into tItem
repeat with x = 1 to the number of lines in tItem
if item 1 of line x of tItem is gSeqNumb then
set the text of field "ItemName" to item 2 of line x of tItem
set the text of field "itemDesc" to item 3 of line x of tItem
set the text of field "Category" to item 5 of line x of tItem
set the text of field "EntryDate" to item 4 of line x of tItem
set the text of field "lat" to item 6 of line x of tItem
set the text of field "lon" to item 7 of line x of tItem
set the text of field "ItemImage" to item 8 of line x of tItem
if item 9 of line x of tItem is "true" then
set the hilited of button "high rank" to "true"
else set the hilited of button "high rank" to "false"
if item 10 of line x of tItem is "True" then
set the hilited of button "Med rank" to "True"
else set the hilited of button "med rank" to "false"
if item 11 of line x of tItem is "True" then
set the hilited of button "low rank" to "true"
else set the hilited of button "low rank" to "false"
if item 12of line x of tItem is "True" then
set the hilited of button "save location" to "true"
else set the hilited of button "save location" to "false"
end if
end repeat
end ShowItemDetail
I am unable to get the item to display. Iv'e tried so many ways I have confused myself.
Thank you
Ty

Re: importing pictures into a data grid

Posted: Sun Mar 09, 2014 12:26 am
by Klaus
Hi Ty,

where and how do you save the image?
set the text of image "itemimage"of me to pDataArray["picture"]
What is in pDataArray["picture"]?
Maybe you want to set the filename, if pDataArray["picture"] contains a path to the image?


Best

Klaus

Re: importing pictures into a data grid

Posted: Sun Mar 09, 2014 4:04 pm
by tyarmsteadBUSuSfT
Klaus,
That is correct that the path name is in the pDataArray["picture"]. The test picture is saved in the documents folder.
Ty

Re: importing pictures into a data grid

Posted: Sun Mar 09, 2014 4:13 pm
by Klaus
Hi Ty,

AHA! :D

Well, then this should do the trick:
...
set the filename of image "itemimage" of me to pDataArray["picture"]
## Optional: Adjust image dimensions...
...


Best

Klaus

Re: importing pictures into a data grid

Posted: Sun Mar 09, 2014 5:30 pm
by tyarmsteadBUSuSfT
Klaus,
I'm using this to test:
put url ("binfile:" & specialfolderpath( "documents") & slash & "Oscar.jpg") into tImageID
then putting tImageID into the data ray, then in the fillindata script using your code, but I 'm just getting an empty image.
Ty

Re: importing pictures into a data grid

Posted: Sun Mar 09, 2014 6:02 pm
by Klaus
Hi Ty,
tyarmsteadBUSuSfT wrote:Klaus,
That is correct that the path name is in the pDataArray["picture"]. The test picture is saved in the documents folder.
tyarmsteadBUSuSfT wrote:Klaus,
I'm using this to test:
put url ("binfile:" & specialfolderpath( "documents") & slash & "Oscar.jpg") into tImageID
then putting tImageID into the data ray, then in the fillindata script using your code, but I 'm just getting an empty image.
hm, what do you want to do:
1. set the filename or
2. put the binary image data into the image? :D

I would prefer the filename, less memory consuming, so my first proposal should work:

Code: Select all

on fillinData
  ...
  set the filename of image "itemimage" of me to pDataArray["picture"]
  ...
end fillinData
put url ("binfile:" & specialfolderpath( "documents") & slash & "Oscar.jpg") into tImageID
Here you are putting th binary image data into the variable, but later, using my cript, you set the filename!

Do this for testing with my code:
...
put specialfolderpath( "documents") & slash & "Oscar.jpg" into tImageID
...

Best

Klaus

Re: importing pictures into a data grid

Posted: Sun Mar 09, 2014 6:06 pm
by jmburnod
Hi,
Klaus suggest the filename, not files's data
What happens if you use file instead binfile.

Code: Select all

put url ("file:" & specialfolderpath( "documents") & slash & "Oscar.jpg") into tImageID
and after

Code: Select all

set the filename of image "itemimage" of me to tImageID


Best regards
Jean-Marc

Re: importing pictures into a data grid

Posted: Sun Mar 09, 2014 7:46 pm
by tyarmsteadBUSuSfT
Klau and Jean-Marc,
It works!! Thank you very much.
Ty

Re: importing pictures into a data grid

Posted: Mon Mar 10, 2014 8:07 pm
by jmburnod
Hi Ty,

Do you think post an exemple ?
That should be useful for others

Best regards
Jean-Marc

Re: importing pictures into a data grid

Posted: Mon Mar 10, 2014 11:46 pm
by tyarmsteadBUSuSfT
Sure, do you mean an example of the code?

Re: importing pictures into a data grid

Posted: Tue Mar 11, 2014 1:16 pm
by jmburnod
Hi Ty
A little stack would be better to illustrate but code is also useful :D
Best regards

Re: importing pictures into a data grid

Posted: Tue May 27, 2014 2:35 am
by tyarmsteadBUSuSfT
I was going to include a stake showing how this worked, but when i recently upgraded to the version 7, now the pictures display very distoreted. Did something changed with the export images functionality?
Thanks
Ty

Re: importing pictures into a data grid

Posted: Tue May 27, 2014 5:27 pm
by Klaus
Hi Ty,
tyarmsteadBUSuSfT wrote:I was going to include a stake showing how this worked, but when i recently upgraded to the version 7, now the pictures display very distoreted. Did something changed with the export images functionality?
no, nothing has changed so far, but all versions >= 6.7x are still DEVELOPER PREVIEWS! :D

Here a little hint about saving a lot of typing by using BOOLEan values effectively!
Instead of this:
...
if item 9 of line x of tItem is "true" then
set the hilited of button "high rank" to "true"
else set the hilited of button "high rank" to "false"
...
Do this:
...
set the hilite of button "high rank" to (item 9 of tLine = "true")
...
The engine will evaluate the expression in parens and do exactly what you want :D


Best

Klaus

Re: importing pictures into a data grid

Posted: Tue May 27, 2014 6:19 pm
by tyarmsteadBUSuSfT
Thank for that suggestion. One last question, is there a way to go back to a previous
version of LiveCode?
Ty

Re: importing pictures into a data grid

Posted: Tue May 27, 2014 6:41 pm
by Klaus