Imagedata row order

Rob Cozens rcozens at pon.net
Tue Jul 25 11:03:34 EDT 2006


Dar, Jacque, et al:

Following is based on (a) what I've read about imageData from Rev 
Dictionary, (b) what I've learned about imageData in personal 
testing, and (c) what I THINK I know about imageData based on 
conclusions drawn from (a) & (b):

* Rev. Dictionary:  "Revolution supports GIF, JPEG, PNG, PICT, BMP, 
PBM/PGM/PPM, and XBM/XPM/XWD formats, as well as its own internal 
format".  My presumption is (untested)  the "internal format", 
designated as "rle" in the image's paintCompression property, is the 
format used for imageData  [4 bytes per pixel:  null, red, green, 
blue].

*  Rev Dictionary: "Because most picture formats include compression, 
the content of an image is normally smaller than its imageData 
property."  My presumption is (untested) that if an image has never 
been resized since created in rle format, the image's text & 
imageData properties will be identical. [ I would also note the 
Dictionary is likely to be incorrect  if the image is displayed at 
less than full size.]

*  Rev Dictionary: "To manipulate each pixel (for example, to 
brighten the image or remove the red channel), to examine the actual 
screen appearance of the image, or to work with the picture data in a 
format-independent way, use the imageData property."  I think this 
should read "use the rle format" instead of "use the imageData 
property."  [Though one could reference the imageData property to 
convert images in other formats to rle.]

*  Rev Dictionary, "To take advantage of the characteristics of a 
particular format or to transfer picture data between objects, use 
the image content."  [Emphasis mine.]

So Jacque notes that "set the imageData of image id 12345 to 
my32x32RLEString" should be functionally equivalent to "set the text 
of image id 12345 to my32x32RLEString", and Dar suggests people work 
with imageData because it's easier to decipher and manipulate 
bit-by-bit than other Rev image formats.

1.  Setting the text of an image automatically resets image 
dimensions (among other properties); setting the imageData of an 
image does NOT adjust dimensions and WILL cause image distortion if 
the imageData does not contain exactly the number of pixels needed to 
fill the screen space occupied by the image.

2.  Changing image content via resetting the imageData property ONLY 
works for data in rle format:

	get URL "binfile:/Disk/Folder/image.jpg"
	set the imageData of image id 12345 to it

will not display(or load?) the image correctly.  So I feel it's bad 
form to post solutions that change image content by changing the 
imageData; since it only works for one of the eight image formats Rev 
supports and does not update all the image properties that are 
touched by "set the text of image id 12345 to it".

3.  None of this means one cannot create and manipulate images rle 
format, it just means once one has created the image string, one 
should set the text of the image to it or put it into the image, 
rather than setting the imageData of the image to it.
-- 

Rob Cozens
CCW, Serendipity Software Company

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)


More information about the use-livecode mailing list