importing pictures into a data grid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
importing pictures into a data grid
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
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
Hi Ty,
where and how do you save the image?
Maybe you want to set the filename, if pDataArray["picture"] contains a path to the image?
Best
Klaus
where and how do you save the image?
What is in pDataArray["picture"]?set the text of image "itemimage"of me to pDataArray["picture"]
Maybe you want to set the filename, if pDataArray["picture"] contains a path to the image?
Best
Klaus
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: importing pictures into a data grid
Klaus,
That is correct that the path name is in the pDataArray["picture"]. The test picture is saved in the documents folder.
Ty
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
Hi Ty,
AHA!
Well, then this should do the trick:
...
set the filename of image "itemimage" of me to pDataArray["picture"]
## Optional: Adjust image dimensions...
...
Best
Klaus
AHA!
Well, then this should do the trick:
...
set the filename of image "itemimage" of me to pDataArray["picture"]
## Optional: Adjust image dimensions...
...
Best
Klaus
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: importing pictures into a data grid
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
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
Hi Ty,
1. set the filename or
2. put the binary image data into the image?
I would prefer the filename, less memory consuming, so my first proposal should work:
Do this for testing with my code:
...
put specialfolderpath( "documents") & slash & "Oscar.jpg" into tImageID
...
Best
Klaus
tyarmsteadBUSuSfT wrote:Klaus,
That is correct that the path name is in the pDataArray["picture"]. The test picture is saved in the documents folder.
hm, what do you want to do: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.
1. set the filename or
2. put the binary image data into the image?
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
Here you are putting th binary image data into the variable, but later, using my cript, you set the filename!put url ("binfile:" & specialfolderpath( "documents") & slash & "Oscar.jpg") into tImageID
Do this for testing with my code:
...
put specialfolderpath( "documents") & slash & "Oscar.jpg" into tImageID
...
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: importing pictures into a data grid
Hi,
Klaus suggest the filename, not files's data
What happens if you use file instead binfile.
and after
Best regards
Jean-Marc
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
Code: Select all
set the filename of image "itemimage" of me to tImageID
Best regards
Jean-Marc
https://alternatic.ch
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: importing pictures into a data grid
Klau and Jean-Marc,
It works!! Thank you very much.
Ty
It works!! Thank you very much.
Ty
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: importing pictures into a data grid
Hi Ty,
Do you think post an exemple ?
That should be useful for others
Best regards
Jean-Marc
Do you think post an exemple ?
That should be useful for others
Best regards
Jean-Marc
https://alternatic.ch
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: importing pictures into a data grid
Sure, do you mean an example of the code?
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: importing pictures into a data grid
Hi Ty
A little stack would be better to illustrate but code is also useful
Best regards
A little stack would be better to illustrate but code is also useful
Best regards
https://alternatic.ch
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: importing pictures into a data grid
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
Thanks
Ty
Re: importing pictures into a data grid
Hi Ty,
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
Best
Klaus
no, nothing has changed so far, but all versions >= 6.7x are still DEVELOPER PREVIEWS!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?
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
Best
Klaus
-
- Posts: 151
- Joined: Sat Aug 25, 2012 1:14 am
Re: importing pictures into a data grid
Thank for that suggestion. One last question, is there a way to go back to a previous
version of LiveCode?
Ty
version of LiveCode?
Ty