encode text to image
Dar Scott
dsc at swcp.com
Wed Aug 30 16:11:42 EDT 2006
On Aug 30, 2006, at 5:20 AM, paolo mazza wrote:
> I imported an image as text (URL file:xxx)
> I wonder if I can convert the text file to binary and set the
> imagedata of
> an image to it
If the image file format is inherently binary, such as PNG or JPEG,
then you should read it as a binary file (URL binfile:). Reading a
binary file as a text file will corrupt it.
If it is really text, then it probably has some header information
that includes the size, and then a bunch of numerals in decimal or
hex. You need to know what its format is.
From that, you can build imageData. If the file has an alpha
channel (transparency) you can also build alphaData.
After you have the image data, set the text of the image to empty
then set the height and width of the image, then set the imageData
(and alphaData). (I'm going by memory; there might be a flaw in that.)
If the image file is really JPEG or PNG then simply set the text of
the image to the value.
Dar Scott
More information about the use-livecode
mailing list