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
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
Post
by bidgeeman » Mon Aug 07, 2017 12:17 am
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
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
Post
by bidgeeman » Mon Aug 07, 2017 1:28 am
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
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
Post
by bidgeeman » Mon Aug 07, 2017 4:56 am
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
-
SparkOut
- Posts: 2947
- Joined: Sun Sep 23, 2007 4:58 pm
Post
by SparkOut » Mon Aug 07, 2017 7:28 am
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.
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
Post
by bidgeeman » Mon Aug 07, 2017 7:51 am
Ahhhh thanks SparkOut. That worked!!!
Cheers
Bidge
-
[-hh]
- VIP Livecode Opensource Backer

- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
Post
by [-hh] » Mon Aug 07, 2017 12:35 pm
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").
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
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
Post
by bidgeeman » Mon Aug 07, 2017 12:51 pm
Hi hh.
Just had to go to the dictionary and look up compress. Thank you so much for your code and advice.
Regards
Bidge
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7393
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Mon Aug 07, 2017 9:10 pm
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
Post
by bidgeeman » Tue Aug 08, 2017 1:03 am
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?
Code: Select all
on mouseUp
flip character 1 of field "Flip" horizontal
end mouseUp
Bidge
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
-
Contact:
Post
by FourthWorld » Tue Aug 08, 2017 3:21 am
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.
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
Post
by bidgeeman » Tue Aug 08, 2017 4:45 am
[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.
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
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
-
Attachments
-

- Image on right before converted to binary. Image on left after. Transparency is gone from center.
-
Klaus
- Posts: 14198
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Tue Aug 08, 2017 2:39 pm
Hi David,
what Richard wrote:
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.
What you do nevertheless:
...
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
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
Post
by bidgeeman » Tue Aug 08, 2017 2:56 pm
Thanks Klaus. I will try again in the morning.
Bidge
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
Post
by bidgeeman » Wed Aug 09, 2017 3:07 am
[SOLVED]
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
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
-
bidgeeman
- Posts: 495
- Joined: Wed Feb 21, 2007 7:58 am
Post
by bidgeeman » Wed Aug 09, 2017 4:31 am
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.
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
Loading:
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
Thanks for the help
Bidge