Design Challenge -- Round Corner mask on images

BNig bernd.niggemann at uni-wh.de
Wed Mar 30 07:00:50 EDT 2016


if you want to get round corners on an image, that does not make use of
alphaData, like jpg or png without alpha you can round the corners by
setting the alphaData as Alejandro has shown.

here is an example of setting the alphaData of an image to get round corners
on the fly

--------------------------------------------
on mouseUp
   lock screen
   put "iLittle" into tImgName -- change to the name of your image
   put "gRoundRect3" into tGrcName
   if not (there is a grc tGrcName) then
      reset the templateGraphic
      set the style of the templateGraphic to "roundRect"
      set the roundRadius of the templateGraphic to "30" -- change radius
here
      set the lineSize of the templateGraphic to 5 -- change border here
      set the opaque of the templateGraphic to true
      set the visible of the templateGraphic to true
      create grc tGrcName
      reset the templateGraphic
   end if
   set the rect of grc tGrcName to the rect of image tImgName -- just to get
dimensions right
   export snapshot from grc tGrcName to tImg as png
   create image "tempImg"
   set the text of image "tempImg" to tImg
   set the alphaData of image tImgName to the alphaData of img "tempImg"
   delete image "tempImg"
   delete grc tGrcName
   unlock screen
end mouseUp
-----------------------------------------------

to get rid of the round corners you can set the alphaData to be fully
transparent, thus restoring the original image

----------------------------------------------
on mouseUp
   put "iLittle" into tImgName -- change to name of your image
   put the width of image tImgName into tWidth
   put the height of image tImgName into tHeight
   put numToByte(255) into tTransparent
   repeat tWidth
      put tTransparent after tAlphaRow
   end repeat
   repeat tHeight
      put tAlphaRow after tAlpha
   end repeat
   set the alphaData of image "iLittle" to tAlpha
end mouseUp
--------------------------------------------

Kind regards
Bernd



--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/Design-Challenge-Round-Corner-mask-on-images-tp4702659p4702783.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list