Blend Images

paolo mazza mazzapaolo at libero.it
Sun Sep 22 07:34:00 CDT 2002


This script blend two images provided the bigger one is called "imagine1"
and it has not a transparent background.
The script works but has two problems:
- it is slow
- it takes an incredible amount of ram
Any suggestions to speed this process?
Paolo Mazza

on MouseUp
  put the ID of the last image into NNN
  if there is not image "imagine1" then
    answer "There is not image imagine1" with "OK"
    exit to top
  end if
  put the MaskData of image "imagine1"  into MascheraData0 -- immagine
originale
  put the ImageData of image "imagine1" into ImmagineData0
  put the MaskData of image ID NNN  into MascheraData2 -- immagine da
incollare
  put the ImageData of image ID NNN into ImmagineData2

  put MascheraData0 into MascheraData1
  put ImmagineData0 into ImmagineData1

  put  the width of image "imagine1"  into X1
  put the height of image "imagine1"  into Y1
  put  the width of image ID NNN  into X2
  put the height of image ID NNN  into Y2
  if X2>X1 then exit to top
  if Y2>Y1 then exit to top


  put "0" into START
  put "0" into KY

  repeat for Y2
    put "0" into KX
    repeat for X2
      put KX+1 into KX
      put KX+(KY*X1) into PAR1
      put KX+(KY*X2) into PAR2
      if chartonum(char PAR2 of MascheraData2) <>  "0"  then
        --  put char PAR2 of MascheraData2 into char PAR1 of MascheraData1
        put PAR1*4 into PAR1
        put PAR2*4 into PAR2
        put char (PAR2-3) to PAR2 of ImmagineData2 into char (PAR1-3) to
PAR1 of ImmagineData1
      end if
    end repeat
    put KY+1 into KY
  end repeat

  if the number of chars of MascheraData1 is the number of chars of
MascheraData0  and  the number of chars of ImmagineData1 is the number of
chars of ImmagineData0  then
    set the MaskData of image "imagine1" to MascheraData1
    set the ImageData of image "imagine1" to ImmagineData1
  end if

  beep 1
end MouseUp






More information about the use-livecode mailing list