Images in Livecode
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Images in Livecode
They are all good examples but have to agree it spoils the user experience to a large degree. It would be great if you could disable the print screen function, but then I guess they just pull out there phone and 'Click"
Bidge
Bidge
Re: Images in Livecode
Hi again.
I just had a thought. Is there a simplified way to encrypt an image so the average person can't make a copy of it and use it?
That would work in my case more so than water marks etc as I am giving people a load of images with the software.
EDIT: I downloaded the sample encryption stack by Peter Hermsen to test out on a small 200 kb image. It worked perfectly but the downside is that it took forever to process. My images would be a lot larger and I would hate to think how long it might take
Can anyone suggest a faster way of scrambling and unscrambling an image?
Thanks
Bidge
I just had a thought. Is there a simplified way to encrypt an image so the average person can't make a copy of it and use it?
That would work in my case more so than water marks etc as I am giving people a load of images with the software.
EDIT: I downloaded the sample encryption stack by Peter Hermsen to test out on a small 200 kb image. It worked perfectly but the downside is that it took forever to process. My images would be a lot larger and I would hate to think how long it might take
Can anyone suggest a faster way of scrambling and unscrambling an image?
Thanks
Bidge
Re: Images in Livecode
Storing the images as binary data would be perfect and then converting them back to an image when needed except I can't get this to work. I get keep getting scrambled results in the image field?
Bidge
Bidge
Re: Images in Livecode
I am not sure what you are doing in the processing, but one thing to note is that the image destination needs to be resized to the same dimensions as the image you are going to insert before you set the data. That might account for the garbled view.
Re: Images in Livecode
Ahhhh thanks SparkOut. That worked!!!
Cheers
Bidge
Cheers
Bidge
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Images in Livecode
Yet another option, that is very fast and works in LC 6/7/8/9 is as follows
(uses "compress" and "decompress", includes the tip of SparkOut for the size by using "text").
(uses "compress" and "decompress", includes the tip of SparkOut for the size by using "text").
Code: Select all
-- button "compress" : compress and store as custom property
on mouseUp
if there is no img "myImage01" then exit mouseUp
set the cImage01 of this stack to compress(the text of img "myImage01")
set the cImageRect01 of this stack to the rect of img "myImage01"
delete img "myImage01"
end mouseUp
-- button "decompress" : decompress from the custom property
on mouseUp
if there is no img "myImage01" then create img "myImage01"
set the text of img "myImage01" to decompress(the cImage01 of this stack)
set the rect of img "myImage01" to the cImageRect01 of this stack
end mouseUp
shiftLock happens
Re: Images in Livecode
Hi hh.
Just had to go to the dictionary and look up compress. Thank you so much for your code and advice.
Regards
Bidge
Just had to go to the dictionary and look up compress. Thank you so much for your code and advice.
Regards
Bidge
-
- VIP Livecode Opensource Backer
- Posts: 7238
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Images in Livecode
Image files are binary already so there's no need to "convert" them. They can't exist in any other form. Also, the compress funtion is just standard gzip and any OS will unzip the file if the user double-clicks it, so that's not much protection. HH's handlers store the image in the stack itself, which would be safe but I think you wanted to store the images externally.
One thing you might try is reversing one or more byte pairs in the binary file, which would scramble the image somewhat. When your script reads in the data, un-reverse them before putting the data into an image object.
If you want to be really sneaky, compress the image and then reverse two bytes. That way they won't decompress.
One thing you might try is reversing one or more byte pairs in the binary file, which would scramble the image somewhat. When your script reads in the data, un-reverse them before putting the data into an image object.
If you want to be really sneaky, compress the image and then reverse two bytes. That way they won't decompress.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Images in Livecode
Hi jaque.
I saved out a jpg after converting it to a .txt file in LC and then changed the file extension back to jpg manually and nothing would open it at all. What is the reason for this if images are already binary, why will paint programs not open them?
EDIT: Also, I tried to flip a character with this code but I cannot get it to work on an object other than an image?
Bidge
I saved out a jpg after converting it to a .txt file in LC and then changed the file extension back to jpg manually and nothing would open it at all. What is the reason for this if images are already binary, why will paint programs not open them?
EDIT: Also, I tried to flip a character with this code but I cannot get it to work on an object other than an image?
Code: Select all
on mouseUp
flip character 1 of field "Flip" horizontal
end mouseUp
Bidge
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Images in Livecode
Storing binary data in a field may alter it. Read as binary, work on it in a variable, save it back out as binary. Omit textual conversions and you should be fine.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Images in Livecode
[SOLVED] I create the binaries directly from my main stack and that is working.
I have a very ODD problem. I created a little stack to convert my images to binary but when I load the files into my main stack they are warped???? But...if I load them into the same image container in the converter stack they look fine? What could be going wrong?
[MAIN PROBLEM UNSOLVED]
Now I have an even worse problem. My png files when converted to binary are losing their alpha data??????
Can someone please offer some advice on this
Here's the code I am using to convert the images and save them.
EDIT UPDATE: I just tried a transparent gif and still have no transparency. Must be the binary
conversion somehow not including all of the image data???
Bidge
I have a very ODD problem. I created a little stack to convert my images to binary but when I load the files into my main stack they are warped???? But...if I load them into the same image container in the converter stack they look fine? What could be going wrong?
[MAIN PROBLEM UNSOLVED]
Now I have an even worse problem. My png files when converted to binary are losing their alpha data??????
Can someone please offer some advice on this
Here's the code I am using to convert the images and save them.
Code: Select all
on mouseUp
put the imageData of image "Background" of stack "ImageArea" into dateToAnalyze
put dateToAnalyze into field "Field"
ask file "Save to?"
if it is empty then exit mouseUp
put it into tFile
if tFile is empty then
exit mouseUp
else
put field "Field" into pRec
put pRec into URL ("file:" & tFile)
end if
end mouseUp
conversion somehow not including all of the image data???
Bidge
Re: Images in Livecode
Hi David,
what Richard wrote:
...
put the imageData of image "Background" of stack "ImageArea" into dateToAnalyze
put dateToAnalyze into field "Field"
...
put field "Field" into pRec
put pRec into URL ("file:" & tFile)
...
Field = Text <> BINARY
So in your script you wreck the binary data two times, congrats!
Best
Klaus
what Richard wrote:
What you do nevertheless:Storing binary data in a field may alter it. Read as binary, work on it in a variable, save it back out as binary. Omit textual conversions and you should be fine.
...
put the imageData of image "Background" of stack "ImageArea" into dateToAnalyze
put dateToAnalyze into field "Field"
...
put field "Field" into pRec
put pRec into URL ("file:" & tFile)
...
Field = Text <> BINARY
So in your script you wreck the binary data two times, congrats!
Best
Klaus
Re: Images in Livecode
Thanks Klaus. I will try again in the morning.
Bidge
Bidge
Re: Images in Livecode
[SOLVED]
Ok...I tried losing the field as suggested and still no alpha data loads.
EDIT: A simple experiment of moving one image to another image
via storing in variable results in Alpha Channel loss to data:
Just looking at the dictionary,. should I be using the binary encode decode functions for png's?
How do I do this?
Thanks for any help.
Bidge
Code: Select all
put the imageData of image "Image" into tIm
put the alphaData of image "Image" into tImB
set the imageData of image "Image3" to tIm
set the alphaData of image "Image3" to tImB
Ok...I tried losing the field as suggested and still no alpha data loads.
EDIT: A simple experiment of moving one image to another image
via storing in variable results in Alpha Channel loss to data:
Code: Select all
on mouseUp
put the imageData of image "Image" into tIm
set the imageData of image "Image3" to tIm
end mouseUp
How do I do this?
Thanks for any help.
Bidge
Re: Images in Livecode
Hi.
I managed to solve the AlphaData issue but now I need to learn how to save
2 types of data into 1 file, alphaData and imageData and also retrieve them separately so they can be applied to the image.
I have only ever saved something as a combined file?
EDIT:
Please cut me a little slack here as I don't know a lot about how arrays work. I have been looking at examples all day and it can get rather
confusing with all the different takes on codes. I found a basic lesson on arrays but they only save and load one bit of data. In this case I need to save and retrieve 2 x blocks separately. I know this code is not correct but it was a start.
Loading:
Thanks for the help
Bidge
I managed to solve the AlphaData issue but now I need to learn how to save
2 types of data into 1 file, alphaData and imageData and also retrieve them separately so they can be applied to the image.
I have only ever saved something as a combined file?
EDIT:
Please cut me a little slack here as I don't know a lot about how arrays work. I have been looking at examples all day and it can get rather
confusing with all the different takes on codes. I found a basic lesson on arrays but they only save and load one bit of data. In this case I need to save and retrieve 2 x blocks separately. I know this code is not correct but it was a start.
Code: Select all
on mouseUp
ask file "Save to?"
if it is empty then exit mouseUp
put it into tFile
if tFile is empty then
exit mouseUp
else
put the imageData of image "Background" of stack "ImageArea" into myBox["ImData"]
put the alphaData of image "Background" of stack "ImageArea" into myBox["AlphData"]
put myBox["ImData"] into URL ("file:" & tFile)
put myBox["AlphData"] into URL ("file:" & tFile)
end if
end mouseUp
Code: Select all
on mouseUp
answer file "Please choose file to load" with type "Text File|txt"
if the result is "Cancel" then exit mouseUp
else
if it is not empty then
put it into myBox
put the imageData of image "Background" of stack "ImageArea" into myBox["ImData"]
put the imageData of image "Background" of stack "ImageArea" into myBox["AlphData"]
then exit mouseUp
end if
end if
end mouseUp
Bidge