Is there any picture there?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Is there any picture there?
How do you test if an image contains a picture or not?
all the usual suspects
empty <>= contains "" size either show nothing or 0
I have looked through the dict and user and other examples with images, but found nothing.
Any ideas?
all the usual suspects
empty <>= contains "" size either show nothing or 0
I have looked through the dict and user and other examples with images, but found nothing.
Any ideas?
Hi user....
At some point, you have to set the text, filename, imagedata, maskdata, or whatever. Whenever you do this, you could also set a special property, e.g. cHiIContainAPictureThankYouVeryMuch. Whenever you add a picture, set the cHiIContainAPictureThankYouVeryMuch to a file path or picture name; whenever you delete the imagedata or filename you set the cHiIContainAPictureThankYouVeryMuch to empty again. That way, you will always know whether your image object contains a picture.
You might even write a handler like this:
or
It might also be possible to check the formattedHeight and formattedWidth, but I don't know by heart right now what these properties report if an image object is empty.
Best,
Mark
At some point, you have to set the text, filename, imagedata, maskdata, or whatever. Whenever you do this, you could also set a special property, e.g. cHiIContainAPictureThankYouVeryMuch. Whenever you add a picture, set the cHiIContainAPictureThankYouVeryMuch to a file path or picture name; whenever you delete the imagedata or filename you set the cHiIContainAPictureThankYouVeryMuch to empty again. That way, you will always know whether your image object contains a picture.
You might even write a handler like this:
Code: Select all
setProp cHiIContainAPictureThankYouVeryMuch theFilename
set the filename of the target to theFileName
pass cHiIContainAPictureThankYouVeryMuch
end cHiIContainAPictureThankYouVeryMuch
Code: Select all
setProp cHiIContainAPictureThankYouVeryMuch theText
set the text of the target to theText
lock messages
set the cHiIContainAPictureThankYouVeryMuch of the target to empty
unlock messages
end cHiIContainAPictureThankYouVeryMuch
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
you can do:
returns true to the message box if image is empty
regards
Bernd
Code: Select all
put image "yourImageName" = empty
regards
Bernd
Thanks Mark, I was wide of the target on this. I have taken Filename as only a "name of a file" not the content of a container.
Anyway, It is so much clearer now.
The issue was to check if the user remembered to add a photo with his text. I wanted to test if pic + text + radio buttons were set before processing, so setting a flag would not help, because the image holder would be there empty or full. All fields, containers and radio buttons are cleared on processing.
Anyway, thank you again.
Anyway, It is so much clearer now.
The issue was to check if the user remembered to add a photo with his text. I wanted to test if pic + text + radio buttons were set before processing, so setting a flag would not help, because the image holder would be there empty or full. All fields, containers and radio buttons are cleared on processing.
Anyway, thank you again.
Hi Bernd,
Your suggestion doesn't work with filenames, but if User consistently uses the text property of image objects, then it should work fine.
Best,
Mark
Your suggestion doesn't work with filenames, but if User consistently uses the text property of image objects, then it should work fine.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
thanks Mark for pointing this out,
it is a little tricky how Rev treats images that you either reference by a filename or create by setting the text of an image or by manually painting into them for that matter.
So make thatThat should take care of an empty image and of an image that is referenced through a filename (if only testing for image = empty it would return true if the image is referenced by a filename, and actually not "empty" at all.
regards
Bernd
it is a little tricky how Rev treats images that you either reference by a filename or create by setting the text of an image or by manually painting into them for that matter.
So make that
Code: Select all
put (image "myImageName" = empty) and (the filename of image "myImageName" = "")
regards
Bernd
user#606,
if you want to make thumbnails and you want to use and image object for this, one thing to watch out for is that even if you set the thumbnail to a smaller size than the original image all the information in the thumbnail is that of the original image. That is the filesize is not reduced.
You can see the effect if you set the text of image 2 to the text of image 1. Than you reduce the size of image 2 manually. Create a new card go that card and come back to the card with image 2 on it. If image 2 was not locked in size (in the inspector) it will be of the original proportions of image 1.
To get around it you can do the following:
So effectively setting the imageData of image 2 to its own imageData reduces the image to the thumbnail size with regards to its true (as shown) width and height.
may be you know all this but if you dont it can be puzzling and well you dont get the lower file size you are looking for in the thumbnail.
regards
Bernd
if you want to make thumbnails and you want to use and image object for this, one thing to watch out for is that even if you set the thumbnail to a smaller size than the original image all the information in the thumbnail is that of the original image. That is the filesize is not reduced.
You can see the effect if you set the text of image 2 to the text of image 1. Than you reduce the size of image 2 manually. Create a new card go that card and come back to the card with image 2 on it. If image 2 was not locked in size (in the inspector) it will be of the original proportions of image 1.
To get around it you can do the following:
Code: Select all
set the imageData of image 2 to the imageData of image 2
may be you know all this but if you dont it can be puzzling and well you dont get the lower file size you are looking for in the thumbnail.
regards
Bernd
user#606,
more to the point of what I was saying about thumbnails is this script:
if you try this you see what I mean
if you for your thumbnail you go this way you save the snapshot bit (which is a very handy features)
You could also create the thumbnail to a hidden image p2 if you dont want it to be seen.
regards
Bernd
edited to take into account images that are references to files
As Mark pointed out above
more to the point of what I was saying about thumbnails is this script:
Code: Select all
on mouseUp
-- lets have an image P1 and P2, P2 is supposed to be a thumbnail of P1
-- assume you have set the lockloc of image p2 to true in the inspector
-- lockloc is the same as lock size and position in "size and position" of the inspector
-- first we test whether it is a referenced image that has a filename
put the filename of image "p1" into tfileName
if tFileName <> "" then -- has a filename
set the imageData of image "p1" to the imageData of image "p1"
put the text of image "p1" into tImageText
set the filename of image "p1" to tfileName
else -- has no filename
put the text of image "p1" into tImageText
end if
put the width of image "p1" into twidth
put the height of image "p1" into theight
put 120 into tNewHeight
put tNewHeight / theight into tfactor
-- no need to round() for decimals, Rev does it for you in this case
-- tNewWidth scales the width of the image proportionaly down (or up)
-- depending on tNewHeight.
put twidth * tfactor into tNewWidth
set the text of image "p2" to tImageText
set the width of image "p2" to tNewWidth
set the height of image "p2" to tNewHeight
-- until now it is just a resize without really changing the original
-- dimensions, they are still there so if you take the image information
-- you would get an image of the original size
-- take this out after testing
put "image size after resizing before 'set imageData ... to imageData'" && length(text of image "p2") & return
-- this reduces the size of the image to the thumbnail dimensions permanently
set the imageData of image "p2" to the imageData of image "p2"
-- take this out after testing
put "image size after resizing – after– 'set imageData ... to imageData'" && length(text of image "p2") after msg
end mouseUp
if you for your thumbnail you go this way you save the snapshot bit (which is a very handy features)
You could also create the thumbnail to a hidden image p2 if you dont want it to be seen.
regards
Bernd
edited to take into account images that are references to files
As Mark pointed out above