Saving a field containing text and images

Stephen Barncard stephenREVOLUTION at barncard.com
Sat Aug 25 11:59:12 EDT 2007


It's possible but complicated. I don't know if you need a document 
readable by something else, but if it's all to be saved and loaded by 
your app, it can be done.

I've experimented with with saving all fields and images in a group 
as text descriptions.

to keep the size down, all images are referenced rather than actually 
hold image data.

1. I get all the properties of the object into an array, and fix the 
returns that are in certain properties (like colors) to some other 
character.
2. Then I flatten the array to a list with combine.
3. Base64Encode the list
4. Replace the returns in the Base64 encoded list with linefeeds
5. this results in a single line
6  Add  a key identifying what the object is (field, image, etc) & 
tab and then the data
7. Build the list with other objects, one per line
8. save as a single text file. This will be very small.

By saving all the properties, you are also saving the HTMLtext and 
rect information.
If the images have been resized, you also may have to save a line of 
actual rects and resize upon expanding.

On expanding, all the fields and images are recreated and the saved 
properties expanded (reverse of above) and applied to the created 
objects, and they will be arranged exactly as you saved them. The 
Base64 encoded text does not have to have the returns restored; it 
reads sections by number of characters, not delimiter.

this former theory has been tested and works. It's also really fast 
with text fields, images take a little longer to 'decode', but 
totally acceptable for say, a labeler or something.

sqb



>
>Thanks for your quick answer, as usual.
>I've made some testing by saving the field's htmlText , but after 
>that you need to export all the images and it can lead to the 
>creation of a huge number of files.
>I'd prefered saving all in a rtf, but here I don't know how to do 
>it. Do you you if something like that is possible?
>

-- 


stephen barncard
s a n  f r a n c i s c o
- - -  - - - - - - - - -






More information about the use-livecode mailing list