OK, Here's the deal. Although there is a byte for alpha in the z buffer 
(imagedata) it seems to be ignored. The alpha data is only in the alphadata 
property. You also must set the text property to empty before you set the new 
image(imagedata) and alpha data(alphadata).

This example just does a crop in the middle of y and pastes the remaining top 
and bottom together:

command CropMiddleOfImage pImageName, pMiddlePercentCrop
   --
   -- pImageName ==> LiveCode image control's name
   -- pMiddlePercentCrop ==> 0 to 100
   --
   local tImageData, tWidth, tHeight, tTop, tBottom, tNewImageData, tAlphaData, 
tNewAlphaData
   
   lock screen
   put the imagedata of image pImageName into tImageData
   put the alphadata of image pImageName into tAlphaData
   put the width of image pImageName into tWidth
   put the height of image pImageName into tHeight
   
   put pMiddlePercentCrop / 100 into pMiddlePercentCrop
   put trunc((tHeight - (tHeight * pMiddlePercentCrop)) / 2) into tTop
   put tTop into tBottom
   if not (((tHeight - (tHeight * pMiddlePercentCrop)) / 2) is an integer) then
      add 1 to tBottom
   end if
   
   put byte 1 to (tTop*4*tWidth) -1 of tImageData into tNewImageData
   put byte (the number of bytes of tImageData - (tBottom*4*tWidth)) to -1 of 
tImageData after tNewImageData
   put byte 1 to (tTop*tWidth) -1 of tAlphaData into tNewAlphaData
   put byte (the number of bytes of tAlphaData - (tBottom*tWidth)) to -1 of 
tAlphaData after tNewAlphaData
   
   set the height of image pImageName to tTop+tBottom
   set the width of image pImageName to tWidth
   set the text of image pImageName to empty
   set the imagedata of image pImageName to tNewImageData
   set the alphadata of image pImageName to tNewAlphaData
   
   unlock screen
   
end CropMiddleOfImage pImageName

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net



_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to