Transparent Images in LC

Paul Dupuis paul at
Thu Mar 30 13:16:27 EDT 2017

NOTE: I am using LC 6.7.11 for an update to a legacy app.

I was trying to import (as a control) a transparent PNG (i.e. the
"white" parts allow whatever is underneath to show through) and instead
of transparancy, I get the slashed background lines transparent PNG are
often displayed with. Thinking it might be the PNG itself, I have our
graphics person create a PNG that was transparent and shows up as
transparent in other app, it still was not importing with the
transparent parts transparent in LC.

Ultimately, I took the same image with the "transparent" parts as actual
white and used the code below to create a transparency mask

command makeMask pObj
  -- pObjs is a reference to an Image object
  local tMaskData -- set to 0 [tranparent] for each byte in imageData
that is white
  get the imageData of pObj -- 4 bytes, 0,r,g,b white = 255, black = 0
  put the number of bytes in it into X
  repeat with i=1 to X step 4
    if i > X then exit repeat
    put byte (i+1) of it into r
    put byte (i+2) of it into g
    put byte (i+3) of it into b
    put byteToNum(r) into rV
    put byteToNum(g) into gV
    put byteToNum(b) into bV
    if rV=255 and gV=255 and bV=255 then
      put numToByte(0) after tMaskData
      put numToByte(1) after tMaskData
    end if
  end repeat
  set the maskData of pObj to tMaskData
end makeMask

Am I missing something? Is there a way to actually import an image with
its transparency or is the only way via script control and scripting is
the only way has anyone make a plugin tool to do this and if you have
could you contribute the tool to the community edition and commercial
versions so a tool to import transparent images becomes part of the main
LiveCode distribution?

More information about the use-livecode mailing list