Image peculiarity...

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Image peculiarity...

Post by bogs » Fri Apr 20, 2018 10:51 pm

I have one that has me stumped. I was creating a small picture demo to explore different aspects of handling, well, pictures.
Picture information demo..._006.png
Image Data button puts the image everywhere.
I first imported as a control the original image on the far right, then I wrote for the "Image Text" button -

Code: Select all

on mouseUp
   put the text of image "imgOriginal" into image "imgOne"
   put the text of image "imgOne" into image "imgTwo"
   put the text of image "imgTwo" into image "imgThree"
   put the text of image "imgThree" into image "imgFour"
end mouseUp
This worked just fine, so I moved onto the "Image Data" button, and again, that worked out fine. Then I decided to add the ability to change the picture since I don't always work on the same machine or even the same os, so I wrote this for the original image -

Code: Select all

on mouseUp
   answer files "Select the image you wish to view:" with type ("Image files|jpg,jpeg,JPEG,JFIF,png")
   if the result is not "" then
      set the fileName of image "imgOriginal" to it
   else
   end if
end mouseUp
And that works fine for changing the picture in the original image slot, but now the image text button doesn't work. On top of that, if I put "the text of imgOriginal" into a variable, the variable comes up empty.
Selection_007.png
Image Text gives me nothing
Using the "Image Data" button still puts the imageData from image to image, so I know there is an image there, but I can't seem to put the text of the image anywhere, and this all started with opening a file into the image control instead of importing an image as a control.

Can anyone explain that?
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9647
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Image peculiarity...

Post by dunbarx » Fri Apr 20, 2018 11:00 pm

Answer files? Does adding that 's" work"

Anyway, not sure, but does this require getting the binary instead of text data?

Craig Newman

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Image peculiarity...

Post by bogs » Sat Apr 21, 2018 4:29 am

Yes, the answer files actually does work, it loads the image into image "imgOriginal" just fine. I thought that once an picture was in an image control, you could then use the text of the image in the control.
Image

Klaus
Posts: 13821
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Image peculiarity...

Post by Klaus » Sat Apr 21, 2018 12:54 pm

For referenced images "the text of img xyz" = EMPTY!
For imported images this property is actually the data displayed inside of the image.

And you are not using the official syntax, either:
...
put img 1 into img 2
...
or (see above)
...
set the text of img 2 to the text of img 1
...
Yes, I know this is highly nitpicking, but over the years I found that the engine is less forgiving with every version when it comes to "correct" syntax!

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Image peculiarity...

Post by bogs » Sat Apr 21, 2018 2:33 pm

The engines nit-pickiness I don't think is a factor, I'm playing with this in 2,3,6, 7, and 8.
Klaus wrote:
Sat Apr 21, 2018 12:54 pm
And you are not using the official syntax, either:
Hmm, from everything I found about putting and setting the text of an image, the syntax looked right to me, however, I had also tried the statements you listed and those did not work either, which leads me to this -
Klaus wrote:
Sat Apr 21, 2018 12:54 pm
For referenced images "the text of img xyz" = EMPTY!
For imported images this property is actually the data displayed inside of the image.
So, whether referenced or not, is not the image object holding the picture? This is the behavior I am seeing, but would like to know the explanation behind it if you could, since I didn't find any reference explaining it myself.

*Edit - thanks to Klaus's explanation, even though I don't understand the *why* yet, I did add this line to the code which corrected the issue.

Code: Select all

on mouseUp
   export image "imgOriginal" to image "imgOriginal"
    // exporting it to itself seems to correct the lack of text...
   put the text of image "imgOriginal" into image "imgOne"
   put the text of image "imgOne" into image "imgTwo"
   put the text of image "imgTwo" into image "imgThree"
   put the text of image "imgThree" into image "imgFour"
end mouseUp
Selection_003.png
Image Text working after using "export image"...
Last edited by bogs on Sat Apr 21, 2018 3:06 pm, edited 1 time in total.
Image

Klaus
Posts: 13821
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Image peculiarity...

Post by Klaus » Sat Apr 21, 2018 3:02 pm

I did not say that using the "official" syntax is the solution here, that was just a recommendation! :-)

Unfortunately I cannot explain what the text iof img 1 is empty when referenced.
I just remember that I read this somewhere, sorry.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Image peculiarity...

Post by bogs » Sat Apr 21, 2018 3:08 pm

Oh don't be, Klaus, you just saved me from the last 3 days of banging my head trying to figure it out with what you did provide.

Hopefully someone who knows will chime in, I love the answers to *why*, not just the ones that let me *do* :wink:
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9647
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Image peculiarity...

Post by dunbarx » Sat Apr 21, 2018 4:28 pm

Bogs. :)

Baby. :D

You think I don't know that "answer files" is a native command? 8)

Look carefully, however, at: "answers files". :evil:

Craig. :wink:

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Image peculiarity...

Post by jacque » Sat Apr 21, 2018 5:15 pm

My take on it: the text of an image is the binary data stored in the stack which is saved for imported images. ImageData is the pixel/visual representation of the image on screen. Both imported and referenced images have imageData. Only imported images have text.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Image peculiarity...

Post by bogs » Sat Apr 21, 2018 6:08 pm

dunbarx wrote:
Sat Apr 21, 2018 4:28 pm
You think I don't know that "answer files" is a native command?
...
Look carefully, however, at: "answers files".
You might, I was surprised that what was essentially a typo worked, I didn't notice it till you pointed it out :)
"answers files" :?: Ok, now I am confused :P
jacque wrote:
Sat Apr 21, 2018 5:15 pm
Only imported images have text.
So, the image object itself doesn't control whether the image has text? And when you export a referenced image in an image object back to itself, that...ok, I'm lost :shock: ...does what, imports the image? Converts it somehow? Overlays it? The dictionary doesn't make it very clear, neither did the user guide, both just mention 'the text of the image', which I assumed was a reference to the object, not the actual picture.
Image

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Image peculiarity...

Post by bogs » Sat Apr 21, 2018 7:55 pm

Well, the most complete reference I could find on it came from 2.x's documentation (still reading through it), but it essentially says what Jacque and Klaus said.
Images
Images, like fields and buttons, are containers that are part of a stack and are saved with the stack. Unlike fields and buttons, however, images hold binary data instead of text.

The content of an image is the raw binary data that makes up the picture in an image. If you understand the format that the image is in, you can analyze or alter the image by using the put command to change portions of the data in the image.

The content of a referenced image is empty, because the picture is stored in a separate file instead of in the image object.

Note: To access or change an image's content, the stack that includes the image must be open or be loaded into memory.
Which is still very confusing to me, I must be dense today. Where did I put my dunce cap again....

*Edit, I did finally find the rest of the information about it, but am keeping my dunce cap close by :P
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”